-
Notifications
You must be signed in to change notification settings - Fork 2
193 lines (165 loc) · 5.86 KB
/
Copy pathci.yaml
File metadata and controls
193 lines (165 loc) · 5.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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: CI
on:
push:
branches:
- main
- release-*
pull_request: {}
workflow_dispatch:
inputs:
version:
description: Package version (e.g. v0.1.0)
required: false
env:
NODE_VERSION: "24"
jobs:
# Compute the package version once and share it with all jobs that need it
version:
runs-on: &default-runner ubuntu-26.04
outputs:
version: ${{ steps.version.outputs.version }}
npm-tag: ${{ steps.version.outputs.npm-tag }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
with:
node-version: ${{env.NODE_VERSION}}
registry-url: "https://registry.npmjs.org"
# If a version wasn't explicitly passed as a workflow_dispatch input we
# default to version $(npm pkg get version)-<git-commit-date>-<git-short-sha>, for example
# v0.1.1-20231101115142-1091066df799.
- name: Compute Package Version
id: version
env:
INPUT_VERSION: ${{ inputs.version }}
run: |
if [ -n "${INPUT_VERSION}" ]; then
VERSION="${INPUT_VERSION}"
RELEASE_TYPE="latest"
else
VERSION="v$(npm pkg get version | tr -d '"')-$(date -d@$(git show -s --format=%ct) +%Y%m%d%H%M%S)-$(git rev-parse --short=12 HEAD)"
RELEASE_TYPE="next"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Computed version: ${VERSION}"
echo "npm-tag=${RELEASE_TYPE}" >> $GITHUB_OUTPUT
echo "npm-tag: ${RELEASE_TYPE}"
protobuf-check:
runs-on: *default-runner
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Install
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
with:
node-version: ${{env.NODE_VERSION}}
- run: npm ci
# Update this version when ts-proto in package.json is updated
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: "36.2"
- name: Generate Protobuf Files
run: npm run protoc-gen
- name: Check for changes in src
run: |
if [[ -n $(git status --porcelain src) ]]; then
echo "Error: Protobuf generation caused changes in src directory"
echo "Please run 'npm run protoc-gen' locally and commit the changes"
git --no-pager status src
git --no-pager diff src
exit 1
fi
echo "No changes detected in src directory"
lint:
runs-on: *default-runner
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Install
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
with:
node-version: ${{env.NODE_VERSION}}
- run: npm ci
- name: Lint
run: npm run lint
# npm run build compiles only src, which tsconfig.json excludes tests
# from. Type check the tests too, so that a change to an exported
# signature cannot silently break callers the tests cover.
- name: Typecheck
run: npm run typecheck
# Last, because a step that fails stops the job: a formatting nit should
# not hide a real lint or type error. Run `npm run format` to fix.
- name: Format
run: npm run format:check
test:
runs-on: *default-runner
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Install
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
with:
node-version: ${{env.NODE_VERSION}}
- run: npm ci
- name: test
run: npm test
build:
runs-on: *default-runner
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Build
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
with:
node-version: ${{env.NODE_VERSION}}
- run: npm ci
- run: npm run clean
- run: npm run build
publish:
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
runs-on: *default-runner
needs:
- version
- protobuf-check
- test
- lint
- build
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Setup Node
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
with:
node-version: ${{env.NODE_VERSION}}
registry-url: "https://registry.npmjs.org"
- run: npm ci
- name: Set package version
env:
VERSION: ${{ needs.version.outputs.version }}
INPUT_VERSION: ${{ inputs.version }}
run: |
if [ -z "${INPUT_VERSION}" ]; then
# No explicit version provided, set it to the computed version
npm version "$VERSION" --no-git-tag-version
else
# Explicit version provided, verify it matches package.json
PACKAGE_VERSION="v$(npm pkg get version | tr -d '"')"
if [ "$VERSION" != "$PACKAGE_VERSION" ]; then
echo "Error: Provided version $VERSION does not match package.json version $PACKAGE_VERSION"
exit 1
fi
echo "Version $VERSION matches package.json, proceeding with publish"
fi
- run: npm run clean
- run: npm run build
- name: Publish to npm
env:
NPM_TAG: ${{ needs.version.outputs.npm-tag }}
run: npm publish --provenance --access public --tag "${NPM_TAG}"