|
| 1 | +# ============================================================================= |
| 2 | +# Release pipeline for zenbpm-java-client |
| 3 | +# |
| 4 | +# Automatically triggered when ZenBPM (pbinitiative/zenbpm) publishes a new |
| 5 | +# release. Copies the latest api.yaml from ZenBPM, bumps the project version |
| 6 | +# to match, builds, and deploys to the configured Maven repository. |
| 7 | +# |
| 8 | +# Requirements (set up in GitHub repo Settings → Secrets and variables → Actions): |
| 9 | +# Secret: ZENBPM_READ_TOKEN |
| 10 | +# A GitHub Personal Access Token (classic or fine-grained) with at least |
| 11 | +# "Contents: read" access to pbinitiative/zenbpm. Used to check out the |
| 12 | +# matching tag from the upstream ZenBPM repo. |
| 13 | +# |
| 14 | +# To trigger from ZenBPM's release workflow, add a step like: |
| 15 | +# - name: Trigger Java client release |
| 16 | +# uses: peter-evans/repository-dispatch@v3 |
| 17 | +# with: |
| 18 | +# token: ${{ secrets.ZENBPM_JAVA_CLIENT_ACCESS_TOKEN }} |
| 19 | +# repository: pbinitiative/zenbpm-java-client |
| 20 | +# event-type: release-upstream |
| 21 | +# client-payload: '{"version": "${{ github.ref_name }}"}' |
| 22 | +# ============================================================================= |
| 23 | + |
| 24 | +name: Release to Maven Repository |
| 25 | + |
| 26 | +on: |
| 27 | + # 1) Automated trigger from ZenBPM's own release workflow |
| 28 | + repository_dispatch: |
| 29 | + types: [release-upstream] |
| 30 | + |
| 31 | + # 2) Manual trigger for testing or ad-hoc releases |
| 32 | + workflow_dispatch: |
| 33 | + inputs: |
| 34 | + version: |
| 35 | + description: 'Release version to publish (e.g., v1.2.0)' |
| 36 | + required: true |
| 37 | + type: string |
| 38 | + |
| 39 | +permissions: |
| 40 | + contents: write # create GitHub Release + tag, push version bump commit |
| 41 | + packages: write # deploy to GitHub Packages |
| 42 | + |
| 43 | +env: |
| 44 | + JAVA_VERSION: '8' |
| 45 | + MAVEN_CLI_OPTS: '-B -ntp' |
| 46 | + |
| 47 | +jobs: |
| 48 | + release: |
| 49 | + runs-on: ubuntu-latest |
| 50 | + |
| 51 | + steps: |
| 52 | + # ── Version ----------------------------------------------------------- |
| 53 | + - name: Determine release version |
| 54 | + id: version |
| 55 | + run: | |
| 56 | + case "${{ github.event_name }}" in |
| 57 | + repository_dispatch) |
| 58 | + VERSION="${{ github.event.client_payload.version }}" |
| 59 | + ;; |
| 60 | + workflow_dispatch) |
| 61 | + VERSION="${{ github.event.inputs.version }}" |
| 62 | + ;; |
| 63 | + esac |
| 64 | +
|
| 65 | + # Validate format — expects "vX.Y.Z" or "vX.Y.Z-rcN" |
| 66 | + if ! echo "${VERSION}" | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+'; then |
| 67 | + echo "ERROR: version '${VERSION}' does not match vX.Y.Z format" |
| 68 | + exit 1 |
| 69 | + fi |
| 70 | +
|
| 71 | + echo "VERSION=${VERSION}" |
| 72 | + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" |
| 73 | + echo "version_no_v=${VERSION#v}" >> "$GITHUB_OUTPUT" |
| 74 | +
|
| 75 | + # ── Checkout sources -------------------------------------------------- |
| 76 | + - name: Checkout zenbpm-java-client |
| 77 | + uses: actions/checkout@v4 |
| 78 | + |
| 79 | + - name: Checkout ZenBPM at matching tag |
| 80 | + uses: actions/checkout@v4 |
| 81 | + with: |
| 82 | + repository: pbinitiative/zenbpm |
| 83 | + ref: ${{ steps.version.outputs.version }} |
| 84 | + token: ${{ secrets.ZENBPM_READ_TOKEN }} |
| 85 | + path: upstream/zenbpm |
| 86 | + |
| 87 | + # ── Copy api.yaml ----------------------------------------------------- |
| 88 | + - name: Copy api.yaml from ZenBPM |
| 89 | + run: | |
| 90 | + SRC="upstream/zenbpm/openapi/api.yaml" |
| 91 | + DST="zenbpm-client-core/src/main/resources/openapi/api.yaml" |
| 92 | +
|
| 93 | + if [ ! -f "$SRC" ]; then |
| 94 | + echo "ERROR: api.yaml not found at ${SRC}" |
| 95 | + exit 1 |
| 96 | + fi |
| 97 | +
|
| 98 | + cp -v "$SRC" "$DST" |
| 99 | + echo "Copied api.yaml ($(wc -l < "$DST") lines)" |
| 100 | +
|
| 101 | + # ── Java + Maven setup ------------------------------------------------ |
| 102 | + - name: Set up JDK ${{ env.JAVA_VERSION }} |
| 103 | + uses: actions/setup-java@v4 |
| 104 | + with: |
| 105 | + java-version: ${{ env.JAVA_VERSION }} |
| 106 | + distribution: temurin |
| 107 | + cache: maven |
| 108 | + # Server configuration for GitHub Packages deploy |
| 109 | + server-id: github |
| 110 | + server-username: MAVEN_USERNAME |
| 111 | + server-password: MAVEN_PASSWORD |
| 112 | + |
| 113 | + # ── Version bump ------------------------------------------------------ |
| 114 | + - name: Update project version to match ZenBPM release |
| 115 | + run: | |
| 116 | + mvn ${MAVEN_CLI_OPTS} \ |
| 117 | + versions:set \ |
| 118 | + -DnewVersion="${{ steps.version.outputs.version_no_v }}" \ |
| 119 | + -DgenerateBackupPoms=false |
| 120 | +
|
| 121 | + # ── Commit version bump ----------------------------------------------- |
| 122 | + - name: Commit and push version bump |
| 123 | + run: | |
| 124 | + git config user.name "github-actions[bot]" |
| 125 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 126 | + git add "**/pom.xml" zenbpm-client-core/src/main/resources/openapi/api.yaml |
| 127 | + git commit -m "chore: release ${{ steps.version.outputs.version }}" |
| 128 | + git push |
| 129 | +
|
| 130 | + # ── Build -------------------------------------------------------------- |
| 131 | + - name: Build & run tests |
| 132 | + run: mvn ${MAVEN_CLI_OPTS} clean verify |
| 133 | + |
| 134 | + # ── Deploy: GitHub Packages ------------------------------------------- |
| 135 | + - name: Deploy to GitHub Packages |
| 136 | + run: > |
| 137 | + mvn ${MAVEN_CLI_OPTS} deploy -DskipTests |
| 138 | + -DaltDeploymentRepository=github::https://maven.pkg.github.com/${{ github.repository }} |
| 139 | + env: |
| 140 | + MAVEN_USERNAME: ${{ github.actor }} |
| 141 | + MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }} |
| 142 | + |
| 143 | + # ── Deploy: Maven Central (optional) ---------------------------------- |
| 144 | + # Uncomment this section and add the following secrets to your repo: |
| 145 | + # MAVEN_CENTRAL_USERNAME, MAVEN_CENTRAL_PASSWORD, GPG_PRIVATE_KEY, GPG_PASSPHRASE |
| 146 | + # |
| 147 | + # Also add <distributionManagement> to your root pom.xml: |
| 148 | + # <distributionManagement> |
| 149 | + # <snapshotRepository><id>ossrh</id><url>...</url></snapshotRepository> |
| 150 | + # <repository><id>ossrh</id><url>...</url></repository> |
| 151 | + # </distributionManagement> |
| 152 | + # |
| 153 | + # - name: Deploy to Maven Central |
| 154 | + # run: mvn ${MAVEN_CLI_OPTS} deploy -Prelease |
| 155 | + # env: |
| 156 | + # MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} |
| 157 | + # MAVEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} |
| 158 | + |
| 159 | + # ── GitHub Release ---------------------------------------------------- |
| 160 | + - name: Create GitHub Release |
| 161 | + uses: softprops/action-gh-release@v2 |
| 162 | + with: |
| 163 | + tag_name: ${{ steps.version.outputs.version }} |
| 164 | + name: ${{ steps.version.outputs.version }} |
| 165 | + body: | |
| 166 | + ## ZenBPM Java Client ${{ steps.version.outputs.version }} |
| 167 | +
|
| 168 | + This release corresponds to ZenBPM [${{ steps.version.outputs.version }}](https://github.com/pbinitiative/zenbpm/releases/tag/${{ steps.version.outputs.version }}). |
| 169 | +
|
| 170 | + ### Changes |
| 171 | + - Updated api.yaml from ZenBPM ${{ steps.version.outputs.version }} |
| 172 | + - Generated updated REST client and DTOs |
| 173 | + - Published to GitHub Packages |
| 174 | + files: | |
| 175 | + zenbpm-client-core/target/*.jar |
| 176 | + zenbpm-spring-boot-starter/target/*.jar |
| 177 | + fail_on_unmatched_files: true |
0 commit comments