-
Notifications
You must be signed in to change notification settings - Fork 1
63 lines (52 loc) · 1.9 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
# Workflow for releasing package to npm registry
name: Release to NPM
on:
pull_request:
types:
- closed # Only run after PRs have been merged or closed
branches:
- main # Only run for PRs targeted against main branch
jobs:
release:
# Only run for pull requests that has been merged (not closed) and that doesn't have `skip-release` label
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'skip-release') == false
name: release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0 # fetch all commits so auto-changelog is correctly generating
token: ${{ secrets.BOT_ACCESS_TOKEN }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18.x
scope: '@lokalise'
always-auth: true
registry-url: 'https://registry.npmjs.org'
- name: Install Dependencies
run: npm install
- name: Build Package
run: npm run build
- name: Setup git config
run: |
git config --global user.email "[email protected]"
git config --global user.name "AUTO RELEASE"
# Apply proper semver according to github labels
- name: Major label detected
if: contains(github.event.pull_request.labels.*.name, 'major')
run: npm version major
- name: Minor label detected
if: contains(github.event.pull_request.labels.*.name, 'minor')
run: npm version minor
- name: Patch label detected
if: contains(github.event.pull_request.labels.*.name, 'patch')
run: npm version patch
- name: Git push
run: git push origin main && git push --tags
- name: Release Package
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish