-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (49 loc) · 1.75 KB
/
main.yml
File metadata and controls
61 lines (49 loc) · 1.75 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
name: Release
on:
push:
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Dependencies
run: npm ci
- name: Create .npmrc
run: |
cat << EOF > "$HOME/.npmrc"
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# There is possibly a better way to do this.
# One problem this has is it will still publish snapshots when it's a documentation/pipeline only change
# But maybe that's a good thing, an abundance of caution that a configuration change isn't breaking something.
# Also, rather than inspecting the output of the changeset version command, we could use `npx changeset status --output=summary.json` and inspect that.
- name: Publish Snapshot
run: |
OUTPUT=$(npx changeset version --snapshot ${COMMIT_SHA::8} 2>&1)
echo "$OUTPUT"
if echo "$OUTPUT" | grep -q "No unreleased changesets found, exiting"; then
echo "No unreleased changesets found. Skipping snapshot publish."
exit 0
fi
npx changeset publish --tag prerelease
git checkout -- .
env:
COMMIT_SHA: ${{ github.sha }}
- name: Create Release Pull Request
id: changesets
uses: changesets/action@v1
with:
publish: npm run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}