-
Notifications
You must be signed in to change notification settings - Fork 0
225 lines (208 loc) · 7.71 KB
/
package-release.yaml
File metadata and controls
225 lines (208 loc) · 7.71 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
name: Package Release
on:
workflow_dispatch:
inputs:
package-path:
description: "Path to the package directory"
required: true
type: string
package-name:
description: "Name of the package"
required: true
type: string
version:
description: "Version to release"
required: true
type: string
checkout-ref:
description: "Git ref to checkout"
required: true
type: string
run-if-changed-only:
description: "Run only if this package has changed"
required: false
type: boolean
default: false
release-dry-run:
description: "Whether to run the release in dry-run mode"
required: false
type: boolean
default: false
debug-enabled:
description: "Enable tmate debug session"
required: false
type: boolean
default: false
build-images:
description: "Whether to build container images after release"
required: false
type: boolean
default: false
images-to-build:
description: "JSON array of images to build"
required: false
type: string
default: "[]"
workflow_call:
inputs:
package-path:
description: "Path to the package directory"
required: true
type: string
package-name:
description: "Name of the package"
required: true
type: string
version:
description: "Version to release"
required: true
type: string
checkout-ref:
description: "Git ref to checkout"
required: true
type: string
run-if-changed-only:
description: "Run only if this package has changed"
required: false
type: string
default: "false"
release-dry-run:
description: "Whether to run the release in dry-run mode"
required: false
type: string
default: "false"
debug-enabled:
description: "Enable tmate debug session"
required: false
type: boolean
default: false
build-images:
description: "Whether to build container images after release"
required: false
type: string
default: "false"
images-to-build:
description: "JSON array of images to build"
required: false
type: string
default: "[]"
outputs:
artifact-name:
description: "Name of the uploaded artifact"
value: ${{ jobs.release.outputs.artifact-name }}
version:
description: "Released version"
value: ${{ jobs.release.outputs.version }}
released:
description: "Whether a new release was published"
value: ${{ jobs.release.outputs.released }}
tag:
description: "Git tag created for the release"
value: ${{ jobs.release.outputs.tag }}
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
outputs:
artifact-name: ${{ steps.set-outputs.outputs.artifact-name }}
version: ${{ steps.semantic-release.outputs.new_release_version || inputs.version }}
released: ${{ steps.semantic-release.outputs.new_release_published || 'false' }}
tag: ${{ steps.semantic-release.outputs.new_release_git_tag }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
ref: ${{ inputs.checkout-ref }}
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@f94ec6bedd8674c4426838e6b50417d36b6ab231 # ratchet:astral-sh/setup-uv@v5
with:
python-version: "3.12"
enable-cache: true
cache-dependency-glob: "uv.lock"
version: "0.6.8"
- name: Setup Yarn
uses: threeal/setup-yarn-action@ec8c075e62bc497968de40011c2b766f5e8f1ac5 # ratchet:threeal/setup-yarn-action@v2.0.0
with:
version: "4.6.0"
cache: true
- name: Install npm dependencies
if: ${{ inputs.release-dry-run == 'true' }}
run: |
yarn workspace ${{ inputs.package-name }} install
git log --oneline --branches --tags
- name: Test semantic-release
if: ${{ inputs.release-dry-run == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
unset GITHUB_ACTIONS
yarn workspace ${{ inputs.package-name }} test-release -b ${{ inputs.checkout-ref }}
- name: Run semantic-release
id: semantic-release
uses: cycjimmy/semantic-release-action@b1b432f13acb7768e0c8efdec416d363a57546f2 # ratchet:cycjimmy/semantic-release-action@v4
with:
working_directory: ${{ inputs.package-path }}
dry_run: ${{ inputs.release-dry-run == 'true' }}
semantic_version: 24
extra_plugins: |
@semantic-release/changelog
@semantic-release/git
semantic-release-major-tag
semantic-release-monorepo
conventional-changelog-conventionalcommits
ci: ${{ inputs.release-dry-run == 'false' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_ACTIONS: ${{ inputs.release-dry-run == 'false' }}
- name: Set outputs
id: set-outputs
run: |
ARTIFACT_NAME="${{ inputs.package-name }}-${{ github.run_id }}"
echo "artifact-name=$ARTIFACT_NAME" >> $GITHUB_OUTPUT
# Log release information
if [ "${{ steps.semantic-release.outputs.new_release_published }}" == "true" ]; then
echo "📦 Package ${{ inputs.package-name }} released version ${{ steps.semantic-release.outputs.new_release_version }}"
echo "🏷️ Tag: ${{ steps.semantic-release.outputs.new_release_git_tag }}"
else
echo "ℹ️ No release needed for ${{ inputs.package-name }}"
fi
- name: Build package
if: ${{ steps.semantic-release.outputs.new_release_published == 'true' || inputs.release-dry-run == 'true' }}
run: |
uv build --package ${{ inputs.package-name }}
- name: Setup tmate debug session
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48 # ratchet:mxschmitt/action-tmate@v3
if: ${{ inputs.debug-enabled }}
- name: Upload artifacts
if: ${{ steps.semantic-release.outputs.new_release_published == 'true' || inputs.release-dry-run == 'true' }}
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # ratchet:actions/upload-artifact@v4
with:
name: ${{ steps.set-outputs.outputs.artifact-name }}
path: dist
- name: Publish to PyPI
if: ${{ steps.semantic-release.outputs.new_release_published == 'true' && inputs.release-dry-run != 'true' }}
# uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # ratchet:pypa/gh-action-pypi-publish@release/v1
continue-on-error: true
run: uv publish
env:
UV_PUBLISH_TOKEN: ${{ secrets.UV_PUBLISH_TOKEN }}
# with:
# packages-dir: dist
- name: Minimize uv cache
run: uv cache prune --ci
if: always()
build-images:
needs: [release]
if: ${{ inputs.build-images == 'true' && needs.release.outputs.released == 'true' && inputs.release-dry-run != 'true' }}
uses: ./.github/workflows/build-nix-images.yaml
with:
debug_enabled: ${{ inputs.debug-enabled }}
version: ${{ needs.release.outputs.version }}
images: ${{ inputs.images-to-build }}
branch: ${{ inputs.checkout-ref }}
secrets: inherit