From 19de281d9f135b349617e44c48d49a871d16924d Mon Sep 17 00:00:00 2001 From: Ales Verbic Date: Fri, 26 Sep 2025 11:21:05 -0400 Subject: [PATCH] ci: add publish workflows Signed-off-by: Ales Verbic --- .github/workflows/publish.yml | 124 ++++++++++++++++++++++++++ .github/workflows/publish_private.yml | 87 ++++++++++++++++++ 2 files changed, 211 insertions(+) create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/publish_private.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..32787a0 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,124 @@ +on: + workflow_call: + inputs: + javaVersion: + description: "Java version to use" + default: "21" + type: string + mavenProperties: + description: "Maven properties to use" + default: "-DskipGithub=true" + type: string + mavenTasks: + description: "Maven tasks to use" + default: "clean install deploy" + type: string + branch: + description: "Branch to publish to" + default: "master" + type: string + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - name: Set up JDK ${{ inputs.javaVersion }} + uses: actions/setup-java@v5 + with: + java-version: "${{ inputs.javaVersion }}" + distribution: "temurin" + - name: Set up Maven + uses: hb0730/maven-action@v1.0.2 + with: + maven-version: 3.8.2 + - name: Create Maven settings.xml + run: | + cat << 'EOF' > $HOME/.m2/settings.xml + + + + s3.applause-public-repo + ${{ secrets.APPLAUSE_REPO_USER_NAME }} + ${{ secrets.APPLAUSE_REPO_PASSWORD }} + + + s3.applause-public-snapshots + ${{ secrets.APPLAUSE_REPO_USER_NAME }} + ${{ secrets.APPLAUSE_REPO_PASSWORD }} + + + + + + + + true + + + + + applause-public-repo + Repository for Applause public artifacts (releases) + https://repo.applause.com/repository/public + true + false + + + applause-public-snapshots + Repository for Applause public artifacts (snapshots) + https://repo.applause.com/repository/snapshots + false + true + + + + + applause-public-repo + Repository for Applause public artifacts (releases) + https://repo.applause.com/repository/public + true + false + + + + + + EOF + + - name: Publish + run: | + # Parse our version using build-helper and versions to strip SNAPSHOT + mvn build-helper:parse-version versions:set -DgenerateBackupPoms=false -DnewVersion=\\${parsedVersion.majorVersion}.\\${parsedVersion.minorVersion}.\\${parsedVersion.incrementalVersion} + + # Write the current version + mvn help:evaluate -q -Dexpression=project.version -DforceStdout=true | tail -n 1 | tee VERSION + + mvn ${{ inputs.mavenProperties }} ${{ inputs.mavenTasks }} + + VERSION=`cat VERSION` + + # Remove the org from the repo name + GITHUB_REPO_NAME=${GITHUB_REPOSITORY#*/} + + git config --global --add safe.directory `pwd -P` + git commit -am "GHA: release version \${VERSION}" + git tag v\${VERSION} -am "GHA: publish public-$GITHUB_REPO_NAME v\${VERSION}" + git log -1 + # git push origin v\${VERSION} + # git push origin HEAD:${{ inputs.branch }} + + # Increment incremental version and set SNAPSHOT + mvn build-helper:parse-version versions:set -DgenerateBackupPoms=false -DnewVersion=\\${parsedVersion.majorVersion}.\\${parsedVersion.minorVersion}.\\${parsedVersion.nextIncrementalVersion}-SNAPSHOT + + # Write the SNAPSHOT version to VERSION + mvn help:evaluate -q -Dexpression=project.version -DforceStdout=true | tail -n 1 | tee VERSION + + # Looks good! Now, for the git-fu for our SNAPSHOT version + VERSION=`cat VERSION` + git commit -am "GHA: SNAPSHOT version \${VERSION}" + git diff HEAD^ HEAD + # git push origin HEAD:${{ inputs.branch }} diff --git a/.github/workflows/publish_private.yml b/.github/workflows/publish_private.yml new file mode 100644 index 0000000..b01ec52 --- /dev/null +++ b/.github/workflows/publish_private.yml @@ -0,0 +1,87 @@ +name: Maven Publish Private + +on: + workflow_call: + inputs: + javaVersion: + description: "Java version to use" + default: "21" + type: string + mavenProperties: + description: "Maven properties to use" + default: "-DskipGithub=true" + type: string + mavenTasks: + description: "Maven tasks to use" + default: "clean install deploy" + type: string + +jobs: + build-and-publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - name: Set up JDK ${{ inputs.javaVersion }} + uses: actions/setup-java@v5 + with: + java-version: "${{ inputs.javaVersion }}" + distribution: "temurin" + - name: Set up Maven + uses: hb0730/maven-action@v1.0.2 + with: + maven-version: 3.8.9 + + - name: Create Maven settings.xml + run: | + cat << 'EOF' > $HOME/.m2/settings.xml + + + + s3.applause-private-repo + ${{ secrets.APPLAUSE_REPO_USER_NAME }} + ${{ secrets.APPLAUSE_REPO_PASSWORD }} + + + + + + + true + + + + + applause-repo + Repository for Applause private artifacts + https://repo.applause.com/repository/private + true + true + + + applause-public-repo + Repository for Applause public artifacts (releases) + https://repo.applause.com/repository/public + true + false + + + + + applause-public-repo + Repository for Applause public artifacts (releases) + https://repo.applause.com/repository/public + true + false + + + + + + EOF + + - name: Publish + run: | + mvn ${{ inputs.mavenProperties }} ${{ inputs.mavenTasks }}