-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (74 loc) · 2.41 KB
/
main.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
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
on:
push:
branches:
- main
paths:
- package.json
concurrency:
group: main
jobs:
check-conditions:
runs-on: ubuntu-latest
outputs:
isNewVersion: ${{ steps.check-tag.outputs.exists == 'false' && steps.package-version.outputs.tag != 'v0.0.0' }}
npmTokenAvailable: ${{ steps.npm.outputs.available }}
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Get the package version tag
id: package-version
run: echo "tag=v$(jq -r '.version' package.json)" >> $GITHUB_OUTPUT
- name: Check if tag exists
uses: mukunku/[email protected]
id: check-tag
with:
tag: ${{ steps.package-version.outputs.tag }}
- name: Check if NPM token secret is available
id: npm
run: echo "available=${{ secrets.NPM_TOKEN != '' }}" >> $GITHUB_OUTPUT
release:
runs-on: ubuntu-latest
permissions: write-all
needs: check-conditions
if: needs.check-conditions.outputs.isNewVersion == 'true'
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Create a new version tag
uses: Klemensas/action-autotag@stable
id: tag
with:
tag_prefix: v
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create the changelog
uses: heinrichreimer/[email protected]
id: changelog
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Extract the release notes
uses: actions-ecosystem/action-regex-match@v2
id: releasenotes
with:
text: ${{ steps.changelog.outputs.changelog }}
regex: ^(\n|.)*?(##(.+)\n\n((\n|.)*?))(\n)+(##(\n|.)*)?(\n)+\\\*(.+)$
- name: Create a new GitHub release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag.outputs.tagname }}
body: ${{ steps.releasenotes.outputs.group4 }}
artifacts: release-artifacts/*
deploy-npm:
runs-on: ubuntu-latest
permissions: write-all
needs:
- release
- check-conditions
if: needs.check-conditions.outputs.npmTokenAvailable == 'true'
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Publish to NPM
uses: JS-DevTools/npm-publish@v3
with:
access: public
token: ${{ secrets.NPM_TOKEN }}