Skip to content

Commit

Permalink
Consume CORE and PRO packages from GitHub Package Manager (DAT-14615) (
Browse files Browse the repository at this point in the history
…liquibase#4197)

Consume CORE and PRO packages from GitHub Package Manager
Moving the logic of branch-build to build.yml so as to deploy the package which has successful builds to GPM
Adding a few dependencies to main pom.xml to like snakeyaml, maven-resources-plugin to handle the copying of project resources to the output directory, maven-install-plugin to install tar.gz
Flatten the pom for maven-plugin due to shaded logic
Changes to java classes for osgi framework errors

---------

Co-authored-by: Sayali M <sayali@Sayalis-MacBook-Pro>
Co-authored-by: Nathan Voxland <[email protected]>
Co-authored-by: Steven Massaro <[email protected]>
Co-authored-by: obovsunivskyii <[email protected]>
  • Loading branch information
5 people authored Jul 26, 2023
1 parent e2a2147 commit 16dc223
Show file tree
Hide file tree
Showing 12 changed files with 376 additions and 283 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ jobs:
# Publish to GitHub Packages
- name: Publish package
run: |
mvn -B clean deploy -DskipTests=true
mvn -B clean deploy -pl '!liquibase-dist' -DskipTests=true "-Dbuild.branch=${{ github.ref_name }}" "-Dbuild.number=${{ github.run_number }}" "-Dbuild.commit=${{ github.sha }}" "-Dbuild.repository.owner=${{ github.repository_owner }}" "-Dbuild.repository.name=${{ github.repository }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/build-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ jobs:
# This would still deploy a package if there are test failures. Might help to have build.yml complete and then run this workflow
# Publish to GitHub Packages
- name: Publish package
run: mvn -B clean deploy -DskipTests=true
run: mvn -B clean deploy -DskipTests=true "-Dbuild.branch=${{ github.ref_name }}" "-Dbuild.number=${{ github.run_number }}" "-Dbuild.commit=${{ github.sha }}" "-Dbuild.repository.owner=${{ github.repository_owner }}" "-Dbuild.repository.name=${{ github.repository }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
132 changes: 89 additions & 43 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ concurrency:
on:
workflow_dispatch:

# DAT branches can get triggered from this logic
pull_request_target:
types:
- opened
Expand Down Expand Up @@ -67,8 +68,6 @@ jobs:
if (${{ github.run_attempt }} % 5 == 0) {
core.setFailed("Fail every 5 run attempts to catch accidental infinite loops");
}
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha || github.event.after}}
Expand Down Expand Up @@ -181,6 +180,9 @@ jobs:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: 'maven'

# getting from build results page. If we remove 0-snapshot then we will need settings.xml

- name: Set up Maven
uses: stCarolas/[email protected]
with:
Expand All @@ -199,7 +201,6 @@ jobs:
run: |
find . -name original-*.jar -exec rm {} \;
- name: Archive Test Results
if: ${{ always() }}
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -232,6 +233,9 @@ jobs:
java-version: 11
distribution: 'adopt'
cache: 'maven'

# getting from build results page. If we remove 0-snapshot then we will need settings.xml

- name: Set up Maven
uses: stCarolas/[email protected]
with:
Expand Down Expand Up @@ -285,6 +289,9 @@ jobs:
java-version: '8'
distribution: 'temurin'
cache: 'maven'

# getting from build results page. If we remove 0-snapshot then we will need settings.xml

- name: Set up Maven
uses: stCarolas/[email protected]
with:
Expand Down Expand Up @@ -321,7 +328,7 @@ jobs:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha || github.event.after}}

# this includes all the tar files included in the previous runs. So in the next step we deploy what was previously build
- name: Built Code Cache
uses: actions/[email protected]
with:
Expand All @@ -343,31 +350,58 @@ jobs:
gpg-private-key: ${{ secrets.GPG_SECRET }}
gpg-passphrase: GPG_PASSPHRASE
cache: 'maven'
overwrite-settings: false
env:
GPG_PASSWORD: ${{ secrets.GPG_PASSPHRASE }}

