-
Notifications
You must be signed in to change notification settings - Fork 1.9k
265 lines (239 loc) · 9.06 KB
/
turborepo-release.yml
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# Turborepo Release Pipeline
#
# This release consists of a few steps
#
# 1. Create a staging branch
# 2. Run some smoke tests on that branch
# 3. Build the Rust binary
# 4. Publish JS packages npm (including turbo itself)
# 5. Create a release branch and open a PR.
# You can opt into a dry run, which will skip publishing to npm and opening the release branch
name: Turborepo Release
env:
CARGO_PROFILE_RELEASE_LTO: true
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
RELEASE_TURBO_CLI: true # TODO: do we need this?
# Needed since we need to build on Xenial which doesn't have a new enough
# GLIBC to use Node 20.
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
on:
workflow_dispatch:
inputs:
increment:
description: "SemVer Increment (prerelease = bump canary)"
required: true
default: "prerelease"
type: choice
options:
- prerelease
- prepatch
- preminor
- premajor
- patch
- minor
- major
dry_run:
description: "Do a dry run, skipping the final publish step."
type: boolean
jobs:
stage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-node
with:
enable-corepack: false
- name: Configure git
run: |
git config --global user.name 'Turbobot'
git config --global user.email '[email protected]'
- name: Version
run: |
./scripts/version.js ${{ inputs.increment }}
cat version.txt
- name: Stage Commit
id: stage
run: cd cli && make stage-release && echo "STAGE_BRANCH=$(git branch --show-current)" >> $GITHUB_OUTPUT
- name: Show Stage Commit
run: echo "${{ steps.stage.outputs.STAGE_BRANCH }}"
outputs:
stage-branch: "${{ steps.stage.outputs.STAGE_BRANCH }}"
rust-smoke-test:
name: Rust Unit Tests
runs-on: ubuntu-latest
needs: [stage]
steps:
- name: Show Stage Commit
run: echo "${{ needs.stage.outputs.stage-branch }}"
- uses: actions/checkout@v3
with:
ref: ${{ needs.stage.outputs.stage-branch }}
- name: Setup Turborepo Environment
uses: ./.github/actions/setup-turborepo-environment
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Run Rust Unit Tests
run: cargo groups test turborepo
js-smoke-test:
name: JS Package Tests
runs-on: ubuntu-latest
needs: [stage]
steps:
- name: Show Stage Commit
run: echo "${{ needs.stage.outputs.stage-branch }}"
- uses: actions/checkout@v3
with:
ref: ${{ needs.stage.outputs.stage-branch }}
- name: Setup Turborepo Environment
uses: ./.github/actions/setup-turborepo-environment
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
node-version: "20"
- name: Install Global Turbo
uses: ./.github/actions/install-global-turbo
- name: Run JS Package Tests
run: turbo run check-types test --filter="./packages/*" --color
build-rust:
name: "Build Rust"
needs: [stage, rust-smoke-test, js-smoke-test]
strategy:
fail-fast: false
matrix:
settings:
- host: macos-latest
target: "x86_64-apple-darwin"
container-options: "--rm"
- host: macos-latest
target: "aarch64-apple-darwin"
container-options: "--rm"
- host: ubuntu-latest
container-options: "--platform=linux/amd64 --rm"
target: "x86_64-unknown-linux-musl"
setup: "sudo apt-get && sudo apt-get install -y build-essential clang lldb llvm libclang curl musl-tools sudo unzip"
- host: ubuntu-latest
container-options: "--rm"
target: "aarch64-unknown-linux-musl"
rust-build-env: 'CC_aarch64_unknown_linux_musl=clang AR_aarch64_unknown_linux_musl=llvm-ar RUSTFLAGS="-Clink-self-contained=yes -Clinker=rust-lld"'
setup: "sudo apt-get update && sudo apt-get install -y build-essential musl-tools clang llvm gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu"
- host: windows-latest
target: x86_64-pc-windows-msvc
container-options: "--rm"
runs-on: ${{ matrix.settings.host }}
container:
image: ${{ matrix.settings.container }}
options: ${{ matrix.settings.container-options }}
steps:
- name: Show Stage Commit
run: echo "${{ needs.stage.outputs.stage-branch }}"
- name: Checkout repo
uses: actions/checkout@v3
with:
ref: "${{ needs.stage.outputs.stage-branch }}"
- name: Setup Container
if: ${{ matrix.settings.container-setup }}
run: ${{ matrix.settings.container-setup }}
- name: Setup Protoc
uses: arduino/[email protected]
with:
version: "26.x"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup capnproto
uses: ./.github/actions/setup-capnproto
- name: Setup Rust Up
if: ${{ matrix.settings.container-setup }}
# setup-rust-toolchain uses the --retry-connrefused flag with curl to install rustup
# this flag was added in curl 7.52.0, but the Ubuntu version we use only has 7.47.0
run: |
curl --proto '=https' --tlsv1.2 --retry 10 --location --silent --show-error --fail "https://sh.rustup.rs" | sh -s -- --default-toolchain none -y
echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH
- name: Rust Setup
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.settings.target }}
# needed to not make it override the defaults
rustflags: ""
# we want more specific settings
cache: false
- name: Build Setup
shell: bash
if: ${{ matrix.settings.setup }}
run: ${{ matrix.settings.setup }}
- name: Build
run: ${{ matrix.settings.rust-build-env }} cargo build --profile release-turborepo -p turbo --target ${{ matrix.settings.target }}
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: turbo-${{ matrix.settings.target }}
path: target/${{ matrix.settings.target }}/release-turborepo/turbo*
npm-publish:
name: "Publish To NPM"
runs-on: ubuntu-latest
needs: [stage, build-rust]
steps:
- name: Show Stage Commit
run: echo "${{ needs.stage.outputs.stage-branch }}"
- uses: actions/checkout@v3
with:
ref: "${{ needs.stage.outputs.stage-branch }}"
- run: git fetch origin --tags
- uses: ./.github/actions/setup-node
with:
enable-corepack: false
- name: Install Global Turbo
uses: ./.github/actions/install-global-turbo
- name: Configure git
run: |
git config --global user.name 'Turbobot'
git config --global user.email '[email protected]'
- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
distribution: goreleaser-pro
version: v1.18.2
install-only: true
env:
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
- name: Download Rust artifacts
uses: actions/download-artifact@v4
with:
path: rust-artifacts
- name: Move Rust artifacts into place
run: |
mv rust-artifacts/turbo-aarch64-apple-darwin cli/dist-darwin-arm64
mv rust-artifacts/turbo-aarch64-unknown-linux-musl cli/dist-linux-arm64
cp -r rust-artifacts/turbo-x86_64-pc-windows-msvc cli/dist-windows-arm64
mv rust-artifacts/turbo-x86_64-unknown-linux-musl cli/dist-linux-amd64
mv rust-artifacts/turbo-x86_64-apple-darwin cli/dist-darwin-amd64
mv rust-artifacts/turbo-x86_64-pc-windows-msvc cli/dist-windows-amd64
- name: Perform Release
run: cd cli && make publish-turbo SKIP_PUBLISH=${{ inputs.dry_run && '--skip-publish' || '' }}
env:
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# Upload published artifacts in case they are needed for debugging later
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: turbo-combined
path: cli/dist
create-release-pr:
name: "Open Release Branch PR"
needs: [stage, npm-publish]
runs-on: ubuntu-latest
steps:
- name: Show Stage Commit
run: echo "${{ needs.stage.outputs.stage-branch }}"
- uses: actions/[email protected]
with:
ref: ${{ needs.stage.outputs.stage-branch }}
- name: Get version
id: getVersion
run: echo "version=$(head -n 1 version.txt)" >> $GITHUB_OUTPUT
- name: Create pull request
uses: thomaseizinger/create-pull-request@master
if: ${{ !inputs.dry_run }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
head: ${{ needs.stage.outputs.stage-branch }}
base: main
title: "release(turborepo): ${{ steps.getVersion.outputs.version }}"