Skip to content

Commit 7cf3618

Browse files
authored
Merge pull request #44 from interscript/ci/oidc-release
ci: npm release via Trusted Publishing
2 parents 0a7928f + c9de396 commit 7cf3618

1 file changed

Lines changed: 38 additions & 9 deletions

File tree

.github/workflows/release.yml

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,57 @@
1-
name: release
1+
name: Release
22

33
on:
44
push:
55
tags:
66
- "v*"
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: "Version to release (e.g. 0.1.1)"
11+
required: true
12+
type: string
713

814
permissions:
9-
contents: read
10-
id-token: write # required for npm provenance
15+
id-token: write
16+
contents: write
1117

1218
jobs:
1319
publish:
1420
runs-on: ubuntu-latest
15-
environment: release
1621
steps:
1722
- uses: actions/checkout@v7
1823
- uses: actions/setup-node@v7
1924
with:
20-
node-version: "22"
21-
cache: npm
22-
registry-url: https://registry.npmjs.org
25+
node-version: "24"
26+
registry-url: "https://registry.npmjs.org"
2327
- run: npm ci
28+
- run: npm run lint
29+
- run: npm run format:check
2430
- run: npm run build
2531
- run: npm test
32+
- name: Set version from workflow input
33+
if: github.event_name == "workflow_dispatch"
34+
run: |
35+
current=$(node -p "require('./package.json').version")
36+
if [ "$current" != "${{ inputs.version }}" ]; then
37+
npm version ${{ inputs.version }} --no-git-tag-version
38+
fi
2639
- run: npm publish --provenance --access public
27-
env:
28-
NODE_AUTH_TOKEN: ${{ secrets.INTERSCRIPT_NPM_TOKEN }}
40+
41+
github-release:
42+
needs: publish
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v7
46+
- name: Determine version
47+
id: version
48+
run: |
49+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
50+
echo "tag=v${{ inputs.version }}" >> "$GITHUB_OUTPUT"
51+
else
52+
echo "tag=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
53+
fi
54+
- uses: softprops/action-gh-release@v3
55+
with:
56+
tag_name: ${{ steps.version.outputs.tag }}
57+
generate_release_notes: true

0 commit comments

Comments
 (0)