Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions .github/workflows/build-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,30 @@ on:
release:
types: [created]
workflow_dispatch:
workflow_call:
inputs:
version_tag:
description: "Version tag to package"
required: true
type: string

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v7
with:
ref: ${{ inputs.version_tag || github.ref }}
persist-credentials: false

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ruby
bundler-cache: true

- name: Build library
- name: Generate templates
run: bundle exec rake templates

- name: Package libprism source
Expand All @@ -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'
Expand Down
19 changes: 13 additions & 6 deletions .github/workflows/publish-gem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
3 changes: 2 additions & 1 deletion docs/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Loading