From 79442a7e821bb0d789995cb0ca74a63a39e5923e Mon Sep 17 00:00:00 2001 From: Ruslan Ibragimov <94184844+5hin0bi@users.noreply.github.com> Date: Fri, 21 Jan 2022 10:47:48 +0300 Subject: [PATCH] Change the way of release workflow (#1434) * use version placeholders in pom.xml files * add release drafter config and workflow * update master workflow * update release workflow * update branch-deploy.yml workflow Co-authored-by: Roman Zabaluev --- .github/release_drafter.yaml | 35 +++++++++ .github/workflows/branch-deploy.yml | 4 +- .github/workflows/master.yaml | 13 +++- .github/workflows/release.yaml | 101 +++++--------------------- .github/workflows/release_drafter.yml | 18 +++++ kafka-ui-api/pom.xml | 2 +- kafka-ui-contract/pom.xml | 2 +- kafka-ui-e2e-checks/pom.xml | 2 +- pom.xml | 3 +- 9 files changed, 90 insertions(+), 90 deletions(-) create mode 100644 .github/release_drafter.yaml create mode 100644 .github/workflows/release_drafter.yml diff --git a/.github/release_drafter.yaml b/.github/release_drafter.yaml new file mode 100644 index 0000000000..21ad76787b --- /dev/null +++ b/.github/release_drafter.yaml @@ -0,0 +1,35 @@ +name-template: 'v$RESOLVED_VERSION' +tag-template: '$RESOLVED_VERSION' +template: | + ## Changes + $CHANGES + ## Contributors + $CONTRIBUTORS + +exclude-labels: + - 'skip-changelog' + +categories: + - title: '⚙️Features' + labels: + - 'type/feature' + - title: '🪛Enhancements' + labels: + - 'type/enhancement' + - title: '🔨Bug Fixes' + labels: + - 'type/bug' + +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' + +version-resolver: + major: + labels: + - 'major' + minor: + labels: + - 'minor' + patch: + labels: + - 'patch' + default: patch diff --git a/.github/workflows/branch-deploy.yml b/.github/workflows/branch-deploy.yml index 996ba05da6..92dc1483e9 100644 --- a/.github/workflows/branch-deploy.yml +++ b/.github/workflows/branch-deploy.yml @@ -35,9 +35,9 @@ jobs: - name: Build id: build run: | - export VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) + mvn clean package -Pprod -DskipTests -DbuildVersion=$GITHUB_SHA + export VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' -DbuildVersion=$GITHUB_SHA --non-recursive exec:exec) echo "::set-output name=version::${VERSION}" - mvn clean package -Pprod -DskipTests - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx diff --git a/.github/workflows/master.yaml b/.github/workflows/master.yaml index 0417c5203b..ffc9469069 100644 --- a/.github/workflows/master.yaml +++ b/.github/workflows/master.yaml @@ -1,4 +1,4 @@ -name: latest +name: Master on: workflow_dispatch: push: @@ -9,6 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: Cache local Maven repository uses: actions/cache@v2 with: @@ -16,16 +17,18 @@ jobs: key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-maven- + - name: Set up JDK 1.13 uses: actions/setup-java@v1 with: java-version: 1.13 + - name: Build id: build run: | - export VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) + mvn clean package -Pprod -DskipTests -DbuildVersion=$GITHUB_SHA + export VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' -DbuildVersion=$GITHUB_SHA --non-recursive exec:exec) echo "::set-output name=version::${VERSION}" - mvn clean package -Pprod -DskipTests ################# # # # Docker images # @@ -33,8 +36,10 @@ jobs: ################# - name: Set up QEMU uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 + - name: Cache Docker layers uses: actions/cache@v2 with: @@ -42,11 +47,13 @@ jobs: key: ${{ runner.os }}-buildx-${{ github.sha }} restore-keys: | ${{ runner.os }}-buildx- + - name: Login to DockerHub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push id: docker_build_and_push uses: docker/build-push-action@v2 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6ca4193f05..49b4be1ac1 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,19 +1,7 @@ -name: release -on: - workflow_dispatch: - inputs: - customVersion: - description: 'A new version for release, please provide with -SNAPSHOT suffix' - required: false - default: '0.0.0' - rebuild: - description: 'A tag name for building previously created release' - required: false - default: 'v0.0.0' - extraMavenOptions: - description: 'A extra options for Maven' - required: false - default: '' +name: Release +on: + release: + types: [published] jobs: release: @@ -24,9 +12,11 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 + - run: | git config user.name github-actions git config user.email github-actions@github.com + - name: Cache local Maven repository uses: actions/cache@v2 with: @@ -34,43 +24,19 @@ jobs: key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-maven- + - name: Set up JDK 1.13 uses: actions/setup-java@v1 with: java-version: 1.13 - - name: Checkout to specific tag - if: github.event.inputs.rebuild != 'v0.0.0' - run: | - git checkout tags/${{ github.event.inputs.rebuild }} -b rebuild-${{ github.event.inputs.rebuild }} - - name: Set custom version - if: github.event.inputs.customVersion != '0.0.0' && github.event.inputs.rebuild == 'v0.0.0' - run: | - mvn -q versions:set -DnewVersion=${{ github.event.inputs.customVersion }} - git add pom.xml **/pom.xml - git commit -m "Increased release" - - name: Update development version - if: github.event.inputs.rebuild == 'v0.0.0' - run: | - mvn -q versions:set -DnextSnapshot - git add pom.xml **/pom.xml - git commit -m "Increased version in pom.xml" - git push -f - git reset --hard HEAD~1 - - name: Prepare release - if: github.event.inputs.rebuild == 'v0.0.0' - run: | - mvn -q versions:set -DremoveSnapshot - export VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) - git add . - git commit -m "release ${VERSION}" - git tag -f v${VERSION} - git push --tags + - name: Build with Maven id: build run: | - mvn clean package -Pprod ${{ github.event.inputs.extraMavenOptions }} - export VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) + mvn clean package -Pprod -DskipTests -DbuildVersion=${{ github.event.release.tag_name }} + export VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' -DbuildVersion=${{ github.event.release.tag_name }} --non-recursive exec:exec) echo ::set-output name=version::${VERSION} + - name: Archive JAR uses: actions/upload-artifact@v2 with: @@ -83,8 +49,10 @@ jobs: ################# - name: Set up QEMU uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 + - name: Cache Docker layers uses: actions/cache@v2 with: @@ -92,12 +60,14 @@ jobs: key: ${{ runner.os }}-buildx-${{ github.sha }} restore-keys: | ${{ runner.os }}-buildx- + - name: Login to DockerHub if: github.ref == 'refs/heads/master' uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push id: docker_build_and_push uses: docker/build-push-action@v2 @@ -113,6 +83,7 @@ jobs: JAR_FILE=kafka-ui-api-${{ steps.build.outputs.version }}.jar cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache + charts: runs-on: ubuntu-latest needs: release @@ -120,14 +91,18 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 1 + - run: | git config user.name github-actions git config user.email github-actions@github.com + - uses: azure/setup-helm@v1 + - name: update appVersion run: | export version=${{needs.release.outputs.version}} sed -i "s/appVersion:.*/appVersion: ${version}/" charts/kafka-ui/Chart.yaml + - name: add chart run: | export VERSION=${{needs.release.outputs.version}} @@ -139,39 +114,3 @@ jobs: git add -f ${MSG##*/} index.yaml git commit -m "release ${VERSION}" git push - gh-release: - runs-on: ubuntu-latest - needs: release - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - run: | - git config user.name github-actions - git config user.email github-actions@github.com - - id: generate - shell: /usr/bin/bash -x -e {0} - run: | - VERSION=${{needs.release.outputs.version}} - CHANGELOG=$(git --no-pager log --oneline --pretty=format:"- %s" `git tag --sort=-creatordate | grep '^v.*' | head -n2 | tail -n1`.. | uniq | grep -v '^- Merge\|^- skip') - CHANGELOG="${CHANGELOG//'%'/'%25'}" - CHANGELOG="${CHANGELOG//$'\n'/'%0A'}" - CHANGELOG="${CHANGELOG//$'\r'/'%0D'}" - echo ${CHANGELOG} - echo "::set-output name=changelog::${CHANGELOG}" - - name: Download release JAR - uses: actions/download-artifact@v2 - with: - name: kafka-ui-${{needs.release.outputs.version}} - path: . - - id: create_release - uses: softprops/action-gh-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - name: ${{needs.release.outputs.version}} - draft: false - tag_name: "v${{needs.release.outputs.version}}" - prerelease: false - files: kafka-ui-api-${{needs.release.outputs.version}}.jar - body: ${{steps.generate.outputs.changelog}} diff --git a/.github/workflows/release_drafter.yml b/.github/workflows/release_drafter.yml new file mode 100644 index 0000000000..a9170c4cc5 --- /dev/null +++ b/.github/workflows/release_drafter.yml @@ -0,0 +1,18 @@ +name: Release Drafter + +on: + push: + # branches to consider in the event; optional, defaults to all + branches: + - master + +jobs: + update_release_draft: + runs-on: ubuntu-latest + steps: + - uses: release-drafter/release-drafter@v5 + with: + config-name: release_drafter.yaml + disable-autolabeler: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/kafka-ui-api/pom.xml b/kafka-ui-api/pom.xml index 1c7f3f12ef..0c35def693 100644 --- a/kafka-ui-api/pom.xml +++ b/kafka-ui-api/pom.xml @@ -4,7 +4,7 @@ kafka-ui com.provectus - 0.3.3-SNAPSHOT + ${buildVersion} 4.0.0 diff --git a/kafka-ui-contract/pom.xml b/kafka-ui-contract/pom.xml index 0c4753f0df..03eb35bc4d 100644 --- a/kafka-ui-contract/pom.xml +++ b/kafka-ui-contract/pom.xml @@ -4,7 +4,7 @@ kafka-ui com.provectus - 0.3.3-SNAPSHOT + ${buildVersion} 4.0.0 diff --git a/kafka-ui-e2e-checks/pom.xml b/kafka-ui-e2e-checks/pom.xml index fd886c3943..08e454b46b 100644 --- a/kafka-ui-e2e-checks/pom.xml +++ b/kafka-ui-e2e-checks/pom.xml @@ -5,7 +5,7 @@ kafka-ui com.provectus - 0.3.3-SNAPSHOT + ${buildVersion} 4.0.0 diff --git a/pom.xml b/pom.xml index f8d99c9582..9a22325713 100644 --- a/pom.xml +++ b/pom.xml @@ -45,6 +45,7 @@ provectus https://sonarcloud.io + 0.0.1-SNAPSHOT @@ -84,7 +85,7 @@ com.provectus kafka-ui - 0.3.3-SNAPSHOT + ${buildVersion} kafka-ui Kafka metrics for UI panel