-
Notifications
You must be signed in to change notification settings - Fork 14
182 lines (175 loc) · 6.36 KB
/
build.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
name: Build
on:
release:
types: [published]
workflow_dispatch:
jobs:
build-windows:
runs-on: windows-latest
strategy:
matrix:
target: [x86_64-pc-windows-msvc]
env:
CRATE_NAME: "clue"
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Cache build
uses: Swatinem/rust-cache@v2
- name: Build ${{ matrix.target }}
run: |
cargo build --target=${{ matrix.target }} --release -vv
cd target\${{ matrix.target }}\release && tar -cavf "$env:CRATE_NAME-${{ matrix.target }}.zip" "$env:CRATE_NAME.exe" && cd ../../..
- name: Upload clue-${{ matrix.target }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.CRATE_NAME }}-${{ matrix.target }}.zip
path: target\${{ matrix.target }}\release\${{ env.CRATE_NAME }}-${{ matrix.target }}.zip
- name: Publish in release
uses: softprops/action-gh-release@v1
if: github.ref_type == 'tag'
with:
files: |
target/${{ matrix.target }}/release/${{ env.CRATE_NAME }}-${{ matrix.target }}.zip
token: ${{ secrets.GITHUB_TOKEN }}
build-macos:
runs-on: macos-latest
strategy:
matrix:
target: [x86_64-apple-darwin, aarch64-apple-darwin]
env:
CRATE_NAME: "clue"
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Cache build
uses: Swatinem/rust-cache@v2
- name: Setup
run: rustup target add ${{ matrix.target }}
- name: Build ${{ matrix.target }}
env:
TARGET_LDFLAGS: "--target=${{ matrix.target }}"
TARGET_CFLAGS: "--target=${{ matrix.target }}"
run: |
cargo build --release --target=${{ matrix.target }} -vv
( cd target/${{ matrix.target }}/release/ && tar -cavf "$CRATE_NAME-${{ matrix.target }}.tar.gz" "$CRATE_NAME" )
- name: Upload clue-${{ matrix.target }}.tar.gz
uses: actions/upload-artifact@v4
with:
name: ${{ env.CRATE_NAME }}-${{ matrix.target }}.tar.gz
path: target/${{ matrix.target }}/release/${{ env.CRATE_NAME }}-${{ matrix.target }}.tar.gz
- name: Publish in release
uses: softprops/action-gh-release@v1
if: github.ref_type == 'tag'
with:
files: |
target/${{ matrix.target }}/release/${{ env.CRATE_NAME }}-${{ matrix.target }}.tar.gz
build-gnu-linux:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
host_cc: ""
target_cc: ""
- target: aarch64-unknown-linux-gnu
host_cc: ""
target_cc: aarch64-linux-gnu
- target: armv7-unknown-linux-gnueabi
host_cc: i686-linux-gnu
target_cc: arm-linux-gnueabi
- target: armv7-unknown-linux-gnueabihf
host_cc: i686-linux-gnu
target_cc: arm-linux-gnueabihf
env:
CRATE_NAME: "clue"
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Cache build
uses: Swatinem/rust-cache@v2
- name: Setup
run: |
rustup target add ${{ matrix.target }}
cargo install cargo-deb cargo-make-rpm
write_var(){
echo "$1=$(eval echo \$$1)" >> $GITHUB_ENV
}
sudo apt update
if ! [[ -z "${{ matrix.host_cc }}" ]]; then
export HOST_CC="${{ matrix.host_cc }}-gcc"
write_var HOST_CC
sudo apt install -y -qq gcc-${{ matrix.host_cc }}
fi
if ! [[ -z "${{ matrix.target_cc }}" ]]; then
export TARGET_CC="${{ matrix.target_cc }}-gcc"
write_var TARGET_CC
sudo apt install -y -qq gcc-${{ matrix.target_cc }}
mkdir -p .cargo
echo '[target.${{ matrix.target }}]'>>.cargo/config
echo "linker = \"$TARGET_CC\"">>.cargo/config
fi
- name: Build ${{ matrix.target }}
run: |
cargo build --target=${{ matrix.target }} --release -vv
( cd target/${{ matrix.target }}/release/ && tar -cavf "$CRATE_NAME-${{ matrix.target }}.tar.gz" "$CRATE_NAME" )
- name: Build deb
run: |
cd cli && cargo deb -p clue --target=${{ matrix.target }} && cd ..
echo "DEB_FILENAME=$(basename $(echo target/${{ matrix.target }}/debian/*.deb))" >> $GITHUB_ENV
- name: Build rpm
run: |
cargo-make-rpm -p clue --target=${{ matrix.target }}
echo "RPM_FILENAME=$(basename $(echo target/${{ matrix.target }}/rpm/*.rpm))" >> $GITHUB_ENV
- name: Upload ${{ env.CRATE_NAME }}-${{ matrix.target }}.tar.gz
uses: actions/upload-artifact@v4
with:
name: ${{ env.CRATE_NAME }}-${{ matrix.target }}.tar.gz
path: target/${{ matrix.target }}/release/*.tar.gz
- name: Upload ${{ env.DEB_FILENAME }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.DEB_FILENAME }}
path: target/${{ matrix.target }}/debian/*.deb
- name: Upload ${{ env.RPM_FILENAME }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.RPM_FILENAME }}
path: target/${{ matrix.target }}/rpm/*.rpm
- name: Publish in release
uses: softprops/action-gh-release@v1
if: github.ref_type == 'tag'
with:
files: |
target/${{ matrix.target }}/release/*.tar.gz
target/${{ matrix.target }}/debian/*.deb
target/${{ matrix.target }}/rpm/*.rpm
build-wasm:
runs-on: ubuntu-latest
env:
CRATE_NAME: "clue"
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Cache build
uses: Swatinem/rust-cache@v2
- name: Setup
run: |
rustup target add wasm32-unknown-unknown
cargo install wasm-pack
- name: Build wasm
run: |
cd wasm
wasm-pack build --target web --release
zip -r clue_wasm.zip pkg
- name: Upload clue_wasm.zip
uses: actions/upload-artifact@v4
with:
name: clue_wasm.zip
path: wasm/clue_wasm.zip
- name: Publish in release
uses: softprops/action-gh-release@v1
if: github.ref_type == 'tag'
with:
files: |
wasm/clue_wasm.zip