-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (92 loc) · 3.82 KB
/
Copy pathrelease.yml
File metadata and controls
112 lines (92 loc) · 3.82 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: Release
on:
push:
branches:
- main
- develop
workflow_dispatch:
permissions:
contents: write
packages: write
id-token: write
jobs:
publish-latest:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: "1.3.14"
- run: bun install --frozen-lockfile
- run: bun run build
# The version bump (package.json + CHANGELOG.md) already landed on main
# via a release/x.x.x pull request (see the make-release skill), so this
# job only needs to publish that version if it hasn't been already.
- name: Check if this version is already published
id: check
run: |
pkg_name=$(node -p "require('./package.json').name")
pkg_version=$(node -p "require('./package.json').version")
echo "pkg_name=$pkg_name" >> "$GITHUB_OUTPUT"
echo "pkg_version=$pkg_version" >> "$GITHUB_OUTPUT"
if npm view "$pkg_name@$pkg_version" version --registry https://registry.npmjs.org >/dev/null 2>&1; then
echo "already_published=true" >> "$GITHUB_OUTPUT"
else
echo "already_published=false" >> "$GITHUB_OUTPUT"
fi
- name: Publish to GitHub Packages
if: steps.check.outputs.already_published == 'false'
run: bun publish --registry https://npm.pkg.github.com --tag latest --tolerate-republish
env:
NPM_CONFIG_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# bun publish does not support npm's OIDC "Trusted Publishing" yet
# (oven-sh/bun#22423, #24855), so the npm registry step uses the npm CLI instead.
- uses: actions/setup-node@v4
if: steps.check.outputs.already_published == 'false'
with:
node-version: "22"
- name: Publish to npm
if: steps.check.outputs.already_published == 'false'
run: |
npm install -g npm@latest
npm publish --registry https://registry.npmjs.org --tag latest --access public
- name: Tag and create GitHub Release
if: steps.check.outputs.already_published == 'false'
run: |
version="${{ steps.check.outputs.pkg_version }}"
git tag "v$version"
git push origin "v$version"
awk '/^## /{n++} n==1' CHANGELOG.md > /tmp/release-notes.md
gh release create "v$version" --title "v$version" --notes-file /tmp/release-notes.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-next:
if: github.ref == 'refs/heads/develop'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: "1.3.14"
- run: bun install --frozen-lockfile
- run: bun run build
- run: bunx changeset version --snapshot "next-$(git rev-parse --short HEAD)" --snapshot-prerelease-template "{tag}"
- run: bun publish --registry https://npm.pkg.github.com --tag next --tolerate-republish
env:
NPM_CONFIG_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# bun publish does not support npm's OIDC "Trusted Publishing" yet
# (oven-sh/bun#22423, #24855), so the npm registry step uses the npm CLI instead.
- uses: actions/setup-node@v4
with:
node-version: "22"
- run: npm install -g npm@latest
- name: Publish to npm
run: |
pkg_name=$(node -p "require('./package.json').name")
pkg_version=$(node -p "require('./package.json').version")
if npm view "$pkg_name@$pkg_version" version --registry https://registry.npmjs.org >/dev/null 2>&1; then
echo "$pkg_name@$pkg_version already published to npm, skipping"
else
npm publish --registry https://registry.npmjs.org --tag next --access public
fi