-
Notifications
You must be signed in to change notification settings - Fork 22
219 lines (195 loc) · 6.12 KB
/
Copy pathnodejs.yml
File metadata and controls
219 lines (195 loc) · 6.12 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
name: Node CI
on: [push, pull_request]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node-version: [20.x, 22.x, 24.x]
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 10.29.3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- name: pnpm install, build, and test
run: |
pnpm install --frozen-lockfile
pnpm test
env:
CI: true
prebuild:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node-version: [22.x]
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 10.29.3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- name: Build native prebuild
run: |
pnpm install --frozen-lockfile
pnpm native:prebuild
env:
CI: true
- uses: actions/upload-artifact@v4
with:
name: tcp-rtt-prebuild-${{ runner.os }}
path: native-addon/prebuilds
release:
needs: [build, prebuild]
if: github.event_name == 'push' && github.ref == 'refs/heads/dev'
runs-on: ubuntu-latest
permissions:
actions: read
contents: write
concurrency:
group: dimensions-release
cancel-in-progress: false
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v4
with:
version: 10.29.3
- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x
cache: pnpm
- name: Read release metadata
id: release
shell: bash
run: |
set -euo pipefail
version="$(node -p "require('./package.json').version")"
tag="v${version}"
zip="Dimensions-v${version}.zip"
prerelease=false
if [[ "$version" == *-* ]]; then
prerelease=true
fi
{
echo "version=$version"
echo "tag=$tag"
echo "zip=$zip"
echo "prerelease=$prerelease"
} >> "$GITHUB_OUTPUT"
- name: Check for existing release tag
id: tag_check
shell: bash
run: |
set -euo pipefail
git fetch --tags --force
if git rev-parse -q --verify "refs/tags/${{ steps.release.outputs.tag }}" >/dev/null; then
echo "exists=true" >> "$GITHUB_OUTPUT"
echo "Tag ${{ steps.release.outputs.tag }} already exists; skipping release."
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- name: Create release tag
id: create_tag
if: steps.tag_check.outputs.exists == 'false'
shell: bash
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -a "${{ steps.release.outputs.tag }}" -m "Release ${{ steps.release.outputs.tag }}"
git push origin "refs/tags/${{ steps.release.outputs.tag }}"
echo "${{ steps.release.outputs.tag }}" > "$RUNNER_TEMP/release-tag-created"
echo "created=true" >> "$GITHUB_OUTPUT"
- name: Install release tools
if: steps.tag_check.outputs.exists == 'false'
run: |
sudo apt-get update
sudo apt-get install -y jq zip
- uses: actions/download-artifact@v4
if: steps.tag_check.outputs.exists == 'false'
with:
pattern: tcp-rtt-prebuild-*
path: native-addon/prebuilds
merge-multiple: true
- name: Build release zip
if: steps.tag_check.outputs.exists == 'false'
run: |
pnpm install --frozen-lockfile
pnpm build:ts
pnpm makerelease
env:
CI: true
- name: Publish GitHub release
if: steps.tag_check.outputs.exists == 'false'
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.release.outputs.tag }}
ZIP: ${{ steps.release.outputs.zip }}
PRERELEASE: ${{ steps.release.outputs.prerelease }}
shell: bash
run: |
set -euo pipefail
release_flags=()
if [[ "$PRERELEASE" == "true" ]]; then
release_flags+=(--prerelease)
fi
gh release create "$TAG" "$ZIP" \
--title "$TAG" \
--notes-file pending_changelog.md \
--verify-tag \
"${release_flags[@]}"
- name: Log in to Docker Hub
if: steps.tag_check.outputs.exists == 'false'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker metadata
id: docker_meta
if: steps.tag_check.outputs.exists == 'false'
uses: docker/metadata-action@v5
with:
images: popstarfreas/dimensions
tags: |
type=raw,value=${{ steps.release.outputs.tag }}
type=raw,value=${{ steps.release.outputs.version }}
type=raw,value=latest,enable=${{ steps.release.outputs.prerelease == 'false' }}
- name: Build and push Docker image
if: steps.tag_check.outputs.exists == 'false'
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
- name: Cleanup failed release
if: failure() && steps.create_tag.outputs.created == 'true'
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.release.outputs.tag }}
shell: bash
run: |
set +e
if [[ ! -f "$RUNNER_TEMP/release-tag-created" ]]; then
echo "Release tag was not created by this run; skipping cleanup."
exit 0
fi
gh release view "$TAG" >/dev/null 2>&1
if [[ $? -eq 0 ]]; then
gh release delete "$TAG" --cleanup-tag -y
fi
git push origin ":refs/tags/$TAG" >/dev/null 2>&1 || true