Repository navigation
102 lines (96 loc) · 3.58 KB
/
Copy pathrelease.yml
File metadata and controls
102 lines (96 loc) · 3.58 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
name: Release alpha
env:
HUSKY: 0
on:
workflow_dispatch:
inputs:
version:
description: Alpha version already committed in package.json (without v)
required: true
type: string
permissions:
contents: read
concurrency:
group: session-kit-release
cancel-in-progress: false
jobs:
prepare:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Require main
env:
RELEASE_REF: ${{ github.ref }}
run: test "$RELEASE_REF" = refs/heads/main
- name: Check out release commit
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up pnpm
uses: pnpm/action-setup@v6
with:
version: 10.12.1
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version: 24
package-manager-cache: false
- name: Validate version and release notes
env:
RELEASE_VERSION: ${{ inputs.version }}
run: |
node scripts/prepare-release.mjs "$RELEASE_VERSION" "$RUNNER_TEMP/release" --check-registry
if git show-ref --verify --quiet "refs/tags/v$RELEASE_VERSION"; then
echo "The release tag already exists."
exit 1
fi
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build and test
run: pnpm run check
- name: Pack verified build
run: pnpm --config.ignore-scripts=true pack --pack-destination "$RUNNER_TEMP/release"
- name: Save release artifact
uses: actions/upload-artifact@v7
with:
name: session-kit-release
path: ${{ runner.temp }}/release/
if-no-files-found: error
retention-days: 14
publish:
needs: prepare
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
id-token: write
steps:
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version: 24
package-manager-cache: false
- name: Download verified release artifact
uses: actions/download-artifact@v8
with:
name: session-kit-release
path: ${{ runner.temp }}/release
- name: Check npm supports trusted publishing
run: |
node --input-type=module -e 'import { execFileSync } from "node:child_process"; const [major, minor, patch] = execFileSync("npm", ["--version"], { encoding: "utf8" }).trim().split(".").map(Number); if (!(major > 11 || (major === 11 && (minor > 5 || (minor === 5 && patch >= 1))))) throw new Error("npm >=11.5.1 is required");'
- name: Publish alpha to npm
env:
RELEASE_VERSION: ${{ inputs.version }}
run: npm publish "$RUNNER_TEMP/release/monarcode-session-kit-$RELEASE_VERSION.tgz" --tag latest --access public --ignore-scripts
- name: Create GitHub prerelease and tag
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
RELEASE_VERSION: ${{ inputs.version }}
RELEASE_COMMIT: ${{ github.sha }}
run: |
gh release create "v$RELEASE_VERSION" \
--target "$RELEASE_COMMIT" \
--title "v$RELEASE_VERSION" \
--prerelease --latest=false \
--notes-file "$RUNNER_TEMP/release/release-notes.md"