From 5bf3c9eaf867429708dbe9b65b73eba81958781f Mon Sep 17 00:00:00 2001 From: Nathan Voxland Date: Wed, 10 Nov 2021 16:17:39 -0600 Subject: [PATCH] Updated release automation - Use triggers vs. dependabot --- .github/add-comment-to-pull-request.sh | 26 --- .github/add-label-to-pull-request.sh | 26 --- .github/set-version-from-head.sh | 13 -- .github/set-version-from-pom.sh | 6 - .github/workflows/create-release.yml | 199 ++++++++++++++++++ .../workflows/pull-request-labeled-closed.yml | 126 ----------- .../pull-request-labeled-release.yml | 40 ---- .github/workflows/pull-request.yml | 61 ------ pom.xml | 3 +- 9 files changed, 200 insertions(+), 300 deletions(-) delete mode 100755 .github/add-comment-to-pull-request.sh delete mode 100755 .github/add-label-to-pull-request.sh delete mode 100755 .github/set-version-from-head.sh delete mode 100755 .github/set-version-from-pom.sh create mode 100644 .github/workflows/create-release.yml delete mode 100644 .github/workflows/pull-request-labeled-closed.yml delete mode 100644 .github/workflows/pull-request-labeled-release.yml diff --git a/.github/add-comment-to-pull-request.sh b/.github/add-comment-to-pull-request.sh deleted file mode 100755 index a562524d..00000000 --- a/.github/add-comment-to-pull-request.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -set -ex -set -o pipefail - -if [[ -z "$GITHUB_TOKEN" ]]; then - echo "Set the GITHUB_TOKEN env variable." - exit 1 -fi - -if [[ -z "$GITHUB_ISSUE_URL" ]]; then - echo "Set the GITHUB_ISSUE_URL env variable." - exit 1 -fi - -if [[ -z "$GITHUB_COMMENT" ]]; then - echo "Set the GITHUB_COMMENT env variable." - exit 1 -fi - -data='{"body":"'${GITHUB_COMMENT}'"}' - -#Create Label on Pull Request -curl -X POST -H "Authorization: token $GITHUB_TOKEN" \ - --data "$data" \ - "$GITHUB_ISSUE_URL/comments" diff --git a/.github/add-label-to-pull-request.sh b/.github/add-label-to-pull-request.sh deleted file mode 100755 index ecd564fc..00000000 --- a/.github/add-label-to-pull-request.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -if [[ -z "$GITHUB_TOKEN" ]]; then - echo "Set the GITHUB_TOKEN env variable." - exit 1 -fi - -if [[ -z "$GITHUB_ISSUE_URL" ]]; then - echo "Set the GITHUB_ISSUE_URL env variable." - exit 1 -fi - -if [[ -z "$GITHUB_LABEL" ]]; then - echo "Set the GITHUB_LABEL env variable." - exit 1 -fi - -data='["'${GITHUB_LABEL}'"]' - -#Create Label on Pull Request -curl -X POST -H "Authorization: token $GITHUB_TOKEN" \ - --data "$data" \ - "$GITHUB_ISSUE_URL/labels" diff --git a/.github/set-version-from-head.sh b/.github/set-version-from-head.sh deleted file mode 100755 index 29fb0f5e..00000000 --- a/.github/set-version-from-head.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -HEAD_REF=$1 - -if [[ -z "$HEAD_REF" ]]; then - echo "Set the HEAD_REF parameter" - exit 1 -fi - -echo "VERSION_TAG=${HEAD_REF#*org.liquibase-liquibase-core-}" >> $GITHUB_ENV \ No newline at end of file diff --git a/.github/set-version-from-pom.sh b/.github/set-version-from-pom.sh deleted file mode 100755 index 535e1fcd..00000000 --- a/.github/set-version-from-pom.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -echo "VERSION_TAG=$(mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV \ No newline at end of file diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml new file mode 100644 index 00000000..2cb4a324 --- /dev/null +++ b/.github/workflows/create-release.yml @@ -0,0 +1,199 @@ +name: Release Extension (v2) +on: + repository_dispatch: + types: [liquibase-release] + workflow_dispatch: + inputs: + liquibaseVersion: + description: 'Liquibase Version' + required: true + extensionVersion: + description: 'Extension Version (Defaults to Liquibase Version)' + required: false + +jobs: + setup: + name: Setup + runs-on: ubuntu-latest + outputs: + liquibaseVersion: ${{ steps.collect-data.outputs.liquibaseVersion }} + extensionVersion: ${{ steps.collect-data.outputs.extensionVersion }} + steps: + - name: Collect Data + id: collect-data + uses: actions/github-script@v4 + with: + script: | + if (context.payload.client_payload) { + core.setOutput("liquibaseVersion", context.payload.client_payload.liquibaseVersion); + core.setOutput("extensionVersion", context.payload.client_payload.liquibaseVersion); + } else if (context.payload.inputs) { + core.setOutput("liquibaseVersion", context.payload.inputs.liquibaseVersion); + core.setOutput("extensionVersion", context.payload.inputs.extensionVersion || context.payload.inputs.liquibaseVersion); + } else { + core.setFailed('Unknown event type') + } + + - run: | + echo "Saw Liquibase version ${{ steps.collect-data.outputs.liquibaseVersion }}" + echo "Saw Extension version ${{ steps.collect-data.outputs.extensionVersion }}" + + build: + name: "Build and Test" + runs-on: ubuntu-latest + needs: setup + outputs: + releaseSha: ${{ steps.get-release-sha.outputs.releaseSha }} + steps: + - uses: actions/checkout@v2 + with: + persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token + fetch-depth: 0 # otherwise, you will fail to push refs to dest repo + + - name: Cache Built Code + uses: actions/cache@v2 + with: + key: built-code-${{ github.run_id }} + path: ./**/target + + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'adopt' + + - name: Configure git user + run: | + git config user.name "liquibot" + git config user.email "liquibot@liquibase.org" + + - name: Download and install liquibase.jar + uses: dsaltares/fetch-gh-release-asset@master + with: + repo: "liquibase/liquibase" + version: "tags/v${{ needs.setup.outputs.liquibaseVersion }}" + file: "liquibase-${{ needs.setup.outputs.liquibaseVersion }}.jar" + target: "liquibase.jar" + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Install liquibase.jar + run: mvn -B org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file -Dfile=liquibase.jar + + - name: Update pom.xml with release versions and commit changes + run: | + mvn -B versions:set -DnewVersion=${{ needs.setup.outputs.extensionVersion }} -DallowSnapshots=false -DoldVersion="*" + mvn -B versions:use-dep-version -Dincludes=org.liquibase:liquibase-core -DdepVersion=${{ needs.setup.outputs.liquibaseVersion }} -DforceVersion=true + + git add pom.xml + if git diff-index --cached --quiet HEAD -- + then + echo "Nothing new to commit" + else + git commit -m "Version Bumped to ${{ needs.setup.outputs.extensionVersion }}" + fi + git tag -a -m "Version Bumped to ${{ needs.setup.outputs.extensionVersion }}" liquibase-mongodb-${{ needs.setup.outputs.extensionVersion }} + git push "https://liquibot:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git" HEAD:${{ github.ref }} --follow-tags --tags + + env: + GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} + + - name: Get release SHA + id: get-release-sha + run: echo ::set-output name=releaseSha::$(git rev-parse HEAD) + + + - name: Build and Unit Test + run: mvn -B clean test package + + - name: Archive Test Results + if: ${{ always() }} + uses: actions/upload-artifact@v2 + with: + name: test-reports-jdk + path: ./**/target/surefire-reports + + - name: Save Artifacts + uses: actions/upload-artifact@v2 + with: + name: liquibase-mongodb + path: | + target/*.jar + + integration-tests: + name: Java ${{ matrix.java }} + runs-on: ubuntu-latest + needs: build + strategy: + matrix: + java: [8, 11, 17] + mongodb: [4] + services: + mongodb: + image: mongo:${{ matrix.mongodb }} + ports: + - 27017-27019:27017-27019 + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK ${{ matrix.java }} + uses: actions/setup-java@v2 + with: + java-version: ${{ matrix.java }} + distribution: 'adopt' + - name: Test With Maven + run: mvn clean verify -Prun-its --file pom.xml + + draft-release: + needs: [ setup, build, integration-tests ] + name: Draft Release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Download Artifacts + uses: actions/download-artifact@v2 + with: + name: liquibase-mongodb + + - name: Release + uses: softprops/action-gh-release@v1 + with: + target_commitish: ${{ needs.build.outputs.releaseSha }} + name: v${{ needs.setup.outputs.extensionVersion }} + tag_name: liquibase-mongodb-${{ needs.setup.outputs.extensionVersion }} + draft: true + body: Support for Liquibase ${{ needs.setup.outputs.liquibaseVersion }}. + files: liquibase-mongodb-*.jar + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + bump-pom-to-snapshot: + name: Prepare POM for Development + runs-on: ubuntu-latest + needs: [ draft-release ] + steps: + - uses: actions/checkout@v2 + with: + persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token + fetch-depth: 0 # otherwise, you will failed to push refs to dest repo + + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'adopt' + + - name: Configure git user + run: | + git config user.name "liquibot" + git config user.email "liquibot@liquibase.org" + + - name: Prepare code for next version + run: | + git pull + mvn -B versions:set -DnextSnapshot=true + git add pom.xml + git commit -m "Version Bumped to Snapshot for Development" + git push "https://liquibot:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git" HEAD:${{ github.ref }} --follow-tags --tags + env: + GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} diff --git a/.github/workflows/pull-request-labeled-closed.yml b/.github/workflows/pull-request-labeled-closed.yml deleted file mode 100644 index 8566877c..00000000 --- a/.github/workflows/pull-request-labeled-closed.yml +++ /dev/null @@ -1,126 +0,0 @@ -name: Prepare Release Candidate for Release - -on: - pull_request: - types: - - closed - -jobs: - build: - name: Build Artifact - runs-on: ubuntu-latest - if: github.ref == 'main'&& github.event.pull_request.merged && contains( github.event.pull_request.labels.*.name, 'Extension Release Candidate :rocket:' ) - steps: - - uses: actions/checkout@v2 - - name: Cache Local Maven Repository - uses: actions/cache@v2 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - - name: Set up JDK 11 - uses: actions/setup-java@v2 - with: - java-version: '11' - distribution: 'adopt' - server-id: sonatype-nexus-staging - server-username: MAVEN_USERNAME - server-password: MAVEN_PASSWORD - gpg-private-key: ${{ secrets.GPG_SECRET }} - gpg-passphrase: GPG_PASSPHRASE - - - name: Build With Maven - run: mvn clean install -Dmaven.test.skip - env: - MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }} - MAVEN_PASSWORD: ${{ secrets.SONATYPE_TOKEN }} - GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - - - name: Upload Artifacts - uses: actions/upload-artifact@v2 - with: - name: liquibase-mongodb - path: target/*.jar - - draft-release: - needs: [ build ] - name: Draft Release - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Cache Local Maven Repository - uses: actions/cache@v2 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - - name: Set up JDK 11 - uses: actions/setup-java@v2 - with: - java-version: '11' - distribution: 'adopt' - - - name: Set Version Tag ENV from POM - run: ./.github/set-version-from-pom.sh - - - run: echo ::set-output name=version::$VERSION_TAG - id: version - - - name: Download Artifacts - uses: actions/download-artifact@v2 - with: - name: liquibase-mongodb - - - name: Release - uses: softprops/action-gh-release@v1 - with: - target_commitish: ${{ github.sha }} - name: v${{ steps.version.outputs.version }} - tag_name: liquibase-mongodb-${{ steps.version.outputs.version }} - draft: true - body: Support for Liquibase ${{ steps.version.outputs.version }}. - files: liquibase-mongodb-*.jar - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - bump-pom-to-snapshot: - name: Prepare POM for Development - runs-on: ubuntu-latest - needs: [ draft-release ] - steps: - - uses: actions/checkout@v2 - with: - persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token - fetch-depth: 0 # otherwise, you will failed to push refs to dest repo - - - name: Cache Local Maven Repository - uses: actions/cache@v2 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - - name: Set up JDK 11 - uses: actions/setup-java@v2 - with: - java-version: '11' - distribution: 'adopt' - - - name: Configure git user - run: | - git config user.name "liquibot" - git config user.email "liquibot@liquibase.org" - - - name: Bump POM Version for Development - run: | - mvn versions:set -DnextSnapshot=true - git add pom.xml - git commit -m "Version Bumped to Snapshot for Developent" - git push "https://liquibot:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git" HEAD:${{ github.base_ref }} --follow-tags --tags - env: - GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/pull-request-labeled-release.yml b/.github/workflows/pull-request-labeled-release.yml deleted file mode 100644 index f14b26bd..00000000 --- a/.github/workflows/pull-request-labeled-release.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Build, Test, and Prepare Release Candidate - -on: - pull_request: - types: - - labeled - - reopened - - synchronize - -jobs: - integration-tests: - name: Java ${{ matrix.java }}, MongoDB ${{ matrix.mongodb }} - runs-on: ubuntu-latest - if: contains( github.event.pull_request.labels.*.name, 'Extension Release Candidate :rocket:' ) - strategy: - matrix: - java: [8, 11, 16] - mongodb: [4] - services: - mongodb: - image: mongo:${{ matrix.mongodb }} - ports: - - 27017-27019:27017-27019 - - steps: - - uses: actions/checkout@v2 - - name: Cache Local Maven Repository - uses: actions/cache@v2 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v2 - with: - java-version: ${{ matrix.java }} - distribution: 'adopt' - - name: Test With Maven - run: mvn clean verify -Prun-its --file pom.xml diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 6d67e7bf..a072142d 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -11,8 +11,6 @@ jobs: unit-test: name: Java ${{ matrix.java }} runs-on: ubuntu-latest - # Only run job if untagged as release. Will run for all PRs and release PRs during the first run. - if: ${{ !contains( github.event.pull_request.labels.*.name, 'Extension Release Candidate :rocket:' ) }} strategy: matrix: java: [8, 11, 16] @@ -33,62 +31,3 @@ jobs: distribution: 'adopt' - name: Run Unit Tests With Maven run: mvn surefire:test --file pom.xml - - # This step is the automation to create a release based on a liquibase core bump - # If a manual release is required, the steps below will need to be done manually prior - # to adding the Release Candidate label. - label: - name: Label as Release Candidate - runs-on: ubuntu-latest - needs: [ unit-test ] - if: contains( github.event.pull_request.head.ref, 'dependabot/maven/org.liquibase-liquibase-core' ) - steps: - - uses: actions/checkout@v2 - with: - persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token - fetch-depth: 0 # otherwise, you will failed to push refs to dest repo - - - name: Cache Local Maven Repository - uses: actions/cache@v2 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - - name: Set up JDK 11 - uses: actions/setup-java@v2 - with: - java-version: '11' - distribution: 'adopt' - - - name: Set Version Tag ENV - run: ./.github/set-version-from-head.sh ${{ github.event.pull_request.head.ref }} - - - run: echo $VERSION_TAG - - - name: Configure git user - run: | - git config user.name "liquibot" - git config user.email "liquibot@liquibase.org" - - - name: Bump POM Version for Next Release - run: | - mvn versions:set -DnewVersion=$VERSION_TAG - git add pom.xml - git commit -m "Version Bumped to $VERSION_TAG" - git tag -a -m "Version Bumped to $VERSION_TAG" liquibase-mongodb-$VERSION_TAG - git push "https://liquibot:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git" HEAD:${{ github.event.pull_request.head.ref }} --follow-tags --tags - env: - GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} - - - run: ./.github/add-label-to-pull-request.sh - env: - GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} - GITHUB_ISSUE_URL: ${{ github.event.pull_request._links.issue.href }} - GITHUB_LABEL: "Extension Release Candidate :rocket:" - - run: ./.github/add-comment-to-pull-request.sh - env: - GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} - GITHUB_ISSUE_URL: ${{ github.event.pull_request._links.issue.href }} - GITHUB_COMMENT: "

⚠️ Reminder

Release Candidate pull requests will automatically release when merged.

Please review and merge all other pull requests prior to merging this request." \ No newline at end of file diff --git a/pom.xml b/pom.xml index 20bab078..ed0ac231 100644 --- a/pom.xml +++ b/pom.xml @@ -37,7 +37,6 @@ UTF-8 2.22.2 2.22.2 - 4.5.0 5.8.1 1.3.2 4.0.0 @@ -66,7 +65,7 @@ org.liquibase liquibase-core - ${liquibase.version} + 4.5.0 provided