Skip to content

Commit

Permalink
Use Cross and build MUSL
Browse files Browse the repository at this point in the history
  • Loading branch information
rcook committed Apr 11, 2023
1 parent 7e0586a commit 5b687b3
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 24 deletions.
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ rustflags = ["-C", "target-feature=+crt-static"]

[target.x86_64-unknown-linux-gnu]
rustflags = ["-C", "target-feature=+crt-static"]

[target.x86_64-unknown-linux-musl]
rustflags = ["-C", "target-feature=+crt-static"]
28 changes: 20 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: CI

env:
CARGO_TERM_COLOR: always
project: isopy

on:
Expand All @@ -12,7 +11,7 @@ on:
branches:
- main
schedule:
- cron: 0 0 * * SUN
- cron: 0 5 * * *

jobs:
ci:
Expand All @@ -30,18 +29,31 @@ jobs:
- target: x86_64-unknown-linux-gnu
host_os: ubuntu-latest
runs-on: ${{ matrix.host_os }}
env:
cargo: cargo
CARGO_TERM_COLOR: always
steps:
- name: Set variables
shell: bash
run: echo "target_flags=--target ${{ matrix.target }}" >> $GITHUB_ENV

- name: Check out
uses: actions/checkout@v3

- name: Build (debug)
run: cargo build --verbose --target ${{ matrix.target }}
run: ${{ env.cargo }} build --verbose ${{ env.target_flags }}

- name: Run tests (debug)
run: cargo test --verbose --target ${{ matrix.target }}
run: ${{ env.cargo }} test --verbose ${{ env.target_flags }}

- name: Build (release)
run: cargo build --verbose --release --target ${{ matrix.target }}
run: ${{ env.cargo }} build --verbose --release ${{ env.target_flags }}

- name: Run tests (release)
run: cargo test --verbose --release --target ${{ matrix.target }}
run: ${{ env.cargo }} test --verbose --release ${{ env.target_flags }}

- name: Run Clippy
run: cargo clippy --target ${{ matrix.target }}
run: ${{ env.cargo }} clippy ${{ env.target_flags }}

- name: Run fmt
run: cargo fmt --check
run: ${{ env.cargo }} fmt --check
46 changes: 30 additions & 16 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
name: Release

permissions:
contents: write

env:
CARGO_TERM_COLOR: always
project: isopy

permissions:
contents: write

on:
push:
tags:
Expand All @@ -20,7 +19,7 @@ jobs:
- aarch64-apple-darwin
- x86_64-apple-darwin
- x86_64-pc-windows-msvc
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
include:
- target: aarch64-apple-darwin
host_os: macos-latest
Expand All @@ -34,23 +33,29 @@ jobs:
host_os: windows-latest
executable_ext: .exe
archive_ext: .zip
- target: x86_64-unknown-linux-gnu
- target: x86_64-unknown-linux-musl
host_os: ubuntu-latest
executable_ext:
archive_ext: .tar.gz
runs-on: ${{ matrix.host_os }}
env:
cargo: cargo
CARGO_TERM_COLOR: always
steps:
- name: Set variables (Windows)
if: ${{ matrix.host_os == 'windows-latest' }}
run: |
echo "archive_file_name=${{ env.project }}-${{ github.ref_name }}-${{ matrix.target }}${{ matrix.archive_ext }}" >> $env:GITHUB_ENV
echo "ISOPY_VERSION=${{ github.ref_name }}" >> $env:GITHUB_ENV
- name: Set variables (Linux/macOS)
if: ${{ matrix.host_os != 'windows-latest' }}
- name: Set variables
shell: bash
run: |
echo "archive_file_name=${{ env.project }}-${{ github.ref_name }}-${{ matrix.target }}${{ matrix.archive_ext }}" >> $GITHUB_ENV
echo "ISOPY_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Install Cross
shell: bash
run: |
cargo install cross
echo "cargo=cross" >> $GITHUB_ENV
echo "target_flags=--target ${{ matrix.target }}" >> $GITHUB_ENV
echo "target_dir=target/${{ matrix.target }}" >> $GITHUB_ENV
- name: Check out
uses: actions/checkout@v3

Expand All @@ -61,14 +66,23 @@ jobs:
targets: ${{ matrix.target }}

- name: Build
run: cargo build --release --target ${{ matrix.target }}
run: ${{ env.cargo }} build --release ${{ env.target_flags }}

- name: Create archive (Windows)
if: ${{ matrix.host_os == 'windows-latest' }}
run: Compress-Archive -DestinationPath ${{ env.archive_file_name }} -LiteralPath target\${{ matrix.target }}\release\${{ env.project}}${{ matrix.executable_ext }}
shell: pwsh
run: |
Compress-Archive `
-DestinationPath ${{ env.archive_file_name }} `
-LiteralPath ${{ env.target_dir }}/release/${{ env.project}}${{ matrix.executable_ext }}
- name: Create archive (Linux/macOS)
if: ${{ matrix.host_os != 'windows-latest' }}
run: tar -C target/${{ matrix.target }}/release -czf ${{ env.archive_file_name }} ${{ env.project}}${{ matrix.executable_ext }}
shell: bash
run: |
tar \
-C ${{ env.target_dir }}/release \
-czf \
${{ env.archive_file_name }} ${{ env.project}}${{ matrix.executable_ext }}
- name: Create release
id: create_release
Expand Down

0 comments on commit 5b687b3

Please sign in to comment.