Repository navigation
153 lines (147 loc) · 5.25 KB
/
Copy pathrelease.yml
File metadata and controls
153 lines (147 loc) · 5.25 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
# 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 python
- name: assemble and scan
run: node codegen/ci/assemble.mjs
- uses: actions/setup-python@v7
with:
python-version: '3.12'
- name: build seller
run: bash codegen/ci/check.sh python seller
- name: build buyer
run: bash codegen/ci/check.sh python buyer
- name: webhook conformance vectors
working-directory: codegen/integrations/webhooks/python
run: python check_vectors.py && python -m pip install -q flask django fastapi httpx && python ../../extras/python/selftest.py
- name: package
run: |
python -m pip install -q build twine
python -m build seller --outdir dist
python -m build buyer --outdir dist
python -m twine check --strict dist/*
- 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-python
- uses: actions/attest-build-provenance@v4
with:
subject-path: 'dist/*'
- name: publish to PyPI
if: vars.PUBLISH_PYPI == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
password: ${{ secrets.PYPI_API_TOKEN }}
- 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