-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Use triggers vs. dependabot
- Loading branch information
Showing
8 changed files
with
251 additions
and
305 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,239 @@ | ||
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 Local Maven Repository | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: | | ||
${{ runner.os }}-maven- | ||
- 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 "[email protected]" | ||
- 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 | ||
git commit -m "Version Bumped to ${{ needs.setup.outputs.extensionVersion }}" | ||
git tag -a -m "Version Bumped to ${{ needs.setup.outputs.extensionVersion }}" liquibase-cassandra-${{ needs.setup.outputs.extensionVersion }} | ||
git push "https://liquibot:[email protected]/$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-cassandra | ||
path: | | ||
target/*.jar | ||
integration-tests: | ||
name: Java ${{ matrix.java }} | ||
runs-on: ubuntu-latest | ||
needs: build | ||
strategy: | ||
matrix: | ||
java: [8, 11] | ||
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: Cache Built Code | ||
uses: actions/cache@v2 | ||
with: | ||
key: built-code-${{ github.run_id }} | ||
path: ./**/target | ||
|
||
- name: Set up JDK ${{ matrix.java }} | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: ${{ matrix.java }} | ||
distribution: 'adopt' | ||
|
||
- name: Start Cassandra Container | ||
run: docker run -p 9042:9042 -v $(pwd):/app --name mycassandra -d cassandra | ||
|
||
- name: Wait for cassandra to start up | ||
run: sleep 90s | ||
|
||
- name: Check cassandra status | ||
run: docker ps -a | ||
|
||
- name: Check cassandra logs | ||
run: docker logs mycassandra | ||
|
||
- name: Load Cassandra Config | ||
run: docker exec mycassandra cqlsh localhost 9042 -f /app/test.cql | ||
|
||
- name: Run Tests | ||
run: mvn -B verify | ||
|
||
- name: Archive Test Results | ||
if: ${{ always() }} | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: test-reports-integration-jdk${{ matrix.java }}-cassandra${{ matrix.cassandra }} | ||
path: ./**/target/surefire-reports | ||
|
||
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-cassandra | ||
|
||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
target_commitish: ${{ needs.build.outputs.releaseSha }} | ||
name: v${{ needs.setup.outputs.extensionVersion }} | ||
tag_name: liquibase-cassandra-${{ needs.setup.outputs.extensionVersion }} | ||
draft: true | ||
body: Support for Liquibase ${{ needs.setup.outputs.liquibaseVersion }}. | ||
files: liquibase-cassandra-*.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 | ||
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 "[email protected]" | ||
- 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:[email protected]/$GITHUB_REPOSITORY.git" HEAD:${{ github.ref }} --follow-tags --tags | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} |
Oops, something went wrong.