-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (66 loc) · 2.16 KB
/
publish.yml
File metadata and controls
79 lines (66 loc) · 2.16 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
name: Publish Package
on:
release:
types: [published]
workflow_dispatch:
inputs:
version_type:
description: "Version bump type"
required: true
default: "patch"
type: choice
options:
- patch
- minor
- major
jobs:
publish:
name: Publish package
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
- name: Setup Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: 22
cache: "pnpm"
- name: Install npm 11+ for OIDC provenance publishing
run: corepack enable npm && corepack install -g npm@latest
env:
COREPACK_ENABLE_STRICT: 0
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run unit tests
run: pnpm test:unit
- name: Build package
run: pnpm build
- name: Configure git (for version bump)
if: github.event_name == 'workflow_dispatch'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Bump version and create tag
if: github.event_name == 'workflow_dispatch'
id: version
run: |
pnpm version ${{ github.event.inputs.version_type }}
echo "new_version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
git push --follow-tags
- name: Publish to npm
run: npm publish --provenance
env:
COREPACK_ENABLE_STRICT: 0
- name: Create GitHub release (manual trigger only)
if: github.event_name == 'workflow_dispatch'
run: |
gh release create v${{ steps.version.outputs.new_version }} \
--title "Release v${{ steps.version.outputs.new_version }}" \
--generate-notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}