-
Notifications
You must be signed in to change notification settings - Fork 4
76 lines (65 loc) · 2.42 KB
/
release-npm.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
name: Publish package to npmjs
on:
pull_request:
types: [ closed ]
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Git Config
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<>"
- name: Detect version bump type
id: bump-type
run: |
BUMP_TYPE=null
if [[ $BUMP_PATCH_PRESENT == 'true' ]]; then
BUMP_TYPE=patch
fi
if [[ $BUMP_MINOR_PRESENT == 'true' ]]; then
BUMP_TYPE=minor
fi
if [[ $BUMP_MAJOR_PRESENT == 'true' ]]; then
BUMP_TYPE=major
fi
echo "::set-output name=bump-type::$BUMP_TYPE"
env:
BUMP_PATCH_PRESENT: ${{ contains(github.event.pull_request.labels.*.name, 'bump patch') }}
BUMP_MINOR_PRESENT: ${{ contains(github.event.pull_request.labels.*.name, 'bump minor') }}
BUMP_MAJOR_PRESENT: ${{ contains(github.event.pull_request.labels.*.name, 'bump major') }}
- name: Get current version
id: package-version
if: steps.bump-type.outputs.bump-type != 'null'
uses: martinbeentjes/npm-get-version-action@master
- name: Determine new version
id: new-version
if: steps.bump-type.outputs.bump-type != 'null'
run: |
NEW_VERSION=$(npx semver ${{ steps.package-version.outputs.current-version }} -i ${{ steps.bump-type.outputs.bump-type }})
echo "New version: $NEW_VERSION"
echo "::set-output name=new-version::$NEW_VERSION"
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- name: Bump package version
if: steps.bump-type.outputs.bump-type != 'null'
run: |
npm version ${{ steps.new-version.outputs.new-version }}
git push origin HEAD:${{ github.event.pull_request.base.ref }}
- name: Install deps
if: steps.bump-type.outputs.bump-type != 'null'
run: yarn install --frozen-lockfile
- name: Build package
run: yarn build
if: steps.bump-type.outputs.bump-type != 'null'
- name: Publish to NPM
run: yarn publish
if: steps.bump-type.outputs.bump-type != 'null'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}