Skip to content

Commit

Permalink
Musl support (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-engel authored Aug 21, 2024
1 parent c1e7181 commit 1d7cc99
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 71 deletions.
50 changes: 24 additions & 26 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,47 @@ on:

jobs:
publish:
name: Publishing for ${{ matrix.os }}
name: Publishing for ${{ matrix.os }}::${{ matrix.label }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
rust: [stable]
include:
- os: macos-latest
artifact_prefix: macOS
target: x86_64-apple-darwin
binary_postfix: ""
label: x86_64
- os: ubuntu-latest
artifact_prefix: linux
target: x86_64-unknown-linux-gnu
binary_postfix: ""
label: x86_64 gnu
- os: ubuntu-latest
artifact_prefix: linux-musl
target: x86_64-unknown-linux-musl
binary_postfix: ""
label: x86_64 musl
- os: windows-latest
artifact_prefix: windows
target: x86_64-pc-windows-msvc
binary_postfix: ".exe"
label: x86_64

steps:
- name: Installing Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
profile: minimal
override: true
- name: Checkout repository
uses: actions/checkout@v2
- name: Cargo build
uses: actions-rs/cargo@v1
uses: actions/checkout@v4
- name: Install Rust
run: rustup update --no-self-update
- name: Install target
run: rustup target add ${{ matrix.target }}
- name: Install musl-tools
if: ${{ runner.os == 'Linux' }}
uses: awalsh128/cache-apt-pkgs-action@v1
with:
command: build
toolchain: ${{ matrix.rust }}
args: --release --target ${{ matrix.target }}

packages: musl-tools # provides musl-gcc
version: 1.0
- name: Cargo build
run: cargo build --target=${{ matrix.target }} --release
- name: Packaging final binary
shell: bash
run: |
Expand All @@ -69,12 +73,6 @@ jobs:
name: Publishing to Cargo
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: publish
args: --token ${{ secrets.CARGO_API_KEY }} --allow-dirty
- uses: actions/checkout@v4
- run: rustup update --no-self-update
- run: cargo publish --token=${{ secrets.CARGO_API_KEY }} --allow-dirty
67 changes: 28 additions & 39 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,75 +1,64 @@
on: [push, pull_request]
name: Continuous Integration

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: Test Suite on ${{ matrix.os }}
name: Test on ${{ matrix.os }}::${{ matrix.label }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
rust: [stable]
include:
- os: macos-latest
artifact_prefix: macOS
target: x86_64-apple-darwin
binary_postfix: ""
label: x86_64
- os: ubuntu-latest
artifact_prefix: linux
target: x86_64-unknown-linux-gnu
binary_postfix: ""
label: x86_64 gnu
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
label: x86_64 musl
- os: windows-latest
artifact_prefix: windows
target: x86_64-pc-windows-msvc
binary_postfix: ".exe"
label: x86_64

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
run: rustup update --no-self-update
- name: Install target
run: rustup target add ${{ matrix.target }}
- name: Install musl-tools
if: ${{ runner.os == 'Linux' }}
uses: awalsh128/cache-apt-pkgs-action@v1
with:
toolchain: stable
profile: minimal
override: true
- uses: actions-rs/cargo@v1
with:
command: test
packages: musl-tools # provides musl-gcc
version: 1.0
- name: Test
run: cargo test --target=${{ matrix.target }}

rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
components: rustfmt
run: rustup update --no-self-update
- name: Check formatting
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
run: cargo fmt --all -- --check

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
components: clippy
run: rustup update --no-self-update
- name: Clippy Check
uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
run: cargo clippy -- -D warnings
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ scoop install jwt-cli
pacman -S jwt-cli
```

## Alpine linux

Unfortunately due to [static linking problems](https://github.com/mike-engel/jwt-cli/issues/194#issuecomment-1169211709) when compiling this project, `jwt-cli` can't run on alpine linux natively.

A workaround is to run it inside a rust docker container rather than using `sh` within alpine.

# Usage

For usage info, use the `help` command.
Expand Down

0 comments on commit 1d7cc99

Please sign in to comment.