-
Notifications
You must be signed in to change notification settings - Fork 6
62 lines (53 loc) · 1.63 KB
/
release.yaml
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
name: Version 🔖
on:
push:
branches:
- main
paths:
- "package.json"
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
runs-on: ubuntu-latest
environment: release
permissions:
contents: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get version from package.json
id: package_version
run: echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Check if tag exists
id: check_tag
run: |
git fetch --tags
if git rev-parse "v${{ steps.package_version.outputs.VERSION }}" >/dev/null 2>&1; then
echo "::set-output name=EXISTS::true"
fi
- name: Create Release
if: steps.check_tag.outputs.EXISTS != 'true'
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.package_version.outputs.VERSION }}
name: Release v${{ steps.package_version.outputs.VERSION }}
draft: false
prerelease: false
generate_release_notes: true
make_latest: true
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"
- name: Publish to NPM
if: steps.check_tag.outputs.EXISTS != 'true'
run: |
npm install -g npm@^9.5.0
npm ci
npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}