-
Notifications
You must be signed in to change notification settings - Fork 1.8k
190 lines (166 loc) · 7.74 KB
/
turborepo-library-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
name: Turborepo Library Release
on:
workflow_dispatch:
inputs:
dry_run:
description: "Do a dry run, skipping the final publish step."
type: boolean
jobs:
build:
defaults:
run:
shell: bash -leo pipefail {0}
strategy:
fail-fast: false
matrix:
settings:
- host: macos-latest
target: "aarch64-apple-darwin"
- host: macos-latest
target: "x86_64-apple-darwin"
- host: ubuntu-latest
target: "aarch64-unknown-linux-gnu"
setup: |
sudo apt update
sudo apt install -y g++-aarch64-linux-gnu libc6-dev-arm64-cross
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++" >> $GITHUB_ENV
- host: ubuntu-latest
target: "x86_64-unknown-linux-gnu"
container: amazon/aws-lambda-nodejs:18
install: |
yum install -y gcc gcc-c++ git
curl https://sh.rustup.rs -sSf | bash -s -- -y
npm i -g pnpm@8.9.0
setup: |
pnpm install
- host: ubuntu-latest
target: "x86_64-unknown-linux-musl"
container: ghcr.io/napi-rs/napi-rs/nodejs-rust:stable-2023-09-17-alpine
install: |
apk add libc6-compat curl
setup: |
pnpm install
- host: ubuntu-latest
target: "aarch64-unknown-linux-musl"
container: ghcr.io/napi-rs/napi-rs/nodejs-rust:stable-2023-09-17-alpine
install: |
apk add libc6-compat curl
echo /root/.cargo/bin >> ${GITHUB_PATH}
echo /usr/local/cargo/bin/rustup >> ${GITHUB_PATH}
echo /aarch64-linux-musl-cross/bin >> ${GITHUB_PATH}
export PATH=/aarch64-linux-musl-cross/bin:/usr/local/cargo/bin/rustup:/root/.cargo/bin:${PATH}
setup: |
export PATH=/aarch64-linux-musl-cross/bin:/usr/local/cargo/bin/rustup:/root/.cargo/bin:${PATH}
rustup default $(cat ./rust-toolchain)-aarch64-unknown-linux-musl
rustup target add aarch64-unknown-linux-musl
rustup toolchain install $(cat ./rust-toolchain)
pnpm install
rust_env: CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc RUSTFLAGS="-Ctarget-feature=-crt-static"
- host: windows-latest
target: "aarch64-pc-windows-msvc"
- host: windows-latest
target: "x86_64-pc-windows-msvc"
runs-on: ${{ matrix.settings.host }}
container:
image: ${{ matrix.settings.container }}
steps:
- name: Install Packages
run: ${{ matrix.settings.install }}
if: ${{ matrix.settings.install }}
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Rust
uses: ./.github/actions/setup-rust
with:
targets: ${{ matrix.settings.target }}
github-token: ${{ github.token }}
if: ${{ !matrix.settings.install }}
- name: Setup Node
uses: ./.github/actions/setup-node
with:
enable-corepack: false
if: ${{ !matrix.settings.install }}
- name: Setup toolchain
run: ${{ matrix.settings.setup }}
if: ${{ matrix.settings.setup }}
- name: Build native library
run: |
cd packages/turbo-repository
${{ matrix.settings.rust_env }} pnpm build:release --target=${{ matrix.settings.target }}
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: turbo-library-${{ matrix.settings.target }}
path: packages/turbo-repository/native
package:
name: "Publish to NPM"
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Configure git
run: |
git config --global user.name 'Turbobot'
git config --global user.email 'turbobot@vercel.com'
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
path: native-packages
- name: Move artifacts into place
run: |
mv native-packages/turbo-library-aarch64-apple-darwin/@turbo/repository.darwin-arm64.node packages/turbo-repository/npm/darwin-arm64/
mv native-packages/turbo-library-x86_64-apple-darwin/@turbo/repository.darwin-x64.node packages/turbo-repository/npm/darwin-x64/
mv native-packages/turbo-library-aarch64-unknown-linux-gnu/@turbo/repository.linux-arm64-gnu.node packages/turbo-repository/npm/linux-arm64-gnu/
mv native-packages/turbo-library-aarch64-unknown-linux-musl/@turbo/repository.linux-arm64-musl.node packages/turbo-repository/npm/linux-arm64-musl/
mv native-packages/turbo-library-x86_64-unknown-linux-gnu/@turbo/repository.linux-x64-gnu.node packages/turbo-repository/npm/linux-x64-gnu/
mv native-packages/turbo-library-x86_64-unknown-linux-musl/@turbo/repository.linux-x64-musl.node packages/turbo-repository/npm/linux-x64-musl/
mv native-packages/turbo-library-aarch64-pc-windows-msvc/@turbo/repository.win32-arm64-msvc.node packages/turbo-repository/npm/win32-arm64-msvc/
mv native-packages/turbo-library-x86_64-pc-windows-msvc/@turbo/repository.win32-x64-msvc.node packages/turbo-repository/npm/win32-x64-msvc/
- name: Build Meta Package
run: |
cd packages/turbo-repository/js
npm run build
- name: Package Artifacts
run: |
mkdir tarballs
npm pack packages/turbo-repository/npm/darwin-arm64
npm pack packages/turbo-repository/npm/darwin-x64
npm pack packages/turbo-repository/npm/linux-arm64-gnu
npm pack packages/turbo-repository/npm/linux-arm64-musl
npm pack packages/turbo-repository/npm/linux-x64-gnu
npm pack packages/turbo-repository/npm/linux-x64-musl
npm pack packages/turbo-repository/npm/win32-arm64-msvc
npm pack packages/turbo-repository/npm/win32-x64-msvc
npm pack packages/turbo-repository/js
mv *.tgz tarballs/
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: Upload Tarballs
path: tarballs
- name: Publish Artifacts
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
if: ${{ !inputs.dry_run }}
run: |
npm config set --location=project "//registry.npmjs.org/:_authToken" ${NPM_TOKEN}
VERSION=$(jq -r .version packages/turbo-repository/js/package.json)
cd tarballs
ls
TAG="canary"
npm publish -ddd --tag ${TAG} --access public turbo-repository-darwin-arm64-${VERSION}.tgz
npm publish -ddd --tag ${TAG} --access public turbo-repository-darwin-x64-${VERSION}.tgz
npm publish -ddd --tag ${TAG} --access public turbo-repository-linux-arm64-gnu-${VERSION}.tgz
npm publish -ddd --tag ${TAG} --access public turbo-repository-linux-arm64-musl-${VERSION}.tgz
npm publish -ddd --tag ${TAG} --access public turbo-repository-linux-x64-gnu-${VERSION}.tgz
npm publish -ddd --tag ${TAG} --access public turbo-repository-linux-x64-musl-${VERSION}.tgz
npm publish -ddd --tag ${TAG} --access public turbo-repository-win32-arm64-msvc-${VERSION}.tgz
npm publish -ddd --tag ${TAG} --access public turbo-repository-win32-x64-msvc-${VERSION}.tgz
npm publish -ddd --tag ${TAG} --access public turbo-repository-${VERSION}.tgz