-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (87 loc) · 3.63 KB
/
Copy pathpublish-rubygems.yml
File metadata and controls
100 lines (87 loc) · 3.63 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Publish rouge-ddot to RubyGems
# Triggers:
# - Push a tag matching `rubygems-v*` (e.g. `rubygems-v0.2.0`).
# - Manual `workflow_dispatch` from the Actions tab.
#
# Distinct tag prefix keeps Ruby releases out of the npm and PyPI
# workflows' tag namespaces.
on:
push:
tags: ['rubygems-v*']
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # required for OIDC trusted publishing
env:
# rubygems/configure-rubygems-credentials@v2.0.0 is still on Node 20,
# which GH Actions deprecates on 2026-06-02. Force Node 24 to silence
# the runner's deprecation warning until the action ships a Node 24
# release. Drop this env var once that happens.
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
defaults:
run:
working-directory: ddot.it-syntax-tools
steps:
# Sibling checkouts — `tools/conformance-rouge.rb` reads inputs and
# goldens from ../ddot.it/test-data/cases/.
- name: Checkout ddot.it-syntax-tools
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
path: ddot.it-syntax-tools
- name: Checkout ddot.it (test-data corpus)
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
repository: Calpano/ddot.it
path: ddot.it
- uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
with:
ruby-version: '3.3'
- name: Install rouge runtime dep
run: gem install rouge
# Gate: don't publish if the canonical-token corpus disagrees with
# the lexer's output.
- name: Conformance — Rouge
run: ruby tools/conformance-rouge.rb
# Exchange the GitHub OIDC token for a short-lived RubyGems API
# key and write it to ~/.gem/credentials so subsequent `gem push`
# picks it up. Requires the rouge-ddot gem on RubyGems to have
# Calpano/ddot.it-syntax-tools + this workflow file configured as
# a trusted publisher.
- uses: rubygems/configure-rubygems-credentials@dc5a8d8553e6ee01fc26761a49e99e733d17954a # v2.1.0
# Build the gem, compare local vs RubyGems version, push only if
# newer. No GEM_HOST_API_KEY env — credentials come from the OIDC
# exchange above.
- name: Build & publish if newer
run: |
set -e
cd rouge
local_v=$(ruby -e "puts Gem::Specification.load('rouge-ddot.gemspec').version")
registry_v=$(curl -fsS https://rubygems.org/api/v1/gems/rouge-ddot.json 2>/dev/null | python3 -c "import sys, json; print(json.load(sys.stdin)['version'])" 2>/dev/null || echo "0.0.0")
echo "local: $local_v, registry: $registry_v"
if [ "$local_v" != "$registry_v" ]; then
echo "::group::Building gem"
rm -f *.gem
gem build rouge-ddot.gemspec
ls -la *.gem
echo "::endgroup::"
echo "::group::Pushing to RubyGems"
gem push "rouge-ddot-${local_v}.gem"
echo "::endgroup::"
{
echo "## RubyGems publish summary"
echo
echo "**Published:** rouge-ddot@$local_v"
echo
echo "https://rubygems.org/gems/rouge-ddot/versions/$local_v"
} >> "$GITHUB_STEP_SUMMARY"
else
echo "rouge-ddot@$local_v already on RubyGems — skipping"
{
echo "## RubyGems publish summary"
echo
echo "**Skipped:** rouge-ddot@$local_v already on RubyGems"
} >> "$GITHUB_STEP_SUMMARY"
fi