77
88jobs :
99 job-matrix :
10- name : ${{ matrix.os }}
10+ name : ${{ matrix.os }}; release:${{ matrix.release-build }}; ${{ matrix.cross-target }}
1111 runs-on : ${{ matrix.os }}
1212 strategy :
1313 fail-fast : true
1414 matrix :
15- os :
16- - ubuntu-latest
17- - macos-latest
15+ include :
16+ - os : ubuntu-latest
17+ - os : ubuntu-latest
18+ release-build : true
19+
20+ - os : macos-latest
21+ - os : macos-latest
22+ release-build : true
23+
24+ - os : macos-latest
25+ cross-target : aarch64-apple-darwin
26+ - os : macos-latest
27+ cross-target : aarch64-apple-darwin
28+ release-build : true
1829
1930 steps :
2031 - uses : actions/checkout@v2
2132
33+ - name : Set outputs
34+ id : set-outputs
35+ run : |
36+ if [[ "${{ matrix.cross-target }}" ]]; then
37+ echo "::set-output name=build-target::${{ matrix.cross-target }}"
38+ echo "::set-output name=target-option::--target=${{ matrix.cross-target }}"
39+ elif [[ ${{ matrix.os }} == "macos-latest" ]]; then
40+ echo "::set-output name=build-target::x86_64-apple-darwin"
41+ echo "::set-output name=target-option::"
42+ elif [[ ${{ matrix.os }} == "ubuntu-latest" ]]; then
43+ echo "::set-output name=build-target::x86_64-unknown-linux-gnu"
44+ echo "::set-output name=target-option::"
45+ else
46+ echo "Unknown OS: ${{ matrix.os }}"
47+ exit 1
48+ fi
49+
50+ if [[ "${{ matrix.release-build }}" ]]; then
51+ echo "::set-output name=release-build-option::--release"
52+ echo "::set-output name=build-type::release"
53+ else
54+ echo "::set-output name=release-build-option::"
55+ echo "::set-output name=build-type::debug"
56+ fi
57+
2258 - name : Install Rust stable
2359 uses : actions-rs/toolchain@v1
2460 with :
@@ -27,50 +63,32 @@ jobs:
2763 components : llvm-tools-preview
2864 override : true
2965
30- - name : Set os outputs
31- id : set-os
66+ - name : Install cross-build toolchain
67+ if : ${{ matrix.cross-target }}
3268 run : |
33- if [[ ${{ matrix.os }} == "macos-latest" ]]; then
34- echo "::set-output name=os::macos"
35- elif [[ ${{ matrix.os }} == "ubuntu-latest" ]]; then
36- echo "::set-output name=os::linux"
37- else
38- echo "Unknown OS: ${{ matrix.os }}"
39- exit 1
40- fi
69+ rustup target add ${{ matrix.cross-target }}
4170
42- - name : debug build
71+ - name : build
4372 run : |
44- cargo build
45- - name : create debug artifact
73+ cargo build ${{ steps.set-outputs.outputs.release-build-option }} ${{ steps.set-outputs.outputs.target-option }}
74+
75+ - name : create artifact
4676 run : |
47- d=springql_client-${{ steps.set-os.outputs.os }}-debug
48- mkdir ${d}
49-
50- cp springql.h ${d}/
51- mv target/debug/libspringql_client.{so,dylib} ${d}/ || :
52-
53- zip -r ${d}.zip ${d}
77+ artifact_dir=springql_client-${{ steps.set-outputs.outputs.build-target }}-${{ steps.set-outputs.outputs.build-type }}
78+ target_dir=target/${{ matrix.cross-target }}/${{ steps.set-outputs.outputs.build-type }}
5479
55- - name : release build
56- run : |
57- cargo build --release
58- - name : create release artifact
59- run : |
60- d=springql_client-${{ steps.set-os.outputs.os }}-release
61- mkdir ${d}
80+ mkdir ${artifact_dir}
6281
63- cp springql.h ${d }/
64- mv target/release/ libspringql_client.{so,dylib} ${d }/ || :
82+ cp springql.h ${artifact_dir }/
83+ mv ${target_dir}/ libspringql_client.{so,dylib} ${artifact_dir }/ || :
6584
66- zip -r ${d }.zip ${d }
85+ zip -r ${artifact_dir }.zip ${artifact_dir }
6786
68- - name : Upload Files to a GitHub Release (${{ steps.set-os .outputs.os }})
87+ - name : Upload Files to a GitHub Release (${{ steps.set-outputs .outputs.os }})
6988 uses : svenstaro/upload-release-action@2.2.1
7089 with :
7190 repo_token : ${{ secrets.GITHUB_TOKEN }}
72- file_glob : true
73- file : springql_client-${{ steps.set-os.outputs.os }}-*.zip
91+ file : springql_client-${{ steps.set-outputs.outputs.build-target }}-${{ steps.set-outputs.outputs.build-type }}.zip
7492 tag : ${{ github.ref }}
7593 overwrite : true
7694 prerelease : false
0 commit comments