Compile prebuilt binaries using musl target

So that it is statically linked and does not depend on any dynamic
library and can be run anywhere.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-05-30 17:13:57 +10:00
parent c2aab16940
commit 4e1cb0fdcf
No known key found for this signature in database
GPG key ID: 591C0B03040416D6

View file

@ -19,7 +19,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
include: include:
- target: x86_64-unknown-linux-gnu - target: x86_64-unknown-linux-musl
os: ubuntu-latest os: ubuntu-latest
output: cargo-binstall output: cargo-binstall
archive: tgz archive: tgz
@ -27,7 +27,7 @@ jobs:
os: macos-latest os: macos-latest
output: cargo-binstall output: cargo-binstall
archive: zip archive: zip
- target: armv7-unknown-linux-gnueabihf - target: armv7-unknown-linux-musleabihf
os: ubuntu-20.04 os: ubuntu-20.04
output: cargo-binstall output: cargo-binstall
archive: tgz archive: tgz
@ -48,7 +48,7 @@ jobs:
override: true override: true
- name: Install openssl (apt armv7) - name: Install openssl (apt armv7)
if: ${{ matrix.target == 'armv7-unknown-linux-gnueabihf' }} if: ${{ matrix.target == 'armv7-unknown-linux-musleabihf' }}
uses: ryankurte/action-apt@v0.3.0 uses: ryankurte/action-apt@v0.3.0
with: with:
arch: armhf arch: armhf
@ -65,15 +65,23 @@ jobs:
target target
- name: Install cross toolchain (armv7) - name: Install cross toolchain (armv7)
if: ${{ matrix.target == 'armv7-unknown-linux-gnueabihf' }} if: ${{ matrix.target == 'armv7-unknown-linux-musleabihf' }}
run: sudo apt install gcc-arm-linux-gnueabihf run: sudo apt install gcc-arm-linux-musleabihf
- name: Enable cross compilation (armv7) - name: Enable cross compilation (armv7)
if: ${{ matrix.target == 'armv7-unknown-linux-gnueabihf' }} if: ${{ matrix.target == 'armv7-unknown-linux-musleabihf' }}
run: | run: |
echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
echo "LZMA_API_STATIC=1" >> $GITHUB_ENV echo "LZMA_API_STATIC=1" >> $GITHUB_ENV
- name: Install musl-tools
if: ${{ matrix.target == 'armv7-unknown-linux-musleabihf' }}
run: sudo apt-get install -y musl-tools
- name: Install musl-tools
if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }}
run: sudo apt-get install -y musl-tools
- name: Build release - name: Build release
uses: actions-rs/cargo@v1 uses: actions-rs/cargo@v1
with: with: