Skip to content

Try to make binary smaller #39

Try to make binary smaller

Try to make binary smaller #39

Workflow file for this run

name: Linux Build
on:
push:
branches:
- "main"
jobs:
release:
name: Release - ${{ matrix.platform.release_for }}
strategy:
matrix:
platform:
- release_for: linux_x86_64_musl
os: ubuntu-latest
target: x86_64-unknown-linux-musl
bin: ak_monitor_client_rs
command: build
- release_for: linux_x86_64_gnu
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
bin: ak_monitor_client_rs
command: build
- release_for: linux_arm_gnueabi
os: ubuntu-latest
target: arm-unknown-linux-gnueabi
bin: ak_monitor_client_rs
command: build
- release_for: linux_arm_gnueabihf
os: ubuntu-latest
target: arm-unknown-linux-gnueabihf
bin: ak_monitor_client_rs
command: build
- release_for: linux_aarch64_gnu
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
bin: ak_monitor_client_rs
command: build
- release_for: linux_aarch64_musl
os: ubuntu-latest
target: aarch64-unknown-linux-musl
bin: ak_monitor_client_rs
command: build
- release_for: linux_i686_gnu
os: ubuntu-latest
target: i686-unknown-linux-gnu
bin: ak_monitor_client_rs
command: build
- release_for: linux_i686_musl
os: ubuntu-latest
target: i686-unknown-linux-musl
bin: ak_monitor_client_rs
command: build
- release_for: linux_arm_gnueabi
os: ubuntu-latest
target: arm-unknown-linux-gnueabi
bin: ak_monitor_client_rs
command: build
- release_for: linux_arm_musleabi
os: ubuntu-latest
target: arm-unknown-linux-musleabi
bin: ak_monitor_client_rs
command: build
- release_for: linux_arm_musleabihf
os: ubuntu-latest
target: arm-unknown-linux-musleabihf
bin: ak_monitor_client_rs
command: build
- release_for: linux_armv5te_gnu
os: ubuntu-latest
target: armv5te-unknown-linux-gnueabi
bin: ak_monitor_client_rs
command: build
- release_for: linux_armv5te_musl
os: ubuntu-latest
target: armv5te-unknown-linux-musleabi
bin: ak_monitor_client_rs
command: build
- release_for: linux_armv7_gnueabi
os: ubuntu-latest
target: armv7-unknown-linux-gnueabi
bin: ak_monitor_client_rs
command: build
- release_for: linux_armv7_gnueabihf
os: ubuntu-latest
target: armv7-unknown-linux-gnueabihf
bin: ak_monitor_client_rs
command: build
- release_for: linux_armv7_musleabi
os: ubuntu-latest
target: armv7-unknown-linux-musleabi
bin: ak_monitor_client_rs
command: build
- release_for: linux_armv7_musleabihf
os: ubuntu-latest
target: armv7-unknown-linux-musleabihf
bin: ak_monitor_client_rs
command: build
runs-on: ${{ matrix.platform.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Lib
run: sudo apt update && sudo apt install -y musl-tools musl-dev musl upx
- name: Build binary
uses: houseabsolute/actions-rust-cross@v0
with:
command: ${{ matrix.platform.command }}
target: ${{ matrix.platform.target }}
args: "-Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --locked --release"
# args: "--locked --release"
strip: true
toolchain: "nightly"
env:
RUSTFLAGS: "-Zlocation-detail=none"
- name: Install UPX
uses: crazy-max/ghaction-upx@v3
with:
install-only: true
- name: UPX version
run: upx --version
- name: Compress binary
run: upx -v --ultra-brute -o target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}-upxed target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}
- name: Upload binary
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.platform.target }}
path: target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}
- name: Rename binary
run:
cp target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }} target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}-${{ matrix.platform.release_for }}
cp target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}-upxed target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}-${{ matrix.platform.release_for }}-upxed
- name: Publish to GitHub Release
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: softprops/action-gh-release@v1
with:
files: |
target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}-${{ matrix.platform.release_for }}
target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}-${{ matrix.platform.release_for }}-upxed
tag_name: latest # 使用固定的标签名称作为发布版本号
body: |
Latest release for Commit: ${{ github.sha }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}