11name : vscode-lean4 build
22
33on :
4+ workflow_dispatch :
5+ inputs :
6+ action :
7+ description : ' Action to perform'
8+ required : true
9+ type : choice
10+ options :
11+ - publish-packages
12+ - release
13+ - pre-release
414 pull_request :
515 branches :
616 - ' *'
@@ -16,6 +26,7 @@ permissions:
1626
1727jobs :
1828 build-and-test :
29+ if : github.event_name != 'workflow_dispatch'
1930 strategy :
2031 fail-fast : false
2132 matrix :
@@ -189,3 +200,105 @@ jobs:
189200 uses : GabrielBB/xvfb-action@v1.0
190201 with :
191202 run : npm run test
203+
204+ publish-packages :
205+ if : github.event_name == 'workflow_dispatch' && inputs.action == 'publish-packages'
206+ runs-on : ubuntu-latest
207+ steps :
208+ - name : Checkout
209+ uses : actions/checkout@v2
210+
211+ - name : Setup Node.js
212+ uses : actions/setup-node@v4
213+ with :
214+ node-version : ' 24'
215+ registry-url : ' https://registry.npmjs.org'
216+
217+ - name : Build
218+ run : |
219+ npm ci
220+ npm run build
221+
222+ - name : Try publishing infoview-api
223+ continue-on-error : true
224+ run : npm publish --workspace=lean4-infoview-api --access=public
225+
226+ - name : Try publishing infoview
227+ continue-on-error : true
228+ run : npm publish --workspace=lean4-infoview --access=public
229+
230+ - name : Try publishing unicode-input
231+ continue-on-error : true
232+ run : npm publish --workspace=lean4-unicode-input --access=public
233+
234+ - name : Try publishing unicode-input-component
235+ continue-on-error : true
236+ run : npm publish --workspace=lean4-unicode-input-component --access=public
237+
238+ release :
239+ if : github.event_name == 'workflow_dispatch' && inputs.action == 'release'
240+ runs-on : ubuntu-latest
241+ steps :
242+ - name : Checkout
243+ uses : actions/checkout@v2
244+ with :
245+ fetch-depth : 0
246+
247+ - name : Compute next version
248+ id : version
249+ run : |
250+ last_tag="$(git tag --sort=-v:refname --list 'v*' --no-contains | head -1)"
251+ echo "Last tag: $last_tag"
252+ last_version="${last_tag#v}"
253+ last_version="${last_version%-pre}"
254+ new_version="$(echo "$last_version" | awk -F. '{$NF=$NF+1; print}' OFS=.)"
255+ echo "New version: $new_version"
256+ echo "new_version=$new_version" >> "$GITHUB_OUTPUT"
257+
258+ - name : Update version and create tag
259+ run : |
260+ new_version="${{ steps.version.outputs.new_version }}"
261+ sed -i 's/"version": ".*"/"version": "'$new_version'"/' vscode-lean4/package.json
262+ git config user.name "github-actions[bot]"
263+ git config user.email "github-actions[bot]@users.noreply.github.com"
264+ git commit -am "Release $new_version"
265+ git tag -a "v$new_version" -m "vscode-lean4 $new_version"
266+
267+ - name : Push
268+ run : |
269+ git push
270+ git push --tags
271+
272+ pre-release :
273+ if : github.event_name == 'workflow_dispatch' && inputs.action == 'pre-release'
274+ runs-on : ubuntu-latest
275+ steps :
276+ - name : Checkout
277+ uses : actions/checkout@v2
278+ with :
279+ fetch-depth : 0
280+
281+ - name : Compute next version
282+ id : version
283+ run : |
284+ last_tag="$(git tag --sort=-v:refname --list 'v*' --no-contains | head -1)"
285+ echo "Last tag: $last_tag"
286+ last_version="${last_tag#v}"
287+ last_version="${last_version%-pre}"
288+ new_version="$(echo "$last_version" | awk -F. '{$NF=$NF+1; print}' OFS=.)"
289+ echo "New version: $new_version"
290+ echo "new_version=$new_version" >> "$GITHUB_OUTPUT"
291+
292+ - name : Update version and create tag
293+ run : |
294+ new_version="${{ steps.version.outputs.new_version }}"
295+ sed -i 's/"version": ".*"/"version": "'$new_version'"/' vscode-lean4/package.json
296+ git config user.name "github-actions[bot]"
297+ git config user.email "github-actions[bot]@users.noreply.github.com"
298+ git commit -am "Release $new_version (pre-release)"
299+ git tag -a "v$new_version-pre" -m "vscode-lean4 $new_version (pre-release)"
300+
301+ - name : Push
302+ run : |
303+ git push
304+ git push --tags
0 commit comments