|
| 1 | +name: Build with '-Prelease' (Run) |
| 2 | + |
| 3 | +# Workflow_run job for release profile build verification. |
| 4 | +# This workflow has access to secrets and runs the actual build. |
| 5 | +# Triggered by build-with-release-profile.yml completion. |
| 6 | +# See: https://securitylab.github.com/research/github-actions-preventing-pwn-requests |
| 7 | + |
| 8 | +on: |
| 9 | + workflow_run: |
| 10 | + workflows: ["Build with '-Prelease' (Trigger)"] |
| 11 | + types: |
| 12 | + - completed |
| 13 | + |
| 14 | +permissions: {} |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + # Only run for successful trigger workflow from main repository |
| 19 | + if: > |
| 20 | + ${{ github.event.workflow_run.conclusion == 'success' && |
| 21 | + github.event.workflow_run.repository.full_name == 'a2aproject/a2a-java' }} |
| 22 | + runs-on: ubuntu-latest |
| 23 | + permissions: |
| 24 | + contents: read |
| 25 | + actions: read # Required to download artifacts |
| 26 | + |
| 27 | + steps: |
| 28 | + - name: Download PR info |
| 29 | + uses: actions/download-artifact@v4 |
| 30 | + with: |
| 31 | + name: pr-info |
| 32 | + github-token: ${{ github.token }} |
| 33 | + run-id: ${{ github.event.workflow_run.id }} |
| 34 | + |
| 35 | + - name: Extract PR info |
| 36 | + id: pr_info |
| 37 | + run: | |
| 38 | + if [ -f pr_number ]; then |
| 39 | + PR_NUMBER=$(cat pr_number) |
| 40 | + echo "pr_number=${PR_NUMBER}" >> $GITHUB_OUTPUT |
| 41 | + echo "PR Number: ${PR_NUMBER}" |
| 42 | + else |
| 43 | + echo "No PR number (push event)" |
| 44 | + fi |
| 45 | +
|
| 46 | + PR_SHA=$(cat pr_sha) |
| 47 | + echo "pr_sha=${PR_SHA}" >> $GITHUB_OUTPUT |
| 48 | + echo "PR SHA: ${PR_SHA}" |
| 49 | +
|
| 50 | + PR_REF=$(cat pr_ref) |
| 51 | + echo "pr_ref=${PR_REF}" >> $GITHUB_OUTPUT |
| 52 | + echo "PR Ref: ${PR_REF}" |
| 53 | +
|
| 54 | + - name: Checkout PR code |
| 55 | + uses: actions/checkout@v4 |
| 56 | + with: |
| 57 | + # Checkout the exact commit from the PR (or push) |
| 58 | + # This is safe because the workflow code (this file) is always from main |
| 59 | + ref: ${{ steps.pr_info.outputs.pr_sha }} |
| 60 | + |
| 61 | + - name: Set up JDK 17 |
| 62 | + uses: actions/setup-java@v4 |
| 63 | + with: |
| 64 | + java-version: '17' |
| 65 | + distribution: 'temurin' |
| 66 | + cache: maven |
| 67 | + |
| 68 | + # Use secrets to import GPG key |
| 69 | + - name: Import GPG key |
| 70 | + uses: crazy-max/ghaction-import-gpg@v6 |
| 71 | + with: |
| 72 | + gpg_private_key: ${{ secrets.GPG_SIGNING_KEY }} |
| 73 | + passphrase: ${{ secrets.GPG_SIGNING_PASSPHRASE }} |
| 74 | + |
| 75 | + # Create settings.xml for Maven since it needs the 'central-a2asdk-temp' server. |
| 76 | + # Populate with username and password from secrets |
| 77 | + - name: Create settings.xml |
| 78 | + run: | |
| 79 | + mkdir -p ~/.m2 |
| 80 | + echo "<settings><servers><server><id>central-a2asdk-temp</id><username>${{ secrets.CENTRAL_TOKEN_USERNAME }}</username><password>${{ secrets.CENTRAL_TOKEN_PASSWORD }}</password></server></servers></settings>" > ~/.m2/settings.xml |
| 81 | +
|
| 82 | + # Build with the same settings as the deploy job |
| 83 | + # -s uses the settings file we created. |
| 84 | + - name: Build with same arguments as deploy job |
| 85 | + run: > |
| 86 | + mvn -B install |
| 87 | + -s ~/.m2/settings.xml |
| 88 | + -P release |
| 89 | + -DskipTests |
| 90 | + -Drelease.auto.publish=true |
| 91 | + env: |
| 92 | + # GPG passphrase is set as an environment variable for the gpg plugin to use |
| 93 | + GPG_PASSPHRASE: ${{ secrets.GPG_SIGNING_PASSPHRASE }} |
| 94 | + |
| 95 | + - name: Build Summary |
| 96 | + if: always() |
| 97 | + run: | |
| 98 | + if [ "${{ job.status }}" = "success" ]; then |
| 99 | + echo "✅ Release profile build succeeded" |
| 100 | + if [ -n "${{ steps.pr_info.outputs.pr_number }}" ]; then |
| 101 | + echo " PR #${{ steps.pr_info.outputs.pr_number }} is ready for release" |
| 102 | + fi |
| 103 | + else |
| 104 | + echo "❌ Release profile build failed" |
| 105 | + if [ -n "${{ steps.pr_info.outputs.pr_number }}" ]; then |
| 106 | + echo " PR #${{ steps.pr_info.outputs.pr_number }} has release profile issues" |
| 107 | + fi |
| 108 | + fi |
0 commit comments