Repository navigation
83 lines (78 loc) · 3.41 KB
/
Copy pathrelease.yml
File metadata and controls
83 lines (78 loc) · 3.41 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
name: Release
on:
push:
branches: [main]
# Publishes to npm via OIDC Trusted Publishing (`id-token: write` + a
# per-package trusted-publisher config on npmjs.com — see docs/releasing.md;
# a publish E404 means that config is missing for the package). NPM_TOKEN is
# injected only as the fallback credential for packages without a trusted
# publisher yet.
permissions:
contents: write
pull-requests: write
id-token: write
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
runs-on: ubuntu-latest
steps:
# Full history + tags. `changeset tag` decides what to create by looking
# at which tags already exist, and the tag-push step below pushes real tag
# objects — both are unreliable from the default shallow, tagless clone.
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
# Matches the root package.json engines field (>=24). The bundled npm is
# used as-is: node 24 ships npm >= 11.6.2 (>= 11.5.1 is what OIDC +
# provenance needs), and upgrading to npm@latest on release day is how we
# hit npm/cli#9722 (12.0.0 shipped without its bundled sigstore).
- uses: actions/setup-node@v7
with:
node-version: 24
registry-url: https://registry.npmjs.org
- run: bun install --frozen-lockfile
- name: Create Release PR or publish
uses: changesets/action@v1
with:
# Opens/updates a "Version Packages" PR from pending changesets; when
# that PR is merged, publishes the bumped packages.
version: bun run version-packages
publish: bun run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: "true"
# changesets/action pushes tags only for packages it can parse out of the
# publish command's stdout, which it does by grepping for
# `New tag: <pkg>@<ver>`. We publish through scripts/publish.ts, because
# `changeset publish` cannot resolve bun `workspace:` ranges (see
# docs/releasing.md), and its log lines read
# `[publish] = @ingram-tech/nk-db@1.5.0 already on npm`. Nothing matches, so
# the action's own tag push is a silent no-op — `bun run release` ends with
# `changeset tag`, which creates every tag correctly inside the runner, where
# they then die with it. The 2026-08-18 release published seven packages and
# pushed zero tags this way.
#
# Pushing here rather than reshaping publish.ts's output keeps the tags from
# depending on an undocumented stdout format staying stable.
#
# Each tag is checked against origin and pushed individually: that makes this
# a no-op on runs that only opened the Version Packages PR (no publish, so no
# new tags), and stops one already-published tag from failing the whole push
# the way `git push --tags` would.
- name: Push release tags
run: |
pushed=0
for tag in $(git tag -l '@ingram-tech/*'); do
if git ls-remote --exit-code --tags origin "refs/tags/$tag" >/dev/null 2>&1
then
continue
fi
echo "pushing $tag"
git push origin "refs/tags/$tag"
pushed=$((pushed + 1))
done
echo "pushed $pushed tag(s)"