-
Notifications
You must be signed in to change notification settings - Fork 121
70 lines (61 loc) · 2.31 KB
/
npm-release.yml
File metadata and controls
70 lines (61 loc) · 2.31 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
name: Release new NPM version
on:
pull_request:
types: [closed]
branches:
- main
concurrency:
group: changeset-${{ github.head_ref }}
cancel-in-progress: true
jobs:
npm:
name: Changeset release
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true && !contains(github.event.pull_request.title, '[ROLLBACK]') && !contains(github.event.pull_request.title, '[DOCS]')
permissions:
contents: write # to be able to publish a GitHub release
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
steps:
- name: Checkout the repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 1
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: "18.20"
- name: Install dependencies
run: yarn install --no-progress --ignore-engines
- name: Check for changesets
id: check_changesets
run: |
if [ -z "$(ls -A .changeset)" ]; then
echo "No changesets found. Exiting."
echo "changesets_found=false" >> $GITHUB_ENV
exit 0
else
echo "changesets_found=true" >> $GITHUB_ENV
fi
- name: Update package version and remove changesets
if: env.changesets_found == 'true'
run: npx changeset version
- name: Publish to NPM
if: env.changesets_found == 'true'
id: changesets
uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3
with:
publish: npx changeset publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true
- name: Update package.json version and reset changesets
if: env.changesets_found == 'true'
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add package.json .changeset
git commit -m "Update package version & delete changesets"
git push