-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (59 loc) · 1.97 KB
/
Copy pathcreate-release.yml
File metadata and controls
70 lines (59 loc) · 1.97 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
name: Create Release
on:
workflow_dispatch:
push:
branches:
- 'main'
permissions:
contents: write
jobs:
release-npmjs:
runs-on: ubuntu-latest
environment: npm-publish
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- run: yarn install --frozen-lockfile
- name: Configure npm auth
shell: bash
run: |
npm config set registry https://registry.npmjs.org/
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
npm whoami
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- id: pkg
name: Read package version
shell: bash
run: |
VERSION=$(npm pkg get version | tr -d '"')
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- id: check_tag
name: Check if tag exists
shell: bash
run: |
if git ls-remote --tags origin "refs/tags/v${{ steps.pkg.outputs.version }}" | grep -q .; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- name: Create and push tag
if: steps.check_tag.outputs.exists == 'false'
shell: bash
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -a "v${{ steps.pkg.outputs.version }}" -m "Release v${{ steps.pkg.outputs.version }}"
git push origin "v${{ steps.pkg.outputs.version }}"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.pkg.outputs.version }}
name: v${{ steps.pkg.outputs.version }}
generate_release_notes: true