7
7
8
8
jobs :
9
9
job-matrix :
10
- name : ${{ matrix.os }}
10
+ name : ${{ matrix.os }}; release:${{ matrix.release-build }}; ${{ matrix.cross-target }}
11
11
runs-on : ${{ matrix.os }}
12
12
strategy :
13
13
fail-fast : true
14
14
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
18
29
19
30
steps :
20
31
- uses : actions/checkout@v2
21
32
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
+
22
58
- name : Install Rust stable
23
59
uses : actions-rs/toolchain@v1
24
60
with :
@@ -27,50 +63,32 @@ jobs:
27
63
components : llvm-tools-preview
28
64
override : true
29
65
30
- - name : Set os outputs
31
- id : set-os
66
+ - name : Install cross-build toolchain
67
+ if : ${{ matrix.cross-target }}
32
68
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 }}
41
70
42
- - name : debug build
71
+ - name : build
43
72
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
46
76
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 }}
54
79
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}
62
81
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 }/ || :
65
84
66
- zip -r ${d }.zip ${d }
85
+ zip -r ${artifact_dir }.zip ${artifact_dir }
67
86
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 }})
69
88
70
89
with :
71
90
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
74
92
tag : ${{ github.ref }}
75
93
overwrite : true
76
94
prerelease : false
0 commit comments