diff --git a/.github/workflows/generate-verifiable-builds.yaml b/.github/workflows/generate-verifiable-builds.yaml index 5ce8e1be..ef5664e2 100644 --- a/.github/workflows/generate-verifiable-builds.yaml +++ b/.github/workflows/generate-verifiable-builds.yaml @@ -6,10 +6,14 @@ on: - production - develop -# Jobs commit the verifiable-build .so files back to the branch via -# EndBug/add-and-commit, so they need write access to repository contents. +# Builds run with a read-only token; only the commit job writes to the branch. permissions: - contents: write + contents: read + +# One run per branch at a time, so two runs never push builds to the same branch at once. +concurrency: + group: generate-verifiable-builds-${{ github.ref }} + cancel-in-progress: false env: HUSKY: 0 @@ -50,10 +54,37 @@ jobs: run: ./scripts/check-stack-frames.sh solana-verify build --library-name ${{ matrix.program }} --arch v3 -- --features production - name: Print artifact hash run: solana-verify get-executable-hash target/deploy/${{ matrix.program }}.so - - run: 'git pull --rebase' - - run: cp target/deploy/${{ matrix.program }}.so ./verifiable-builds - - name: Commit verifiable build back to mainline + - name: Upload verifiable build + uses: actions/upload-artifact@v4 + with: + name: verifiable-${{ matrix.program }} + path: target/deploy/${{ matrix.program }}.so + if-no-files-found: error + + commit: + name: commit-verifiable-builds + needs: generate-verifiable + # Runs when a build failed too, so the programs that did build are still committed. + if: ${{ !cancelled() }} + runs-on: ubuntu-24.04 + permissions: + contents: write + steps: + # Checks out the branch tip instead of the commit that was built, so the push still works when the branch has moved on. + - uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} + - name: Download verifiable builds + uses: actions/download-artifact@v4 + with: + pattern: verifiable-* + path: verifiable-builds + merge-multiple: true + # Downloaded artifacts lose the executable bit that the committed files carry. + - run: chmod 755 verifiable-builds/*.so + - name: Commit verifiable builds back to mainline uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 with: + add: verifiable-builds default_author: github_actions - message: 'Update ${{ matrix.program }} verifiable build' + message: 'Update verifiable builds'