Skip to content

Commit

Permalink
Merge pull request #1 from mattclement/static-build
Browse files Browse the repository at this point in the history
Use musl builder for statically linked binaries
  • Loading branch information
mattclement authored Jul 2, 2022
2 parents bd585cf + 0d3bf39 commit e3ce6d5
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ jobs:
strategy:
matrix:
include:
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
Expand All @@ -34,11 +36,24 @@ jobs:
key: ${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('**/Cargo.toml') }}

- name: Add rustup target
if: matrix.target != 'x86_64-unknown-linux-musl'
run: rustup target add ${{ matrix.target }}

- name: Build ${{ matrix.target }}
if: matrix.target != 'x86_64-unknown-linux-musl'
run: cargo build --release --target=${{ matrix.target }}

- name: Build static ${{ matrix.target }}
if: matrix.target == 'x86_64-unknown-linux-musl'
run: |
mkdir -p ~/.cargo/{git,registry}
docker run --rm -t \
--mount type=bind,source=${{ github.workspace }},target=/volume \
--mount type=bind,source=$HOME/.cargo/registry,target=/root/.cargo/registry \
--mount type=bind,source=$HOME/.cargo/git,target=/root/.cargo/git \
clux/muslrust:stable \
cargo build --release
- name: Create tar.gz
run: tar -czvf tfreg_${{ matrix.target }}.tar.gz -C target/${{ matrix.target }}/release tfreg

Expand Down

0 comments on commit e3ce6d5

Please sign in to comment.