-
Notifications
You must be signed in to change notification settings - Fork 90
60 lines (51 loc) · 1.81 KB
/
Copy pathrelease.yml
File metadata and controls
60 lines (51 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Publish the RubyTree gem to RubyGems.org on a release tag.
#
# Uses RubyGems trusted publishing (OIDC) instead of a stored API key, so
# there is no long-lived RubyGems credential held by this repository or by
# any maintainer's machine for automated releases.
#
# A Trusted Publisher must be configured for the `rubytree` gem at
# rubygems.org (Manage Gem > Trusted Publishers), pointing at this
# repository and this workflow file name.
#
# Tag push triggers cannot be scoped to a branch directly (a tag ref has no
# branch of its own), so a release tag pushed from anywhere still fires this
# workflow. The "Verify tag is reachable from master" step guards against
# that: it fails the job before anything is published if the tagged commit
# is not on master, so an accidental release tag on another branch is
# harmless.
#
# This runs as a Github Action.
name: Release to RubyGems
on:
push:
tags:
- "R*"
permissions:
contents: read
id-token: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Clone Repository
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Verify tag is reachable from master
run: |
if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/master; then
echo "::error::Tag $GITHUB_REF_NAME (commit $GITHUB_SHA) is not on master. Refusing to publish."
exit 1
fi
- name: Setup Ruby and bundler dependencies
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: ".ruby-version"
- name: Configure RubyGems trusted-publishing credentials
uses: rubygems/configure-rubygems-credentials@main
- name: Build gem package
run: bundle exec rake gem:package
- name: Push to RubyGems.org
run: gem push pkg/*.gem