Repository navigation
173 lines (167 loc) · 6.05 KB
/
Copy pathrelease.yml
File metadata and controls
173 lines (167 loc) · 6.05 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# Regenerate from the public Crossly OpenAPI specs and release, with signed build provenance.
#
# Daily, on dispatch, or on a crossly-spec-updated repository_dispatch: if the specs changed since the last
# release, generate, build, test, write the CHANGELOG entry and version (codegen/ci/next-version.mjs), commit
# and tag with this repository's own GITHUB_TOKEN, then publish. Publishing uses OIDC trusted publishing where the
# registry supports it, so no registry token is stored here.
#
# Dispatched on any other branch it is a DRY RUN: it always regenerates, builds and tests, uploads the artifacts,
# and never commits, tags or publishes.
#
# Managed by tools/sdk-repo/seed.mjs in the Crossly monorepo: edits here are overwritten on the next seed.
name: release
on:
schedule:
- cron: '23 7 * * *'
workflow_dispatch:
inputs:
force:
description: Regenerate and release even when the specs are unchanged
type: boolean
default: false
repository_dispatch:
types: [crossly-spec-updated]
concurrency:
group: release
cancel-in-progress: false
permissions:
contents: read
jobs:
detect:
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
changed: ${{ steps.specs.outputs.changed }}
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: '22'
- id: specs
env:
FORCE: ${{ (inputs.force || github.ref != 'refs/heads/main') && 'true' || 'false' }}
run: node codegen/ci/fetch-specs.mjs
regen:
needs: detect
if: needs.detect.outputs.changed == 'true'
runs-on: ubuntu-latest
timeout-minutes: 90
permissions:
contents: write
outputs:
tag: ${{ steps.version.outputs.tag }}
env:
CROSSLY_SPEC_DIR: codegen/specs
# Every compile check so far was made against 5.4.0 output (it runs on Java 8).
OPENAPI_GENERATOR_VERSION: '5.4.0'
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: '22'
# Generator runtime. Zulu, because Temurin has no Java 8 for Apple silicon.
- uses: actions/setup-java@v6
with:
distribution: zulu
java-version: '8'
- uses: actions/cache@v6
with:
path: codegen/.tools
key: openapi-generator-${{ env.OPENAPI_GENERATOR_VERSION }}
- name: fetch specs
env:
FORCE: 'true'
run: node codegen/ci/fetch-specs.mjs
- name: version and changelog
id: version
run: node codegen/ci/next-version.mjs
- name: generate
env:
CROSSLY_SDK_VERSION: ${{ steps.version.outputs.version }}
run: node codegen/scripts/generate-sdks.mjs --lang ruby
- name: assemble and scan
run: node codegen/ci/assemble.mjs
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
- name: build seller
run: bash codegen/ci/check.sh ruby seller
- name: build buyer
run: bash codegen/ci/check.sh ruby buyer
- name: webhook conformance vectors
working-directory: codegen/integrations/webhooks/ruby
run: ruby check_vectors.rb
- name: package
run: |
mkdir -p dist
for d in seller buyer; do
spec=$(cd "$d" && ls *.gemspec | head -1)
sed -i -E \
-e 's|^( *s\.license *= *).*|\1"MIT"|' \
-e 's|^( *s\.authors *= *).*|\1["Crossly"]|' \
-e 's|^( *s\.homepage *= *).*|\1"https://github.com/crossly-dev/crossly-ruby"|' \
"$d/$spec"
(cd "$d" && gem build "$spec" && mv ./*.gem ../dist/)
done
ls -l dist
# Once assembled (assemble.mjs vendors them), every gem must ship the verifier and the client.
if [ -f seller/lib/crossly_kit.rb ]; then
for g in dist/*.gem; do
for f in lib/crossly_webhooks.rb lib/crossly_kit.rb; do
gem spec "$g" files | grep -q "$f" || { echo "::error::$g does not ship $f"; exit 1; }
done
done
fi
- name: commit and tag
if: github.ref == 'refs/heads/main'
env:
TAG: ${{ steps.version.outputs.tag }}
run: |
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add -A seller buyer webhooks CHANGELOG.md codegen/state.json codegen/index
git commit -q -m "$TAG: regenerate from the Crossly API" -m "$(head -c 4000 codegen/release-notes.md)"
git tag -a "$TAG" -m "$TAG"
git push origin HEAD:main
git push origin "$TAG"
- uses: actions/upload-artifact@v7
with:
name: release
path: |
dist/
codegen/release-notes.md
retention-days: 30
publish:
needs: regen
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
timeout-minutes: 20
environment: release
permissions:
contents: write
id-token: write
attestations: write
steps:
- uses: actions/download-artifact@v8
with:
name: release
# Signed SLSA build provenance for every artifact: gh attestation verify <file> --repo crossly-dev/crossly-ruby
- uses: actions/attest-build-provenance@v4
with:
subject-path: 'dist/*'
- name: set up Ruby (RubyGems)
if: vars.PUBLISH_RUBYGEMS == 'true'
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
- name: RubyGems credentials (trusted publishing)
if: vars.PUBLISH_RUBYGEMS == 'true'
uses: rubygems/configure-rubygems-credentials@v1.0.0
- name: publish to RubyGems
if: vars.PUBLISH_RUBYGEMS == 'true'
run: for g in dist/*.gem; do gem push "$g"; done
- name: GitHub Release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ needs.regen.outputs.tag }}
run: gh release create "$TAG" dist/* --repo "$GITHUB_REPOSITORY" --title "$TAG" --notes-file codegen/release-notes.md --verify-tag