Skip to content

Commit

Permalink
Build docker and create release pipeline (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
rtorsten authored Mar 31, 2023
1 parent 3678148 commit 91c4e20
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 34 deletions.
4 changes: 2 additions & 2 deletions .deploy/demo/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ app:
component: "emulator"
replicaCount: 1
image:
name: localhost:5000/droidherd-service
tag: local
name: tinkoffcreditsystems/droidherd
tag: latest
pullPolicy: "Always"
service:
port: 8080
Expand Down
12 changes: 12 additions & 0 deletions .github/scripts/release-env-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

echo "Checking repository [$GITHUB_REPOSITORY]..."
[[ "${GITHUB_REPOSITORY}" != "tinkoff-mobile-tech/droidherd" ]] && exit 1

echo "Checking that ref type is tag ..."
[[ "${GITHUB_REF_TYPE}" != "tag" ]] && exit 1

echo "Checking tag [$GITHUB_REF_NAME]..."
[[ "${GITHUB_REF_NAME}" =~ ^release-[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit 1

echo "Ok, lets go"
13 changes: 4 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
name: Building, testing and assembling jar-file
name: Build and test

on:
push:
branches: [ "main" ]
pull_request:
workflow_dispatch:
on: [ push ]

jobs:
gradle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Build, test and assemble jar
run: ./gradlew build test bootJar
run: ./gradlew assemble test
52 changes: 29 additions & 23 deletions .github/workflows/release-api.yml → .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
name: Release Droidherd API
name: Release Droidherd

on:
release:
types: [created, workflow_dispatch]

env:
MVN_LOGIN: ${{ secrets.NEXUS_LOGIN }}
MVN_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
DOCKER_REPOSITORY: ${{secrets.DOCKER_REPOSITORY}}

jobs:
with:
publish-api-to-maven-repo:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Check repository
run: |
[[ "${GITHUB_REPOSITORY}" != "tinkoff-mobile-tech/droidherd" ]] && exit 1
- uses: actions/checkout@v3

- name: Check release tag
run: |
[[ "${GITHUB_REF_NAME}" =~ ^release-[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit 1
- name: Check repository and tag
run: .github/scripts/release-env-check.sh

- name: Set build version
run: |
VERSION = $(echo "release-0.2.3" | grep -Eo '[0-9]\.[0-9]+\.[0-9]+')
echo "Evaluated version: $VERSION"
[[ -z "$VERSION" ]] && exit 1
echo "BUILD_VERSION=${VERSION}" >> $GITHUB_ENV
echo "BUILD_VERSION=$(echo $GITHUB_REF_NAME | grep -Eo '[0-9]\.[0-9]+\.[0-9]+')" >> $GITHUB_ENV
- uses: actions/checkout@v3
- name: Show and check version
run: |
echo "Evaluated version: [$BUILD_VERSION]"
if [[ -z "$BUILD_VERSION" ]]; then exit 1; fi
- name: Set up JDK 11
uses: actions/setup-java@v3
Expand All @@ -36,15 +37,15 @@ jobs:
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1

- name: Retrieve the secret and decode it to a file
env:
GPG_KEY: ${{ secrets.GPG_KEY }}
run: echo "$GPG_KEY" | base64 --decode > /tmp/secring.gpg
- name: Build
run: ./gradlew assemble test

- name: Retrieve the gradle.properties
- name: Generate sign key for publishing
env:
GPG_KEY: ${{ secrets.GPG_KEY }}
SIGN_OSSRH_GRADLE_PROPERTIES: ${{ secrets.SIGN_OSSRH_GRADLE_PROPERTIES }}
run: |
echo "$GPG_KEY" | base64 --decode > /tmp/secring.gpg
mkdir -p ~/.gradle
echo -en "$SIGN_OSSRH_GRADLE_PROPERTIES" > ~/.gradle/gradle.properties
Expand All @@ -54,14 +55,19 @@ jobs:
arguments: :api:publish -Psigning.secretKeyRingFile=/tmp/secring.gpg
env:
MVN_RELEASE_REPOSITORY: https://oss.sonatype.org/service/local/staging/deploy/maven2/
MVN_LOGIN: ${{ secrets.NEXUS_LOGIN }}
MVN_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}

- name: Execute Gradle nexus staging release
uses: gradle/gradle-build-action@v2
with:
arguments: closeAndReleaseRepository
env:
MVN_RELEASE_REPOSITORY: https://oss.sonatype.org/service/local/
MVN_LOGIN: ${{ secrets.NEXUS_LOGIN }}
MVN_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}

- name: Docker build and push
run: |
echo '${{ secrets.DOCKER_REPOSITORY_PASSWORD }}' | docker login -u $DOCKER_REPOSITORY --password-stdin
docker build ./app --file ./app/OssDockerfile --tag $DOCKER_REPOSITORY/droidherd:${BUILD_VERSION}
docker push $DOCKER_REPOSITORY/droidherd:${BUILD_VERSION}
docker tag $DOCKER_REPOSITORY/droidherd:${BUILD_VERSION} $DOCKER_REPOSITORY/droidherd:latest
echo "Update latest tag $DOCKER_REPOSITORY/droidherd"
docker push $DOCKER_REPOSITORY/droidherd:latest

0 comments on commit 91c4e20

Please sign in to comment.