@@ -2,6 +2,8 @@ name: Rust
22
33on :
44 push :
5+ release :
6+ types : [created]
57
68env :
79 CARGO_TERM_COLOR : always
@@ -12,118 +14,86 @@ defaults:
1214 shell : bash
1315
1416jobs :
15- test :
16- runs-on : ubuntu-latest
17- steps :
18- - uses : actions/checkout@v2
19- - name : Cargo cache
20- uses : actions/cache@v2
21- with :
22- path : |
23- ~/.cargo/registry
24- ./target
25- key : test-cargo-registry
26- - name : List
27- run : find ./
28- - name : Run tests
29- run : cargo test --verbose
30-
3117 build :
18+ runs-on : ${{ matrix.runs-on }}
3219 strategy :
33- fail-fast : false
3420 matrix :
35- # a list of all the targets
21+ os : [x86_64-unknown-linux-musl, x86_64-unknown-linux-gnu]
22+ runs-on : [ubuntu-latest]
23+ cross : [true]
3624 include :
37- - TARGET : x86_64-unknown-linux-gnu # tested in a debian container on a mac
38- OS : ubuntu-latest
39- - TARGET : x86_64-unknown-linux-musl # test in an alpine container on a mac
40- OS : ubuntu-latest
41- - TARGET : aarch64-unknown-linux-gnu # tested on aws t4g.nano
42- OS : ubuntu-latest
43- # - TARGET: aarch64-unknown-linux-musl # tested on aws t4g.nano in alpine container
44- # OS: ubuntu-latest
45- - TARGET : armv7-unknown-linux-gnueabihf # raspberry pi 2-3-4, not tested
46- OS : ubuntu-latest
47- # - TARGET: armv7-unknown-linux-musleabihf # raspberry pi 2-3-4, not tested
48- # OS: ubuntu-latest
49- - TARGET : arm-unknown-linux-gnueabihf # raspberry pi 0-1, not tested
50- OS : ubuntu-latest
51- # - TARGET: arm-unknown-linux-musleabihf # raspberry pi 0-1, not tested
52- # OS: ubuntu-latest
53- - TARGET : x86_64-apple-darwin # tested on a mac, is not properly signed so there are security warnings
54- OS : macos-latest
55- - TARGET : x86_64-pc-windows-gnu # tested on a windows machine
56- OS : windows-latest
57- needs : test
58- runs-on : ${{ matrix.OS }}
59- env :
60- NAME : dbimport
61- TARGET : ${{ matrix.TARGET }}
62- OS : ${{ matrix.OS }}
63- PKG_CONFIG_ALLOW_CROSS : 1
64- LIBZ_SYS_STATIC : 1
25+ - os : x86_64-apple-darwin
26+ runs-on : macos-latest # Apple needs to be compiled on an apple os
27+ cross : false # Cross fails on these platforms
28+ - os : x86_64-pc-windows-gnu
29+ runs-on : windows-latest # Not needed, but why not?
30+ suffix : .exe # Windows has an .exe suffix
31+ cross : false # Cross fails on these platforms
32+
6533 steps :
66- - uses : actions/checkout@v2
67- - name : Cargo cache
68- uses : actions/cache@v2
69- with :
70- path : |
71- ~/.cargo/registry
72- ./target
73- key : build-cargo-registry-${{matrix.TARGET}}
74- - name : List
75- run : find ./
76- - name : Install and configure dependencies
77- run : |
78- # dependencies are only needed on ubuntu as that's the only place where
79- # we make cross-compilation
80- if [[ $OS =~ ^ubuntu.*$ ]]; then
81- sudo apt-get install -qq crossbuild-essential-arm64 crossbuild-essential-armhf
82- sudo apt-get install musl-tools libssl-dev
83- fi
84- - name : Install rust target
85- run : rustup target add $TARGET
86- - name : Run build
87- run : cargo build --release --verbose --target $TARGET
88- - name : List target
89- run : find ./target
90- - name : Compress
91- run : |
92- mkdir -p ./artifacts
93- # windows is the only OS using a different convention for executable file name
94- if [[ $OS =~ ^windows.*$ ]]; then
95- EXEC=$NAME.exe
96- else
97- EXEC=$NAME
98- fi
99- if [[ $GITHUB_REF_TYPE =~ ^tag$ ]]; then
100- TAG=$GITHUB_REF_NAME
101- else
102- TAG=$GITHUB_SHA
103- fi
104- mv ./target/$TARGET/release/$EXEC ./$EXEC
105- tar -czf ./artifacts/$NAME-$TARGET-$TAG.tar.gz $EXEC
106- - name : Archive artifact
107- uses : actions/upload-artifact@v2
108- with :
109- name : result
110- path : |
111- ./artifacts
34+ - uses : actions/checkout@v2
35+
36+ - name : Install Rust
37+ uses : actions-rs/toolchain@v1
38+ with :
39+ toolchain : stable
40+ override : true
41+ profile : minimal
42+ target : ${{ matrix.os }}
11243
113- # deploys to github releases on tag
114- deploy :
115- if : startsWith(github.ref, 'refs/tags/')
116- needs : build
44+ - name : Build Binary
45+ uses : actions-rs/cargo@v1
46+ with :
47+ use-cross : ${{ matrix.cross }}
48+ command : build
49+ args : --target ${{ matrix.os }} --release
50+
51+ - name : Save Artifact
52+ uses : actions/upload-artifact@v2
53+ with :
54+ name : dbimport-${{ matrix.os }}${{ matrix.suffix }}
55+ path : target/${{ matrix.os }}/release/dbimport${{ matrix.suffix }}
56+
57+ - name : Upload Binary
58+ if : github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v')
59+ uses : actions/upload-release-asset@v1
60+ env :
61+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
62+ with :
63+ asset_name : dbimport-${{ matrix.os }}${{ matrix.suffix }}
64+ asset_path : target/${{ matrix.os }}/release/dbimport${{ matrix.suffix }}
65+ upload_url : ${{ github.event.release.upload_url }}
66+ asset_content_type : application/octet-stream
67+
68+ - name : Tests
69+ uses : actions-rs/cargo@v1
70+ with :
71+ use-cross : ${{ matrix.cross }}
72+ command : test
73+ args : --target ${{ matrix.os }} --verbose
74+
75+ clippy_check :
11776 runs-on : ubuntu-latest
11877 steps :
119- - name : Download artifacts
120- uses : actions/download-artifact@v2
78+ - uses : actions/checkout@v1
79+ - run : rustup component add clippy
80+ - uses : actions-rs/clippy-check@v1
12181 with :
122- name : result
123- path : ./artifacts
124- - name : List
125- run : find ./artifacts
126- - name : Release
127- uses : softprops/action-gh-release@v1
128- with :
129- files : ./artifacts/*.tar.gz
82+ token : ${{ secrets.GITHUB_TOKEN }}
83+ args : --all-features
84+
85+ rustfmt :
86+ name : rustfmt
87+ runs-on : ubuntu-latest
88+ steps :
89+ - uses : actions/checkout@v2
90+ - name : Install Rust
91+ uses : actions-rs/toolchain@v1
92+ with :
93+ toolchain : stable
94+ override : true
95+ profile : minimal
96+ components : rustfmt
97+ - name : Check formatting
98+ run : |
99+ cargo fmt --all -- --check
0 commit comments