diff --git a/.github/add-comment-to-pull-request.sh b/.github/add-comment-to-pull-request.sh new file mode 100755 index 00000000..a562524d --- /dev/null +++ b/.github/add-comment-to-pull-request.sh @@ -0,0 +1,26 @@ +#!/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 new file mode 100755 index 00000000..ecd564fc --- /dev/null +++ b/.github/add-label-to-pull-request.sh @@ -0,0 +1,26 @@ +#!/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/dependabot.yml b/.github/dependabot.yml index bfc2e271..a217b347 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,16 +5,3 @@ updates: schedule: interval: daily open-pull-requests-limit: 10 - ignore: - - dependency-name: org.hibernate:hibernate-envers - versions: - - 5.4.27.Final - - 5.4.29.Final - - dependency-name: org.hibernate:hibernate-entitymanager - versions: - - 5.4.27.Final - - 5.4.29.Final - - dependency-name: org.hibernate:hibernate-core - versions: - - 5.4.27.Final - - 5.4.29.Final diff --git a/.github/set-version-from-head.sh b/.github/set-version-from-head.sh new file mode 100755 index 00000000..29fb0f5e --- /dev/null +++ b/.github/set-version-from-head.sh @@ -0,0 +1,13 @@ +#!/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 new file mode 100755 index 00000000..535e1fcd --- /dev/null +++ b/.github/set-version-from-pom.sh @@ -0,0 +1,6 @@ +#!/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/pull-request-labeled-closed.yml b/.github/workflows/pull-request-labeled-closed.yml new file mode 100644 index 00000000..ce55ebdb --- /dev/null +++ b/.github/workflows/pull-request-labeled-closed.yml @@ -0,0 +1,136 @@ +name: Prepare Release Candidate for Release + +on: + pull_request: + types: + - closed + +jobs: + verify: + name: Verify Closed PR is Release Candidate + 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: + - run: echo "Starting Release ... " + + build: + needs: [verify] + name: Build Artifact + 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' + 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-hibernate5 + 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-hibernate5 + + - name: Release + uses: softprops/action-gh-release@v1 + with: + target_commitish: ${{ github.sha }} + name: v${{ steps.version.outputs.version }} + tag_name: liquibase-hibernate5-${{ steps.version.outputs.version }} + draft: true + body: Support for Liquibase ${{ steps.version.outputs.version }}. + files: liquibase-hibernate5-*.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 new file mode 100644 index 00000000..602a2a58 --- /dev/null +++ b/.github/workflows/pull-request-labeled-release.yml @@ -0,0 +1,33 @@ +name: Build, Test, and Prepare Release Candidate + +on: + pull_request: + types: + - labeled + - reopened + - synchronize + +jobs: + integration-tests: + name: Java ${{ matrix.java }} + runs-on: ubuntu-latest + if: contains( github.event.pull_request.labels.*.name, 'Extension Release Candidate :rocket:' ) + strategy: + matrix: + java: [8, 11, 16] + 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 --file pom.xml diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 00000000..df87398d --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,94 @@ +name: Run Unit Tests + +on: + pull_request: + types: + - opened + - reopened + - synchronize + +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] + + 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: 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-hibernate5-$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: "