@@ -2,13 +2,17 @@ name: Automatic Release Creation
2
2
3
3
on :
4
4
workflow_dispatch :
5
+ schedule :
6
+ - cron : ' 0 10 * * *'
5
7
6
8
jobs :
7
9
create-metadata :
8
10
runs-on : ubuntu-latest
9
11
outputs :
10
12
hash : ${{ steps.last-release.outputs.hash }}
11
13
version : ${{ steps.create-version.outputs.version}}
14
+ npm_packages : ${{ steps.create-npm-packages.outputs.npm_packages}}
15
+ pypi_packages : ${{ steps.create-pypi-packages.outputs.pypi_packages}}
12
16
steps :
13
17
- uses : actions/checkout@v4
14
18
with :
43
47
name : release-notes
44
48
path : RELEASE_NOTES.md
45
49
50
+ - name : Create python matrix
51
+ id : create-pypi-packages
52
+ run : |
53
+ HASH="${{ steps.last-release.outputs.hash }}"
54
+ PYPI=$(uv run --script scripts/release.py generate-matrix --pypi --directory src $HASH)
55
+ echo "pypi_packages $PYPI"
56
+ echo "pypi_packages=$PYPI" >> $GITHUB_OUTPUT
57
+
58
+ - name : Create npm matrix
59
+ id : create-npm-packages
60
+ run : |
61
+ HASH="${{ steps.last-release.outputs.hash }}"
62
+ NPM=$(uv run --script scripts/release.py generate-matrix --npm --directory src $HASH)
63
+ echo "npm_packages $NPM"
64
+ echo "npm_packages=$NPM" >> $GITHUB_OUTPUT
65
+
46
66
update-packages :
47
67
needs : [create-metadata]
68
+ if : ${{ needs.create-metadata.outputs.npm_packages != '[]' || needs.create-metadata.outputs.pypi_packages != '[]' }}
48
69
runs-on : ubuntu-latest
49
70
outputs :
50
71
changes_made : ${{ steps.commit.outputs.changes_made }}
@@ -80,8 +101,94 @@ jobs:
80
101
echo "changes_made=true" >> $GITHUB_OUTPUT
81
102
fi
82
103
83
- create-release :
104
+ publish-pypi :
105
+ needs : [update-packages, create-metadata]
106
+ strategy :
107
+ fail-fast : false
108
+ matrix :
109
+ package : ${{ fromJson(needs.create-metadata.outputs.pypi_packages) }}
110
+ name : Build ${{ matrix.package }}
111
+ environment : release
112
+ permissions :
113
+ id-token : write # Required for trusted publishing
114
+ runs-on : ubuntu-latest
115
+ steps :
116
+ - uses : actions/checkout@v4
117
+ with :
118
+ ref : ${{ needs.create-metadata.outputs.version }}
119
+
120
+ - name : Install uv
121
+ uses : astral-sh/setup-uv@v5
122
+
123
+ - name : Set up Python
124
+ uses : actions/setup-python@v5
125
+ with :
126
+ python-version-file : " src/${{ matrix.package }}/.python-version"
127
+
128
+ - name : Install dependencies
129
+ working-directory : src/${{ matrix.package }}
130
+ run : uv sync --frozen --all-extras --dev
131
+
132
+ - name : Run pyright
133
+ working-directory : src/${{ matrix.package }}
134
+ run : uv run --frozen pyright
135
+
136
+ - name : Build package
137
+ working-directory : src/${{ matrix.package }}
138
+ run : uv build
139
+
140
+ - name : Publish package to PyPI
141
+ uses : pypa/gh-action-pypi-publish@release/v1
142
+ with :
143
+ packages-dir : src/${{ matrix.package }}/dist
144
+
145
+ publish-npm :
84
146
needs : [update-packages, create-metadata]
147
+ strategy :
148
+ fail-fast : false
149
+ matrix :
150
+ package : ${{ fromJson(needs.create-metadata.outputs.npm_packages) }}
151
+ name : Build ${{ matrix.package }}
152
+ environment : release
153
+ runs-on : ubuntu-latest
154
+ steps :
155
+ - uses : actions/checkout@v4
156
+ with :
157
+ ref : ${{ needs.create-metadata.outputs.version }}
158
+
159
+ - uses : actions/setup-node@v4
160
+ with :
161
+ node-version : 22
162
+ cache : npm
163
+ registry-url : ' https://registry.npmjs.org'
164
+
165
+ - name : Install dependencies
166
+ working-directory : src/${{ matrix.package }}
167
+ run : npm ci
168
+
169
+ - name : Check if version exists on npm
170
+ working-directory : src/${{ matrix.package }}
171
+ run : |
172
+ VERSION=$(jq -r .version package.json)
173
+ if npm view --json | jq --arg version "$VERSION" '[.[]][0].versions | contains([$version])'; then
174
+ echo "Version $VERSION already exists on npm"
175
+ exit 1
176
+ fi
177
+ echo "Version $VERSION is new, proceeding with publish"
178
+
179
+ - name : Build package
180
+ working-directory : src/${{ matrix.package }}
181
+ run : npm run build
182
+
183
+ - name : Publish package
184
+ working-directory : src/${{ matrix.package }}
185
+ run : |
186
+ npm publish --access public
187
+ env :
188
+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
189
+
190
+ create-release :
191
+ needs : [update-packages, create-metadata, publish-pypi, publish-npm]
85
192
if : needs.update-packages.outputs.changes_made == 'true'
86
193
runs-on : ubuntu-latest
87
194
environment : release
97
204
98
205
- name : Create release
99
206
env :
100
- GH_TOKEN : ${{ secrets.RELEASE_TOKEN }}
207
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
101
208
run : |
102
209
VERSION="${{ needs.create-metadata.outputs.version }}"
103
210
gh release create "$VERSION" \
0 commit comments