-
Notifications
You must be signed in to change notification settings - Fork 3
102 lines (90 loc) · 2.96 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
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
# This will increase package.json version, create tags and release
name: Release
on:
pull_request:
types:
- closed
paths-ignore:
- '../../test'
- '../ISSUE_TEMPLATE'
- '../workflows'
permissions:
contents: write
pull-requests: read
jobs:
if_merged:
name: Merge to main branch
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- run: |
echo The PR was merged
if_norelease_label_then_stop:
name: No release if label 'norelease'
needs: if_merged
if: ${{ !contains(github.event.pull_request.labels.*.name, 'norelease') }}
runs-on: ubuntu-latest
steps:
- run: |
echo The PR can continue to tags, release creation
# This will create automatic tags based on the last 50 comits and it will create latest release
release:
name: 'Create: tags and release'
runs-on: ubuntu-latest
needs: [if_merged, if_norelease_label_then_stop]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: 'Save version to .env'
env:
IS_PATCH_FOUND: ${{ contains(github.event.pull_request.labels.*.name, 'patch') }}
IS_MINOR_FOUND: ${{ contains(github.event.pull_request.labels.*.name, 'minor') }}
IS_MAJOR_FOUND: ${{ contains(github.event.pull_request.labels.*.name, 'major') }}
IS_NO_RELEASE_FOUND: ${{ contains(github.event.pull_request.labels.*.name, 'norelease') }}
run: |
if [ "${IS_MINOR_FOUND}" == "true" ]; then
echo "version=minor" >> $GITHUB_ENV
echo "Version: minor"
elif [ "${IS_PATCH_FOUND}" == "true" ]; then
echo "version=patch" >> $GITHUB_ENV
echo "Version: patch"
elif [ "${IS_MAJOR_FOUND}" == "true" ]; then
echo "version=major" >> $GITHUB_ENV
echo "Version: major"
else
echo "version=norelease" >> $GITHUB_ENV
echo "Version: norelease"
fi
- uses: rymndhng/release-on-push-action@v0.28.0
with:
bump_version_scheme: ${{ env.version }}
release_name: 'Release <RELEASE_VERSION>'
tag_prefix: 'v'
# This will start build of the project
build:
name: 'Start: build'
runs-on: ubuntu-latest
needs: release
steps:
- uses: actions/checkout@v4
- run: npm install
- run: npm run build
# This will push the latest build of the project to npm
publish-npm:
name: 'Publish: npm public'
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm run build
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}