-
Notifications
You must be signed in to change notification settings - Fork 1
84 lines (69 loc) · 2.7 KB
/
publish.yml
File metadata and controls
84 lines (69 loc) · 2.7 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: "Publish"
on:
pull_request:
branches:
- main
types: [closed]
jobs:
publish_js:
name: "Create release for JS client"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./js
if: >-
${{ github.event.pull_request.merged == true && (
contains(github.event.pull_request.labels.*.name, 'patch') ||
contains(github.event.pull_request.labels.*.name, 'minor') ||
contains(github.event.pull_request.labels.*.name, 'major') ) }}
steps:
- name: Checkout the repository
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
token: ${{ secrets.RELEASE_PAT }}
fetch-depth: 0
- name: Setup git user
run: |
git config user.name "neetobot"
git config user.email "neetobot.github@neeto.com"
- name: Setup NodeJS LTS version
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
with:
node-version-file: ".nvmrc"
- name: Setup the project
run: yarn install
- name: Generate production build
run: yarn build
- name: Prefix version tag with "v"
run: yarn config set version-tag-prefix "v"
- name: Disable Git commit hooks
run: git config core.hooksPath /dev/null
- name: Bump the patch version and create git tag on release
if: ${{ contains(github.event.pull_request.labels.*.name, 'patch') }}
run: yarn version --patch
- name: Bump the minor version and create git tag on release
if: ${{ contains(github.event.pull_request.labels.*.name, 'minor') }}
run: yarn version --minor
- name: Bump the major version and create git tag on release
if: ${{ contains(github.event.pull_request.labels.*.name, 'major') }}
run: yarn version --major
- name: Get the package version from package.json
uses: tyankatsu0105/read-package-version-actions@v1
id: package-version
- name: Create a new version release commit
uses: EndBug/add-and-commit@290ea2c423ad77ca9c62ae0f5b224379612c0321 # v10
with:
message: "New version release"
push: false
- name: Rebase on latest main and push commit and tag
working-directory: ${{ github.workspace }}
run: |
VERSION=$(node -p "require('./js/package.json').version")
git fetch origin main
git rebase origin/main
git tag -f "v${VERSION}"
git push --atomic origin HEAD:main "refs/tags/v${VERSION}"
- name: Publish the package on NPM
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
npm publish