-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (105 loc) · 3.4 KB
/
release.yml
File metadata and controls
120 lines (105 loc) · 3.4 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
name: Manual Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g. 0.5.0)'
required: true
type: string
npm_token:
description: 'npm publish token'
required: true
type: string
dry_run:
description: 'Run without publishing'
required: false
type: boolean
default: false
permissions: {}
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Verify main branch
run: |
if [ "${{ github.ref }}" != "refs/heads/main" ]; then
echo "Error: Releases can only be created from the main branch"
exit 1
fi
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
cache-dependency-path: apps/web/package-lock.json
- name: Install dependencies
working-directory: apps/web
run: npm ci
- name: Typecheck
working-directory: apps/web
run: npm run typecheck
- name: Lint
working-directory: apps/web
run: npm run lint
- name: Test
working-directory: apps/web
run: npm run test
- name: Build
working-directory: apps/web
run: npm run build
- name: Create tag and GitHub Release
if: ${{ !inputs.dry_run }}
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: |
const tag = 'v${{ inputs.version }}';
// Create tag only if it doesn't already exist
try {
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${tag}`,
sha: context.sha
});
console.log(`Created tag: ${tag}`);
} catch (e) {
if (e.status === 422) {
console.log(`Tag ${tag} already exists, skipping tag creation`);
} else {
throw e;
}
}
// Create or update the GitHub release
try {
const { data: release } = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: tag,
name: tag,
generate_release_notes: true,
});
console.log(`Created release: ${release.html_url}`);
} catch (e) {
if (e.status === 422) {
console.log(`Release for ${tag} already exists, skipping`);
} else {
throw e;
}
}
- name: Publish to npm
if: ${{ !inputs.dry_run }}
working-directory: apps/web
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ inputs.npm_token }}
- name: Dry run summary
if: ${{ inputs.dry_run }}
run: echo "Dry run complete — quality gates passed. Would release v${{ inputs.version }}"