-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (49 loc) · 1.41 KB
/
release.yml
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
on:
push:
branches:
- main
paths:
- "package.json"
name: Create Release
jobs:
test:
uses: ./.github/workflows/ci.yml
build:
name: Create Release
runs-on: ubuntu-latest
needs: test
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
- name: Fetch tags
run: git fetch --prune --unshallow --tags
- name: Check if package version changed
id: check_version
run: |
version="v$(cat package.json | jq -r '.version')"
if [ $(git tag -l "$version") ]; then
echo "Tag $version already exists."
else
echo "version_tag=$version" >> "$GITHUB_OUTPUT"
fi
- uses: actions/setup-node@v4
if: steps.check_version.outputs.version_tag
with:
node-version-file: .nvmrc
cache: npm
registry-url: "https://registry.npmjs.org"
- name: Create GitHub release
if: steps.check_version.outputs.version_tag
run: |
gh release create ${{ steps.check_version.outputs.version_tag }} --generate-notes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to NPM
if: steps.check_version.outputs.version_tag
run: |
npm ci
npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}