-
Notifications
You must be signed in to change notification settings - Fork 2
190 lines (164 loc) · 5.83 KB
/
release.yml
File metadata and controls
190 lines (164 loc) · 5.83 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: Release
on:
push:
branches: [main]
workflow_dispatch:
inputs:
tag:
description: "Custom tag override (default: per-package tags via changesets)"
type: string
required: false
publish-npm:
description: Publish npm packages (oxa-types, @oxa/core, oxa)
type: boolean
default: true
publish-pypi:
description: Publish Python package (oxa-types)
type: boolean
default: true
publish-crates:
description: Publish Rust package (oxa-types)
type: boolean
default: true
create-release:
description: Create GitHub Release
type: boolean
default: true
dry-run:
description: Dry run (skip actual publishing)
type: boolean
default: false
force-publish:
description: Force publish (skip version checks, for initial release)
type: boolean
default: false
concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions:
contents: write
pull-requests: write
id-token: write # Required for npm provenance and trusted publishing
jobs:
release:
name: Release
runs-on: ubuntu-latest
outputs:
published: ${{ steps.changesets.outputs.published }}
published-packages: ${{ steps.changesets.outputs.publishedPackages }}
types-version: ${{ steps.get-versions.outputs.types-version }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 24
cache: pnpm
registry-url: "https://registry.npmjs.org"
- uses: astral-sh/setup-uv@v5
- uses: dtolnay/rust-toolchain@stable
- run: pnpm install --frozen-lockfile
- name: Create Release PR or Publish npm
id: changesets
uses: changesets/action@v1
with:
version: pnpm run version
# Use changeset publish to only publish packages that were actually bumped
publish: ${{ (inputs.dry-run == true || inputs.publish-npm == false) && 'echo Skipping npm publish' || 'pnpm run release' }}
createGithubReleases: ${{ inputs.create-release != false }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get published types version
id: get-versions
if: steps.changesets.outputs.published == 'true'
run: |
# Read version after changesets has bumped it
TYPES_VERSION=$(jq -r '.version' packages/oxa-types-ts/package.json)
echo "types-version=$TYPES_VERSION" >> $GITHUB_OUTPUT
publish-pypi:
name: Publish to PyPI
needs: release
if: |
always() &&
inputs.publish-pypi != false &&
(inputs.force-publish == true ||
(needs.release.outputs.published == 'true' &&
contains(needs.release.outputs.published-packages, 'oxa-types')))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
- name: Build Python package
working-directory: packages/oxa-types-py
run: uv build
- name: Publish to PyPI
if: ${{ inputs.dry-run != true }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: packages/oxa-types-py/dist/
- name: Dry run - show what would be published
if: ${{ inputs.dry-run == true }}
run: |
echo "Dry run - would publish:"
ls -la packages/oxa-types-py/dist/
publish-crates:
name: Publish to crates.io
needs: release
if: |
always() &&
inputs.publish-crates != false &&
(inputs.force-publish == true ||
(needs.release.outputs.published == 'true' &&
contains(needs.release.outputs.published-packages, 'oxa-types')))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Authenticate with crates.io
id: crates-auth
if: ${{ inputs.dry-run != true }}
uses: rust-lang/crates-io-auth-action@v1
- name: Publish to crates.io
if: ${{ inputs.dry-run != true }}
working-directory: packages/oxa-types-rs
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ steps.crates-auth.outputs.token }}
- name: Dry run - check package
if: ${{ inputs.dry-run == true }}
working-directory: packages/oxa-types-rs
run: cargo publish --dry-run
create-schema-tag:
name: Create schema tag
needs: [release, publish-pypi, publish-crates]
if: |
always() &&
(inputs.force-publish == true ||
(needs.release.outputs.published == 'true' &&
contains(needs.release.outputs.published-packages, 'oxa-types'))) &&
(needs.publish-pypi.result == 'success' || needs.publish-pypi.result == 'skipped') &&
(needs.publish-crates.result == 'success' || needs.publish-crates.result == 'skipped')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get version
id: version
run: |
VERSION=$(jq -r '.version' packages/oxa-types-ts/package.json)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Create and push schema tag
if: ${{ inputs.dry-run != true }}
run: |
VERSION="${{ steps.version.outputs.version }}"
TAG="schema@${VERSION}"
# Check if tag already exists
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists, skipping"
else
git tag "$TAG"
git push origin "$TAG"
echo "Created and pushed tag: $TAG"
fi
- name: Dry run - show what tag would be created
if: ${{ inputs.dry-run == true }}
run: |
VERSION="${{ steps.version.outputs.version }}"
echo "Dry run - would create tag: schema@${VERSION}"