-
-
Notifications
You must be signed in to change notification settings - Fork 616
140 lines (121 loc) · 4.57 KB
/
release.yml
File metadata and controls
140 lines (121 loc) · 4.57 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
name: Publish Release
on:
release:
types: [published]
permissions:
contents: read
jobs:
publish:
name: Publish crates
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Set environment
env:
W_FLAGS: ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && '-Dwarnings' || '' }}
# Setting `RUSTFLAGS` overrides any flags set on .cargo/config.toml, so we need to
# set the target flags instead which are cumulative.
# Track https://github.com/rust-lang/cargo/issues/5376
run: |
target=$(rustc -vV | awk '/^host/ { print $2 }' | tr [:lower:] [:upper:] | tr '-' '_')
echo "CARGO_TARGET_${target}_RUSTFLAGS=$W_FLAGS" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable
with:
toolchain: stable
- name: Install cargo-workspaces
uses: baptiste0928/cargo-install@f204293d9709061b7bc1756fec3ec4e2cd57dec0 # v3.4.0
with:
crate: cargo-workspaces
- name: Release
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
PATCH: ${{ github.run_number }}
shell: bash
run: |
git config --global user.email "[email protected]"
git config --global user.name "Github Action"
cargo workspaces publish \
--from-git \
--yes \
--no-git-commit \
skip
npm_publish:
name: Publish NPM package (wasm)
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable
with:
toolchain: stable
targets: wasm32-unknown-unknown
- name: Install wasm-pack
uses: baptiste0928/cargo-install@f204293d9709061b7bc1756fec3ec4e2cd57dec0 # v3.4.0
with:
crate: wasm-pack
- name: Build boa_wasm
run: wasm-pack build --scope boa-dev ./ffi/wasm
- name: Set-up Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: "20"
- name: Set-up npm config for publishing
run: npm config set -- '//registry.npmjs.org/:_authToken' "${{ secrets.NPM_TOKEN }}"
- name: Check if the npm version already exists
run: |
VERSION=$(jq -r '.version' ./ffi/wasm/pkg/package.json)
if npm view @boa-dev/boa_wasm@$VERSION version > dev/null 2>&1; then
echo "Version $VERSION already published. Skipping"
echo "SKIP_PUBLISH=true" >> $GITHUB_ENV
fi
- name: Publish to npm
if: env.SKIP_PUBLISH != 'true'
run: npm publish ./ffi/wasm/pkg --access=public
release-binaries:
name: Publish binaries
permissions:
contents: write
needs: publish
strategy:
fail-fast: false
matrix:
build: [linux, macos-arm64, win-msvc]
include:
- build: linux
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
binary_extension: ""
- build: macos-arm64
os: macos-14
target: aarch64-apple-darwin
binary_extension: ""
- build: win-msvc
os: windows-latest
target: x86_64-pc-windows-msvc
binary_extension: ".exe"
runs-on: ${{ matrix.os }}
timeout-minutes: 60
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Cache Cargo
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- name: Build
run: cargo build --target ${{ matrix.target }} --verbose --release --locked --bin boa
- name: Upload binaries to release
uses: svenstaro/upload-release-action@29e53e917877a24fad85510ded594ab3c9ca12de # v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/${{ matrix.target }}/release/boa${{ matrix.binary_extension }}
asset_name: boa-${{ matrix.target }}${{ matrix.binary_extension }}
tag: ${{ github.ref }}