Repository navigation
91 lines (78 loc) · 3.17 KB
/
Copy pathrelease.yml
File metadata and controls
91 lines (78 loc) · 3.17 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
name: Release
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: write
pull-requests: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
release:
if: github.ref_name == 'main'
runs-on: ubuntu-latest
env:
CI: true
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up pnpm
uses: pnpm/action-setup@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: pnpm
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-apple-darwin,aarch64-apple-darwin,x86_64-pc-windows-msvc
- name: Set up Zig
uses: mlugg/setup-zig@v2
with:
version: 0.14.1
- name: Install cross-compilation tools
run: |
cargo install cargo-zigbuild --locked
cargo install cargo-xwin --locked
- name: Install Node dependencies
run: pnpm install --frozen-lockfile
- name: Create version pull request or publish
uses: ./
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
branch: rivet-release
check: cargo run --release --bin rivet -- check --json
version: cargo run --release --bin rivet -- bump
publish: |
set -euo pipefail
pnpm --dir packages/rivet exec napi build --target x86_64-unknown-linux-gnu --release -x
pnpm --dir packages/rivet exec napi build --target x86_64-pc-windows-msvc --release -x
pnpm --dir packages/rivet exec napi build --target x86_64-apple-darwin --release -x
pnpm --dir packages/rivet exec napi build --target aarch64-apple-darwin --release -x
cd packages/rivet
pnpm exec napi create-npm-dirs
cp ../../target/x86_64-unknown-linux-gnu/release/librivet.so npm/linux-x64-gnu/rivet-native.linux-x64-gnu.node
cp ../../target/x86_64-apple-darwin/release/librivet.dylib npm/darwin-x64/rivet-native.darwin-x64.node
cp ../../target/aarch64-apple-darwin/release/librivet.dylib npm/darwin-arm64/rivet-native.darwin-arm64.node
cp ../../target/x86_64-pc-windows-msvc/release/rivet.dll npm/win32-x64-msvc/rivet-native.win32-x64-msvc.node
VERSION="$(node -p "require('./package.json').version")"
DIST_TAG="$(node -p "const version = require('./package.json').version; const pre = version.split('-')[1]; pre ? pre.split('.')[0] : 'latest'")"
export npm_config_tag="${DIST_TAG}"
RELEASE_ID="$(gh api "repos/${GITHUB_REPOSITORY}/releases/tags/v${VERSION}" --jq .id 2>/dev/null || true)"
if [ -n "${RELEASE_ID}" ]; then
pnpm exec napi prepublish -t npm --gh-release-id "${RELEASE_ID}"
else
pnpm exec napi prepublish -t npm
fi
cd ../..
cargo run --release --bin rivet -- release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_CONFIG_IGNORE_SCRIPTS: true
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}