-
Notifications
You must be signed in to change notification settings - Fork 11
89 lines (77 loc) · 2.86 KB
/
Copy pathrelease.yml
File metadata and controls
89 lines (77 loc) · 2.86 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
name: Release
on:
push:
branches: [main]
permissions:
contents: write
id-token: write
pull-requests: write
concurrency:
group: changesets-release-${{ github.ref }}
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Check out the repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
with:
node-version: "24"
package-manager-cache: false
registry-url: https://registry.npmjs.org
- name: Install dependencies
run: npm ci
- name: Update npm for trusted publishing
run: npm install --global npm@latest
- name: Validate, build, typecheck, and test
run: npm run check
- name: Lint the package
run: npx --yes publint@0.3.24
- name: Pack and smoke-test the executable
shell: bash
run: |
package_root=$(mktemp -d)
install_root=$(mktemp -d)
npm pack --pack-destination "$package_root"
package_files=("$package_root"/*.tgz)
test -f "${package_files[0]}"
test "${#package_files[@]}" -eq 1
npm install --global --prefix "$install_root" "${package_files[0]}"
"$install_root/bin/gbot" --help
"$install_root/bin/grok-bot" --help
"$install_root/bin/gbot-install" --help
- name: Create release pull request or publish
id: changesets
uses: changesets/action@ae32849d5ba541f9ae29e40e22a623bc13562f51 # v2.1.2
with:
pr-base-branch: main
commit-message: Release packages
create-github-releases: true
github-token: ${{ secrets.GITHUB_TOKEN }}
publish-script: npm run release
pr-title: Release packages
# Green must mean published. Once no changesets are pending, the version
# in package.json is the one that should be on npm, whether this run
# published it or an earlier one did; a silent publish failure is red.
- name: Verify package.json version resolves on npm
if: steps.changesets.outputs.has-changesets == 'false'
shell: bash
run: |
set -euo pipefail
name=$(node -p "require('./package.json').name")
version=$(node -p "require('./package.json').version")
for attempt in 1 2 3 4 5 6 7 8; do
if [ "$(npm view "$name@$version" version 2>/dev/null || true)" = "$version" ]; then
echo "registry $name@$version"
exit 0
fi
echo "attempt $attempt: $name@$version not on npm yet"
sleep 15
done
echo "::error::$name@$version is not on npm; the release did not publish."
exit 1