# look for dependencies in maven
- name: maven-settings-xml-action
uses: whelk-io/maven-settings-xml-action@v20
with:
repositories: |
[
{
"id": "liquibase",
"url": "https://maven.pkg.github.com/liquibase/liquibase",
"releases": {
"enabled": "false"
},
"snapshots": {
"enabled": "true",
"updatePolicy": "always"
}
},
{
"id": "liquibase-pro",
"url": "https://maven.pkg.github.com/liquibase/liquibase-pro",
"releases": {
"enabled": "false"
},
"snapshots": {
"enabled": "true",
"updatePolicy": "always"
}
}
]
servers: |
[
{
"id": "liquibase-pro",
"username": "liquibot",
"password": "${{ secrets.LIQUIBOT_PAT }}"
},
{
"id": "liquibase",
"username": "liquibot",
"password": "${{ secrets.LIQUIBOT_PAT }}"
}
]
- name: Set up Maven
uses: stCarolas/[email protected]
with:
maven-version: ${{ env.MAVEN_VERSION }}

- name: Download liquibase-commercial
uses: liquibase/action-download-artifact@v2-liquibase
with:
github_token: ${{ secrets.BOT_TOKEN }}
workflow: build.yml
workflow_conclusion: success
branch: "${{ needs.setup.outputs.proBranchName }}"
name: liquibase-commercial-modules
path: download/liquibase-commercial
repo: liquibase/liquibase-pro

