Repository navigation
102 lines (98 loc) 路 3.21 KB
/
Copy pathrelease.yml
File metadata and controls
102 lines (98 loc) 路 3.21 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
---
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Release
on:
push:
branches:
- main
workflow_dispatch:
permissions: {}
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
check-release:
name: Check for release tag
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
tag: ${{ steps.release.outputs.tag }}
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
fetch-depth: 0
persist-credentials: false
- name: Check release version
id: release
env:
EVENT_NAME: ${{ github.event_name }}
run: |
package_version="$(node -p "require('./package.json').version")"
tag="v$package_version"
if ! git show-ref --verify --quiet "refs/tags/$tag"; then
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
echo "Expected release tag $tag on the selected main commit" >&2
exit 1
fi
echo "No release tag $tag; skipping release"
exit 0
fi
if [[ "$(git rev-parse "$tag^{commit}")" != "$GITHUB_SHA" ]]; then
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
echo "Tag $tag does not point to the selected main commit" >&2
exit 1
fi
echo "Tag $tag does not point to this commit; skipping release"
exit 0
fi
echo "tag=$tag" >> "$GITHUB_OUTPUT"
release:
name: Stage npm package and create GitHub release
needs: check-release
if: needs.check-release.outputs.tag != ''
environment: protected branches
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
env:
RELEASE_TAG: ${{ needs.check-release.outputs.tag }}
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
- name: Setup pnpm
uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
with:
version: 9
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 24
registry-url: https://registry.npmjs.org
package-manager-cache: false
- name: Setup npm
run: npm install --global npm@11.15.0
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Check formatting
run: pnpm run format:check
- name: Build
run: pnpm run build
- name: Integration test
run: pnpm run test:integration
- name: Stage npm package
run: |
if [[ "$RELEASE_TAG" == *-* ]]; then
npm stage publish --provenance --access public --tag next
else
npm stage publish --provenance --access public
fi
- name: Create draft GitHub release
run: gh release create "$RELEASE_TAG" --draft --generate-notes --verify-tag
env:
GH_TOKEN: ${{ github.token }}