-
Notifications
You must be signed in to change notification settings - Fork 7
110 lines (92 loc) · 2.83 KB
/
release.yml
File metadata and controls
110 lines (92 loc) · 2.83 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
# Based on https://github.com/directus/eslint-config/blob/main/.github/workflows/release.yml
# Version must already be bumped in package.json via a PR before running this workflow
name: Release
on:
workflow_dispatch: {}
jobs:
validate:
name: Validate
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
outputs:
version: ${{ steps.version.outputs.release }}
is-prerelease: ${{ steps.version.outputs.prerelease && true || false }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup env
uses: ./.github/actions/setup
- name: Read version from package.json
id: pkg-version
run: echo "version=$(node -p 'require("./package.json").version')" >> "$GITHUB_OUTPUT"
- name: Check version
uses: madhead/semver-utils@v4
id: version
with:
version: ${{ steps.pkg-version.outputs.version }}
lenient: false
- name: Build
run: pnpm run build
create-tag:
name: Create Tag
needs: validate
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Create tag
run: |
version='v${{ needs.validate.outputs.version }}'
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git tag --annotate "$version" --message "$version"
git push origin "refs/tags/${version}"
create-release:
name: Create Release
needs:
- validate
- create-tag
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create \
'v${{ needs.validate.outputs.version }}' \
--verify-tag \
--generate-notes \
${{ needs.validate.outputs.is-prerelease == 'true' && '--prerelease' || '' }}
publish-npm:
name: Publish to NPM
needs:
- validate
- create-tag
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: refs/tags/v${{ needs.validate.outputs.version }}
- name: Setup env
uses: ./.github/actions/setup
with:
registry: https://registry.npmjs.org
- name: Build
run: pnpm run build
- name: Publish
env:
NPM_CONFIG_PROVENANCE: true
run: |
pnpm publish \
--access=public \
--no-git-checks \
--tag ${{ needs.validate.outputs.is-prerelease == 'true' && 'canary' || 'latest' }}