Skip to content

build: Upgrade Rust toolchain #272

build: Upgrade Rust toolchain

build: Upgrade Rust toolchain #272

Workflow file for this run

name: Rust
on:
push:
branches:
- main
pull_request:
branches:
- main
release:
types:
- published
env:
CARGO_TERM_COLOR: always
jobs:
checks:
runs-on: ubuntu-22.04
permissions:
checks: write
contents: read
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install latest stable
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt,clippy
- uses: Swatinem/rust-cache@v2
- name: Install libpcsclite
run: sudo apt update && sudo apt install libpcsclite-dev
# - run: rm -f rust-toolchain.toml
- name: Run clippy
run: cargo +stable clippy --workspace --exclude jpki-ffi-generic
# - name: Run clippy
# uses: auguwu/[email protected]
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# check-args: --workspace,--exclude,jpki-ffi-generic
- name: Run rustfmt
run: cargo +stable fmt --all --check
- name: Run tests
run: cargo +stable test --workspace --exclude jpki-ffi-generic --exclude jpki-ffi-android --verbose
checks-nightly:
runs-on: ubuntu-22.04
permissions:
checks: write
contents: read
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install nightly-2023-10-20
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2023-10-20
components: rustfmt,clippy
- uses: Swatinem/rust-cache@v2
- name: Install libpcsclite
run: sudo apt update && sudo apt install libpcsclite-dev
- name: Run clippy
run: cargo clippy -p jpki-ffi-generic
# - name: Run clippy
# uses: auguwu/[email protected]
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# check-args: --workspace,--exclude,jpki-ffi-generic
- name: Run tests
run: cargo test -p jpki-ffi-generic --verbose
build:
needs:
- checks
strategy:
matrix:
target:
- x86_64-pc-windows-msvc
- x86_64-apple-darwin
- aarch64-apple-darwin
- x86_64-unknown-linux-gnu
- aarch64-linux-android
- armv7-linux-androideabi
features:
- '--no-default-features'
- '--features tracing'
include:
- target: x86_64-pc-windows-msvc
host: windows-2022
artifact: jpki-cli.exe
cli: true
android: false
additionalFeatures: '--features pcsc'
- target: x86_64-apple-darwin
host: macos-13-large
artifact: jpki-cli
cli: true
android: false
additionalFeatures: '--features pcsc'
- target: aarch64-apple-darwin
host: macos-13-xlarge
artifact: jpki-cli
cli: true
android: false
additionalFeatures: '--features pcsc'
- target: x86_64-unknown-linux-gnu
host: ubuntu-22.04
artifact: jpki-cli
cli: true
android: false
- target: aarch64-linux-android
host: ubuntu-22.04
cli: false
android: true
- target: armv7-linux-androideabi
host: ubuntu-22.04
cli: false
android: true
runs-on: ${{ matrix.host }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install latest stable
uses: dtolnay/rust-toolchain@stable
- id: cache-key
run: echo "::set-output name=key::$(echo '${{ toJSON(matrix) }}' | shasum -a 256)"
- uses: Swatinem/rust-cache@v2
with:
key: ${{ steps.cache-key.outputs.key }}
- name: Install libpcsclite
if: ${{ matrix.cli && startsWith(matrix.host, 'ubuntu-') }}
run: sudo apt update && sudo apt install libpcsclite-dev
- name: Install Android NDK
if: ${{ matrix.android }}
run: |
wget https://dl.google.com/android/repository/android-ndk-r25c-linux.zip
sha1sum android-ndk-r25c-linux.zip | grep '53af80a1cce9144025b81c78c8cd556bff42bd0e'
unzip android-ndk-r25c-linux.zip
echo "ANDROID_NDK_HOME=${PWD}/android-ndk-r25c" >> $GITHUB_ENV
- name: Install cargo-ndk
if: ${{ matrix.android }}
run: cargo install cargo-ndk
- name: Build (Core)
run: cargo +stable build --verbose --release --target=${{ matrix.target }} ${{ matrix.features }} ${{ matrix.additionalFeatures }} -p jpki
- name: Build (CLI)
if: ${{ matrix.cli }}
run: cargo +stable build --verbose --release --target=${{ matrix.target }} -p jpki-cli
- name: Build (Android)
if: ${{ matrix.android }}
run: cargo ndk --target=${{ matrix.target }} build --verbose --release -p jpki-ffi-android
- name: Compress artifacts into .tar.gz file
if: ${{ matrix.cli }}
run: tar -C ./target/${{ matrix.target }}/release -czf jpki-cli-${{ matrix.target }}.tar.gz ${{ matrix.artifact }}
- uses: actions/upload-artifact@v3
if: ${{ matrix.cli }}
with:
path: jpki-cli-${{ matrix.target }}.tar.gz
- uses: svenstaro/upload-release-action@v2
if: ${{ github.event_name == 'release' && matrix.cli }}
with:
file: jpki-cli-${{ matrix.target }}.tar.gz
overwrite: true
build-nightly:
needs:
- checks-nightly
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install nightly-2023-10-20
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2023-10-20
components: rustfmt,clippy
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.features }}
- name: Install libpcsclite
run: sudo apt update && sudo apt install libpcsclite-dev
- name: Build (FFI/Generic)
run: cargo build --verbose --release --all-features -p jpki-ffi-generic
deploy:
runs-on: ubuntu-22.04
if: ${{ github.event_name == 'release' }}
needs:
- build
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install latest stable
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Install libpcsclite
run: sudo apt update && sudo apt install libpcsclite-dev
- name: Log into crates.io
run: cargo login ${{ secrets.CRATES_IO_TOKEN }}
- name: Publish to crates.io (Core)
run: cargo publish --verbose --allow-dirty -p jpki
- name: Publish to crates.io (CLI)
run: |
until cargo publish --verbose --allow-dirty -p jpki-cli
do
echo "Still waiting..."
sleep 5
done
- name: Publish to crates.io (FFI/Generic)
run: cargo publish --verbose --allow-dirty -p jpki-ffi-generic