- name: Install Built Modules
run: |
(find . -name *-SNAPSHOT.jar -exec mvn -B org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file -Dfile={} \;)
(find . -name *-SNAPSHOT-sources.jar -exec mvn -B org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file -Dclassifier=sources -Dfile={} \;)
mvn -B org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file -Dfile=download/liquibase-commercial/liquibase-commercial-0-SNAPSHOT.jar
- name: Build & Sign Artifacts
env:
INSTALL4J_LICENSE: ${{ secrets.INSTALL4J_LICENSE }}
Expand All @@ -378,6 +412,7 @@ jobs:
INSTALL4J_WINDOWS_KEY: ${{ secrets.INSTALL4J_WINDOWS_KEY }}
INSTALL4J_WINDOWS_KEY_PASSWORD: ${{ secrets.INSTALL4J_WINDOWS_KEY_PASSWORD }}
GPG_PASSWORD: ${{ secrets.GPG_PASSPHRASE }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
## save install4j code signing keys
mkdir -p liquibase-dist/target/keys
Expand All @@ -386,28 +421,30 @@ jobs:
echo "Saving windows key"
echo "$INSTALL4J_WINDOWS_KEY" | base64 -d > liquibase-dist/target/keys/datical_windows.pfx
mvn -B -pl liquibase-dist -P liquibase-commercial source:jar package
# we are packaging and deploying liquibase tar which includes liquibase-commercial
mvn versions:set -DnewVersion="${{ needs.setup.outputs.thisBranchName }}-SNAPSHOT"
mvn -B -pl liquibase-dist -P liquibase-commercial source:jar package -Dliquibase-pro.version="${{ needs.setup.outputs.proBranchName }}-SNAPSHOT"
## extract tar content for other artifacts
mkdir -p liquibase-dist/target/liquibase-0-SNAPSHOT
(cd liquibase-dist/target/liquibase-0-SNAPSHOT && tar xfz ../liquibase-0-SNAPSHOT.tar.gz)
mkdir -p liquibase-dist/target/liquibase-${{ needs.setup.outputs.thisBranchName }}-SNAPSHOT
(cd liquibase-dist/target/liquibase-${{ needs.setup.outputs.thisBranchName }}-SNAPSHOT && tar -xzf ../liquibase-${{ needs.setup.outputs.thisBranchName }}-SNAPSHOT.tar.gz)
##create zip file from tar content
(cd liquibase-dist/target/liquibase-0-SNAPSHOT && zip -r ../liquibase-0-SNAPSHOT.zip *)
(cd liquibase-dist/target/liquibase-${{ needs.setup.outputs.thisBranchName }}-SNAPSHOT && zip -r ../liquibase-${{ needs.setup.outputs.thisBranchName }}-SNAPSHOT.zip *)
ls liquibase-dist/target/liquibase-${{ needs.setup.outputs.thisBranchName }}-SNAPSHOT
##create installer - disabled here but run as nightly job and as part of release workflow
# (cd liquibase-dist && ${{ github.workspace }}/.github/util/package-install4j.sh 0-SNAPSHOT)
find . -name original-*.jar -exec rm {} \;
mkdir -p artifacts
cp liquibase-dist/target/liquibase-0-SNAPSHOT.tar.gz artifacts
cp liquibase-dist/target/liquibase-0-SNAPSHOT.zip artifacts
cp liquibase-dist/target/liquibase-${{ needs.setup.outputs.thisBranchName }}-SNAPSHOT.tar.gz artifacts
cp liquibase-dist/target/liquibase-${{ needs.setup.outputs.thisBranchName }}-SNAPSHOT.zip artifacts
cp liquibase-core/target/liquibase-core-0-SNAPSHOT.jar artifacts/liquibase-core-0-SNAPSHOT.jar
cp liquibase-core/target/liquibase-core-0-SNAPSHOT-sources.jar artifacts/liquibase-core-0-SNAPSHOT-sources.jar
cp target/liquibase-0-SNAPSHOT-javadoc.jar artifacts/liquibase-core-0-SNAPSHOT-javadoc.jar
##create installer - disabled here but run as nightly job and as part of release workflow
#cp liquibase-dist/target/liquibase-*-installer-* artifacts
Expand All @@ -422,29 +459,30 @@ jobs:
cp liquibase-cdi-jakarta/target/liquibase-cdi-jakarta-0-SNAPSHOT.jar artifacts
cp liquibase-cdi-jakarta/target/liquibase-cdi-jakarta-0-SNAPSHOT-sources.jar artifacts
cp liquibase-cdi-jakarta/target/liquibase-cdi-jakarta-0-SNAPSHOT-javadoc.jar artifacts
echo "Source code not available for liquibase-commercial" > /tmp/readme.source.txt
(cd /tmp && jar cf liquibase-commercial-0-SNAPSHOT-sources.jar readme.source.txt)
(cd /tmp && jar cf liquibase-commercial-${{ needs.setup.outputs.proBranchName }}-SNAPSHOT-sources.jar readme.source.txt)
echo "Javadocs not available for liquibase-commercial" > /tmp/readme.javadocs.txt
(cd /tmp && jar cf liquibase-commercial-0-SNAPSHOT-javadoc.jar readme.javadocs.txt)
(cd /tmp && jar cf liquibase-commercial-${{ needs.setup.outputs.proBranchName }}-SNAPSHOT-javadoc.jar readme.javadocs.txt)
cp download/liquibase-commercial/liquibase-commercial-0-SNAPSHOT.jar artifacts
cp /tmp/liquibase-commercial-0-SNAPSHOT-sources.jar artifacts
cp /tmp/liquibase-commercial-0-SNAPSHOT-javadoc.jar artifacts
commercialJarM2Location=/Users/runner/.m2/repository/org/liquibase/liquibase-commercial/${{ needs.setup.outputs.proBranchName }}-SNAPSHOT/liquibase-commercial-${{ needs.setup.outputs.proBranchName }}-SNAPSHOT.jar
cp $commercialJarM2Location artifacts
cp /tmp/liquibase-commercial-${{ needs.setup.outputs.proBranchName }}-SNAPSHOT-sources.jar artifacts
cp /tmp/liquibase-commercial-${{ needs.setup.outputs.proBranchName }}-SNAPSHOT-javadoc.jar artifacts
.github/util/sign-artifacts.sh artifacts
##prepare branch-named convenience artifacts directories
mkdir artifacts-named
cp liquibase-dist/target/liquibase-0-SNAPSHOT.tar.gz artifacts-named/liquibase-${{ needs.setup.outputs.thisBranchFileName }}.tar.gz
cp liquibase-dist/target/liquibase-${{ needs.setup.outputs.thisBranchName }}-SNAPSHOT.tar.gz artifacts-named/liquibase-${{ needs.setup.outputs.thisBranchFileName }}.tar.gz
cp liquibase-core/target/liquibase-core-0-SNAPSHOT.jar artifacts-named/liquibase-core-${{ needs.setup.outputs.thisBranchFileName }}.jar
cp liquibase-maven-plugin/target/liquibase-maven-plugin-0-SNAPSHOT.jar artifacts-named/liquibase-maven-plugin-${{ needs.setup.outputs.thisBranchFileName }}.jar
cp liquibase-cdi/target/liquibase-cdi-0-SNAPSHOT.jar artifacts-named/liquibase-cdi-${{ needs.setup.outputs.thisBranchFileName }}.jar
cp liquibase-cdi-jakarta/target/liquibase-cdi-jakarta-0-SNAPSHOT.jar artifacts-named/liquibase-cdi-jakarta-${{ needs.setup.outputs.thisBranchFileName }}.jar
cp liquibase-extension-testing/target/liquibase-extension-testing-0-SNAPSHOT.jar artifacts-named/liquibase-extension-testing-${{ needs.setup.outputs.thisBranchFileName }}.jar
cp liquibase-extension-testing/target/liquibase-extension-testing-0-SNAPSHOT-deps.jar artifacts-named/liquibase-extension-testing-${{ needs.setup.outputs.thisBranchFileName }}-deps.jar
cp download/liquibase-commercial/liquibase-commercial-0-SNAPSHOT.jar artifacts-named/liquibase-commercial-${{ needs.setup.outputs.thisBranchFileName }}.jar
cp $commercialJarM2Location artifacts-named/liquibase-commercial-${{ needs.setup.outputs.thisBranchFileName }}.jar
- name: Archive Packages
uses: actions/upload-artifact@v3
Expand All @@ -456,7 +494,7 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: liquibase-zip-${{ needs.setup.outputs.thisBranchFileName }}
path: liquibase-dist/target/liquibase-0-SNAPSHOT/*
path: liquibase-dist/target/liquibase-${{ needs.setup.outputs.thisBranchName }}-SNAPSHOT/*

- name: Archive Convenience Artifacts
uses: actions/upload-artifact@v3
Expand All @@ -465,10 +503,18 @@ jobs:
path: artifacts-named/*


# Publish to GitHub Packages. We are building a tar file which includes liquibase-commercial hence we need "-Dliquibase-pro.version"
- name: Publish tar.gz package to GPM
run: |
mvn -B -pl liquibase-dist -P liquibase-commercial clean deploy -DskipTests=true -Dliquibase-pro.version="${{ needs.setup.outputs.proBranchName }}-SNAPSHOT" -Dbuild.timestamp=${{ steps.date.outputs.date }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# this triggers the pro-tests and test-harness to run
finish:
name: Finish Build
runs-on: ubuntu-22.04
needs: [ setup, build, integration-test, package, sonar ]
needs: [ setup, build, integration-test, package, sonar]
if: ${{ needs.setup.outputs.setupSuccessful }}
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -575,7 +621,7 @@ jobs:
})
}
});
let testHarnessBranch = await helper.findMatchingBranch("liquibase", "liquibase-test-harness");
if (testHarnessBranch.name == "main" || testHarnessBranch.name == "master") {
testHarnessBranch.name = "develop";
Expand Down Expand Up @@ -614,4 +660,4 @@ jobs:
"state": markFunctionalTestsStatus,
"context": "Run Test Harness",
"description": markFunctionalTestsDescription
});
});
Loading

0 comments on commit 16dc223

Please sign in to comment.