@@ -48,11 +48,20 @@ jobs:
48
48
strategy :
49
49
matrix :
50
50
os :
51
- - ubuntu-latest
52
- - windows-latest
53
- - macos-latest
54
-
55
- runs-on : ${{ matrix.os }}
51
+ - name : ubuntu-latest
52
+ cross_compile_os : linux
53
+ cross_compile_target : aarch64-unknown-linux-gnu
54
+ - name : ubuntu-latest
55
+ cross_compile_os :
56
+ cross_compile_target :
57
+ - name : windows-latest
58
+ cross_compile_os :
59
+ cross_compile_target :
60
+ - name : macos-latest
61
+ cross_compile_os :
62
+ cross_compile_target :
63
+
64
+ runs-on : ${{ matrix.os.name }}
56
65
57
66
steps :
58
67
- uses : actions/checkout@v4
@@ -66,17 +75,34 @@ jobs:
66
75
- name : Setup PostgreSQL
67
76
uses : ikalnytskyi/action-setup-postgres@v6
68
77
69
- - uses : actions-rs/cargo@v1
70
- with :
71
- command : build
72
- args : --release
78
+ - run : |
79
+ if [ -z "${CROSS_COMPILE_TARGET}" ]; then
80
+ # normal build targetting the CPU architecture and the OS of the host
81
+ cargo build --release
82
+ else
83
+ # cross build with the specified rustc target
84
+ cargo install cross
85
+ cross build --release --target ${CROSS_COMPILE_TARGET}
86
+ fi
87
+ env:
88
+ CROSS_COMPILE_TARGET: ${{ matrix.os.cross_compile_target }}
73
89
74
90
- id : build
75
91
run : |
76
- rustc --print cfg | grep = > rustc.vars
77
- source rustc.vars
92
+ if [ -z "${CROSS_COMPILE_TARGET}" ]; then
93
+ # normal build targetting the CPU architecture and the OS of the host
94
+ rustc --print cfg | grep = > rustc.vars
95
+ source rustc.vars
96
+
97
+ pushd target/release
98
+ else
99
+ # cross build with the specified rustc target
100
+ export target_os=${CROSS_COMPILE_OS}
101
+ export target_arch=${CROSS_COMPILE_TARGET}
102
+
103
+ pushd target/${CROSS_COMPILE_TARGET}/release
104
+ fi
78
105
79
- pushd target/release
80
106
if [ "$RUNNER_OS" == "Windows" ]; then
81
107
export ASSET_NAME="xsnippet-api-${target_arch}-${target_os}.exe.7z"
82
108
7z a $ASSET_NAME xsnippet-api.exe
89
115
90
116
echo "asset_path=target/release/$ASSET_NAME" >> $GITHUB_OUTPUT
91
117
env :
118
+ CROSS_COMPILE_OS : ${{ matrix.os.cross_compile_os }}
119
+ CROSS_COMPILE_TARGET : ${{ matrix.os.cross_compile_target }}
92
120
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
93
121
GH_REPO : ${{ env.GITHUB_REPOSITORY }}
94
122
RELEASE_TAG : ${{ needs.create_release.outputs.release_tag }}
0 commit comments