Repository navigation
159 lines (130 loc) · 4.41 KB
/
Copy pathci.yml
File metadata and controls
159 lines (130 loc) · 4.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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: ci
on: [push, pull_request, workflow_dispatch]
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
compile:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v6
- name: Set up node
uses: actions/setup-node@v6
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Compile
run: pnpm build
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v6
- name: Set up node
uses: actions/setup-node@v6
- name: Test release validation
run: node --test .github/scripts/validate-release.test.cjs
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Test
run: pnpm test
package:
needs: [ compile, test ]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
outputs:
dist-tag: ${{ steps.release.outputs.dist-tag }}
steps:
- name: Checkout repo
uses: actions/checkout@v6
with:
persist-credentials: false
fetch-depth: 0
- name: Set up node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "24"
package-manager-cache: false
- name: Verify release commit is on main
run: |
git fetch --no-tags origin +refs/heads/main:refs/remotes/origin/main
bash .github/scripts/verify-release-commit.sh
- name: Validate release tag
run: node .github/scripts/validate-release.cjs
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm build
- name: Select npm dist-tag
id: release
run: |
if [[ ${GITHUB_REF} == *alpha* ]]; then
dist_tag=alpha
elif [[ ${GITHUB_REF} == *beta* ]]; then
dist_tag=beta
else
PKG_NAME=$(node -p "require('./package.json').name")
PKG_VERSION=$(node -p "require('./package.json').version")
CURRENT_LATEST=$(npm view "${PKG_NAME}" dist-tags.latest 2>/dev/null || echo "0.0.0")
if npx -y semver "${PKG_VERSION}" -r "<${CURRENT_LATEST}" > /dev/null 2>&1; then
dist_tag=backport
else
dist_tag=latest
fi
fi
echo "dist-tag=${dist_tag}" >> "$GITHUB_OUTPUT"
- name: Pack npm artifact
run: |
mkdir -p "$RUNNER_TEMP/npm-package"
npm pack --ignore-scripts --pack-destination "$RUNNER_TEMP/npm-package"
- name: Upload npm artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: npm-package
path: ${{ runner.temp }}/npm-package/*.tgz
if-no-files-found: error
retention-days: 1
publish:
needs: package
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
id-token: write
steps:
# Keep package code and caches out of the job with publishing authority.
- name: Set up node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "24"
registry-url: https://registry.npmjs.org
package-manager-cache: false
- name: Download npm artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: npm-package
path: .release
- name: Publish npm artifact
env:
DIST_TAG: ${{ needs.package.outputs.dist-tag }}
run: |
tarballs=(.release/*.tgz)
if [[ ${#tarballs[@]} -ne 1 || ! -f "${tarballs[0]}" ]]; then
echo "::error::Expected exactly one npm package tarball."
exit 1
fi
case "$DIST_TAG" in
latest|alpha|beta|backport) ;;
*) echo "::error::Unexpected npm dist-tag."; exit 1 ;;
esac
npm publish "${tarballs[0]}" --access public --ignore-scripts --tag "$DIST_TAG"