From 4da45daed8201a2079be78c50e10d59e3dff599c Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Wed, 2 Dec 2026 16:48:01 -0500 Subject: [PATCH] Add libprism source files to release publishing --- .github/workflows/build-artifacts.yml | 23 +++++++++++++++++++++-- .github/workflows/publish-gem.yml | 19 +++++++++++++------ docs/releasing.md | 3 ++- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-artifacts.yml b/.github/workflows/build-artifacts.yml index 5c28bff94e..3cbee35395 100644 --- a/.github/workflows/build-artifacts.yml +++ b/.github/workflows/build-artifacts.yml @@ -8,6 +8,12 @@ on: release: types: [created] workflow_dispatch: + workflow_call: + inputs: + version_tag: + description: "Version tag to package" + required: true + type: string jobs: build: @@ -15,6 +21,9 @@ jobs: steps: - uses: actions/checkout@v7 + with: + ref: ${{ inputs.version_tag || github.ref }} + persist-credentials: false - name: Set up Ruby uses: ruby/setup-ruby@v1 @@ -22,7 +31,7 @@ jobs: ruby-version: ruby bundler-cache: true - - name: Build library + - name: Generate templates run: bundle exec rake templates - name: Package libprism source @@ -31,7 +40,17 @@ jobs: cp -r src build/libprism-src/src cp -r include build/libprism-src/include cp Makefile build/libprism-src/Makefile - tar -czf build/libprism-src.tar.gz -C build libprism-src + # Keep the tarball checksum stable when a release is rebuilt. + tar --sort=name --mtime="@$(git log -1 --format=%ct)" --owner=0 --group=0 --numeric-owner \ + -czf build/libprism-src.tar.gz -C build libprism-src + + - uses: actions/upload-artifact@v7 + if: inputs.version_tag + with: + name: release-${{ inputs.version_tag }}-libprism-src + path: build/libprism-src.tar.gz + if-no-files-found: error + retention-days: 1 - name: Upload to release if: github.event_name == 'release' diff --git a/.github/workflows/publish-gem.yml b/.github/workflows/publish-gem.yml index ed4d521e39..fec74e34e9 100644 --- a/.github/workflows/publish-gem.yml +++ b/.github/workflows/publish-gem.yml @@ -18,23 +18,28 @@ permissions: contents: read jobs: - build: + build_gems: uses: ./.github/workflows/build-gems.yml with: release: true artifact_prefix: "release-${{ inputs.version_tag || github.ref_name }}-" ref: ${{ inputs.version_tag || github.ref }} + build_libprism: + uses: ./.github/workflows/build-artifacts.yml + with: + version_tag: ${{ inputs.version_tag || github.ref_name }} + push: name: "Push gems and create GitHub release" - needs: build + needs: [build_gems, build_libprism] if: github.repository == 'ruby/prism' runs-on: ubuntu-latest environment: name: rubygems.org url: https://rubygems.org/gems/prism permissions: - contents: write # create/update GitHub releases and upload .gem assets + contents: write # create/update GitHub releases and upload assets id-token: write # OIDC token for rubygems.org trusted publishing steps: - name: Harden Runner @@ -60,9 +65,10 @@ jobs: merge-multiple: true - name: Print and record checksums + shell: bash run: | cd gems - sha256sum ./*.gem | tee CHECKSUMS.txt + sha256sum ./*.gem ./libprism-src.tar.gz | tee CHECKSUMS.txt - uses: rubygems/configure-rubygems-credentials@v2.2.0 @@ -80,8 +86,9 @@ jobs: TAG: ${{ inputs.version_tag || github.ref_name }} REPO: ${{ github.repository }} run: | + assets=(gems/*.gem gems/libprism-src.tar.gz gems/CHECKSUMS.txt) if gh release view "$TAG" --repo "$REPO" >/dev/null 2>&1 ; then - gh release upload "$TAG" --repo "$REPO" --clobber gems/*.gem gems/CHECKSUMS.txt + gh release upload "$TAG" --repo "$REPO" --clobber "${assets[@]}" else - gh release create "$TAG" --repo "$REPO" --title "$TAG" --generate-notes gems/*.gem gems/CHECKSUMS.txt + gh release create "$TAG" --repo "$REPO" --title "$TAG" --generate-notes "${assets[@]}" fi diff --git a/docs/releasing.md b/docs/releasing.md index d8d32922e0..c95e4759c0 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -79,8 +79,9 @@ git push The [`publish-gem.yml`](../.github/workflows/publish-gem.yml) workflow handles publishing. It triggers either on a `v*` tag push or via manual `workflow_dispatch`. In both cases it: - Builds the source gem and all native gems (calling the reusable [`build-gems.yml`](../.github/workflows/build-gems.yml) workflow with `--release`). +- Generates the C sources and headers, then packages `src/`, `include/`, and the Makefile as `libprism-src.tar.gz`. - Pushes every gem to RubyGems.org using OIDC trusted publishing (no API key required). -- Creates (or updates) a GitHub release for the tag, attaches the `.gem` files and a `CHECKSUMS.txt`, and auto-generates release notes. +- Creates (or updates) a GitHub release for the tag, attaches the gems, source tarball, and their SHA-256 checksums in `CHECKSUMS.txt`, and auto-generates release notes. The `push` job is gated on `github.repository == 'ruby/prism'` and runs in the `rubygems.org` GitHub environment, which is the trust anchor for OIDC publishing to RubyGems.org. Pushes that already exist on RubyGems.org are reported as warnings rather than failing the run, so re-runs after a partial failure are safe.