-
Notifications
You must be signed in to change notification settings - Fork 3
181 lines (174 loc) · 5.96 KB
/
Copy pathtest.yml
File metadata and controls
181 lines (174 loc) · 5.96 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
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
on: [push, pull_request]
defaults:
run:
shell: bash
env:
cratename: rdp
rustflags: -C rpath
name: Test and Build
jobs:
test:
if: github.event_name == 'push' && !contains(github.ref, 'refs/tags/')
name: Test on ${{ matrix.os }} (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- build: linux
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-gnu
use-cross: false
- build: macos
os: macos-latest
rust: stable
target: x86_64-apple-darwin
use-cross: false
deptarget: 10.9
- build: windows
os: windows-latest
rust: stable
target: x86_64-pc-windows-msvc
use-cross: false
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Run tests
env:
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.deptarget }}
run: cargo test --target=${{ matrix.target }}
build:
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
name: Build and release on ${{ matrix.os }} (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- build: linux
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-gnu
use-cross: true
- build: linux
os: ubuntu-latest
rust: stable
target: aarch64-unknown-linux-gnu
use-cross: true
- build: macos
os: macos-latest
rust: stable
target: x86_64-apple-darwin
use-cross: false
deptarget: 10.9
- build: macos
os: macos-latest
rust: stable
target: aarch64-apple-darwin
use-cross: false
deptarget: 11.0
- build: windows
os: windows-latest
rust: stable
target: x86_64-pc-windows-msvc
use-cross: false
steps:
- name: Switch to macOS 14.x SDK
if: matrix.target == 'aarch64-apple-darwin'
run: |
xcodebuild -showsdks
SDKROOT=$(xcrun -sdk macosx14.5 --show-sdk-path)
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Cache cross binary
id: cache-cross
if: matrix.use-cross == true
uses: actions/cache@v4
with:
path: ~/.cargo/bin/cross
key: ${{ runner.os }}-cross-${{ hashFiles('.github/workflows/test.yml') }}
- name: Install cross
if: matrix.use-cross == true && steps.cache-cross.outputs.cache-hit != 'true'
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Build with cross
if: matrix.use-cross == true
env:
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.deptarget }}
run: cross build --release --target=${{ matrix.target }} --features headers
- name: Build with cargo
if: matrix.use-cross == false
env:
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.deptarget }}
run: cargo build --release --target=${{ matrix.target }} --features headers
- name: Install aarch64 related packages
if: matrix.os == 'ubuntu-latest' && matrix.target == 'aarch64-unknown-linux-gnu'
run: sudo apt-get update && sudo apt-get install gcc-aarch64-linux-gnu qemu-system-arm
- name: Gather Assets
run: |
src=$(pwd)
stage=
case $RUNNER_OS in
Linux)
stage=$(mktemp -d)
;;
macOS)
stage=$(mktemp -d -t tmp)
;;
Windows)
stage=$(mktemp -d)
;;
esac
mkdir zipped
cp include/header.h $stage
RELEASE_VERSION=${GITHUB_REF#refs/tags/}
ASSET_NAME="${{ env.cratename }}-$RELEASE_VERSION-${{ matrix.target }}"
echo "Release name is $ASSET_NAME"
echo "STAGE=$stage" >> $GITHUB_ENV
echo "ASSET_NAME=$ASSET_NAME" >> $GITHUB_ENV
if [ "$RUNNER_OS" == "Linux" ]; then
echo "TYPE=tar" >> $GITHUB_ENV
echo "EXTENSION=tar.gz" >> $GITHUB_ENV
cp target/${{ matrix.target }}/release/*.so $stage/
fi
if [ "$RUNNER_OS" == "macOS" ]; then
echo "TYPE=tar" >> $GITHUB_ENV
echo "EXTENSION=tar.gz" >> $GITHUB_ENV
for lib in target/${{ matrix.target }}/release/*.dylib; do
install_name_tool -id "@rpath/lib${{ env.cratename }}.dylib" $lib
otool -L $lib
done
cp target/${{ matrix.target }}/release/*.dylib $stage/
fi
if [ "$RUNNER_OS" == "Windows" ]; then
echo "TYPE=tar" >> $GITHUB_ENV
echo "EXTENSION=tar.gz" >> $GITHUB_ENV
cp target/${{ matrix.target }}/release/deps/${{ env.cratename }}.dll.lib target/${{ matrix.target }}/release/deps/${{ env.cratename }}.lib
cp target/${{ matrix.target }}/release/${{ env.cratename }}* $stage/
cp target/${{ matrix.target }}/release/deps/${{ env.cratename }}* $stage/
fi
ls $stage
cd $src
- name: Create archive
run: |
pushd ${{ env.STAGE }}
tar -czf "${{ env.ASSET_NAME }}.${{ env.EXTENSION }}" *
popd
cp "${{ env.STAGE }}/${{ env.ASSET_NAME }}.${{ env.EXTENSION }}" zipped/
- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
zipped/${{ env.ASSET_NAME }}.${{ env.EXTENSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}