-
Notifications
You must be signed in to change notification settings - Fork 48
152 lines (130 loc) · 4.51 KB
/
main.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
name: ci
on:
push:
paths:
- 'Cargo.toml'
- 'html-parser/core/**'
- 'html-parser/plugin/**'
- '.github/workflows/**'
pull_request:
branches-ignore: [master]
paths:
- 'Cargo.toml'
- 'html-parser/core/**'
- 'html-parser/plugin/**'
- '.github/workflows/**'
jobs:
build:
name: ${{ matrix.kind }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
matrix:
os: [macOS-latest, windows-latest, ubuntu-latest]
env:
GH_ACTIONS: true
RUST_BACKTRACE: full
DENO_BUILD_MODE: release
steps:
- name: Clone repository
uses: actions/checkout@v1
- name: Install rust
uses: hecrj/setup-rust-action@v1
with:
rust-version: '1.60.0'
- name: Log versions
run: |
rustc --version
cargo --version
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Remove Some Cache
if: matrix.os == 'windows-latest'
run: |
rm target/release/gn_root -Recurse -ErrorAction Ignore
rm target/debug/gn_root -Recurse -ErrorAction Ignore
- name: Build
env:
RUST_BACKTRACE: 1
run: cargo clean && cargo build --release
- name: Build ARM64 Linux
if: matrix.os == 'ubuntu-latest'
env:
RUST_BACKTRACE: 1
shell: bash
run: |
# Keep the Linux x86_64 build artifact around since
# we'll be clearing it to build the ARM64 artifact
cp target/release/libplugin.so .
target=aarch64-unknown-linux-gnu
arm64_cargo_config=$(cat <<CONFIG
[build]
target = "$target"
rustflags = ["-C", "linker=clang", "-C", "link-arg=--target=$target", "-C", "link-arg=-fuse-ld=lld"]
CONFIG
)
install -D <(printf %s "$arm64_cargo_config") .cargo/config.toml
rustup target add "$target"
# Add ARM64 Ubuntu repos
sed -E '/^deb/!d; s|.+/([^/]+\.txt)?|deb [arch=arm64] http://ports.ubuntu.com/|' /etc/apt/sources.list | sudo tee /etc/apt/sources.list.d/sources-arm64.list
# Mark existing repos as x86_64 only
sudo sed -i -E 's/^deb/deb [arch=amd64]/' /etc/apt/sources.list
sudo dpkg --add-architecture arm64
sudo bash -c 'apt update; true'
# Install ARM64 deps
ubuntu_version=$(grep VERSION_ID /etc/os-release | tr -dc '[:digit:].')
gcc_lib=
case $ubuntu_version in
20.04 ) gcc_lib=libgcc-9-dev ;;
22.04 ) gcc_lib=libgcc-11-dev ;;
* )
echo "Unsupported Ubuntu version" >&2
exit 1
;;
esac
sudo apt install libgcc-s1:arm64 libc6:arm64 libc6-dev:arm64 "$gcc_lib:arm64" -y
# Make sure the ARM64 dependency libraries are found by the linker
(
cd /usr/lib/aarch64-linux-gnu
for lib in gcc_s util rt pthread m dl c; do
for file in lib$lib.so.*; do
link_path=lib$lib.so
if [[ -f $file && ! -e $link_path ]]; then
sudo ln -s "$file" "$link_path"
fi
done
done
)
if cargo clean && cargo build --release; then
lib=target/$target/release/libplugin.so
cp "$lib" "${lib%.so}-linux-aarch64.so"
else
echo "Failed to build Linux ARM64 target"
fi
# Put the x86_64 build artifact back
install -D libplugin.so target/release/libplugin.so
- name: Release Plugin
uses: softprops/action-gh-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: 'release draft'
draft: true
files: |
target/release/libplugin.dylib
target/release/plugin.dll
target/release/libplugin.so
target/aarch64-unknown-linux-gnu/release/libplugin-linux-aarch64.so