-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add multi platform support (#9)
* chore: add multi platform support * chore: add multi platform support * chore:fix windows build * fix: steps * fix: remove windows support * fix: rename job * feat: update dependencies and remove verbose logging * fix: profile warning * feat: add release job * feat: add release job * feat: fix build command * feat: fix remove comment * feat: add "v" prefix to tag --------- Co-authored-by: mike <mike@smartive.ch>
- Loading branch information
1 parent
5398aef
commit df0e341
Showing
5 changed files
with
182 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: Release | ||
|
||
env: | ||
PROJECT_NAME: swiss-qr-bill-decoder | ||
CARGO_TERM_COLOR: always | ||
|
||
on: | ||
push: | ||
tags: | ||
# Regex for a version number such as v0.2.1 | ||
- "v[0-9]+.[0-9]+.[0-9]+" | ||
|
||
jobs: | ||
build_and_release: | ||
runs-on: ${{ matrix.platform.runner }} | ||
strategy: | ||
matrix: | ||
platform: | ||
- name: linux-amd64 | ||
runner: ubuntu-latest | ||
target: x86_64-unknown-linux-gnu | ||
- name: macos-amd64 | ||
runner: macos-latest | ||
target: x86_64-apple-darwin | ||
- name: macos-arm64 | ||
runner: macos-latest | ||
target: aarch64-apple-darwin | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Rust | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
targets: "${{ matrix.platform.target }}" | ||
|
||
- name: Rust (Cargo) Caching | ||
uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Install ghostscript (for linux) | ||
uses: awalsh128/cache-apt-pkgs-action@latest | ||
if: matrix.platform.runner == 'ubuntu-latest' | ||
with: | ||
packages: ghostscript | ||
version: 1.0 | ||
|
||
- name: Install ghostscript (for macos) | ||
run: brew install ghostscript | ||
if: matrix.platform.runner == 'macos-latest' | ||
|
||
- name: Run tests | ||
run: cargo test --locked --target ${{ matrix.platform.target }} | ||
|
||
- name: Build release | ||
run: cargo build --release --locked --target ${{ matrix.platform.target }} | ||
|
||
- name: Get the release version from the tag | ||
shell: bash | ||
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | ||
|
||
- name: Build archive | ||
shell: bash | ||
run: | | ||
binary_name="${{env.PROJECT_NAME}}" | ||
dirname="$binary_name-${{ env.VERSION }}-${{ matrix.platform.target }}" | ||
mkdir "$dirname" | ||
mv "target/${{ matrix.platform.target }}/release/$binary_name" "$dirname" | ||
tar -czf "$dirname.tar.gz" "$dirname" | ||
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV | ||
- name: Upload the binaries | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
${{ env.ASSET }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,56 @@ | ||
name: Test | ||
|
||
env: | ||
PROJECT_NAME: swiss-qr-bill-decoder | ||
CARGO_TERM_COLOR: always | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
test: | ||
runs-on: ${{ matrix.platform.runner }} | ||
strategy: | ||
matrix: | ||
platform: | ||
- name: linux-amd64 | ||
runner: ubuntu-latest | ||
target: x86_64-unknown-linux-gnu | ||
- name: macos-amd64 | ||
runner: macos-latest | ||
target: x86_64-apple-darwin | ||
- name: macos-arm64 | ||
runner: macos-latest | ||
target: aarch64-apple-darwin | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
- name: Setup Rust (Cargo) Caching | ||
|
||
- name: Install Rust | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
targets: "${{ matrix.platform.target }}" | ||
|
||
- name: Rust (Cargo) Caching | ||
uses: Swatinem/rust-cache@v2 | ||
- name: Install ghostscript | ||
|
||
- name: Install ghostscript (for linux) | ||
uses: awalsh128/cache-apt-pkgs-action@latest | ||
if: matrix.platform.runner == 'ubuntu-latest' | ||
with: | ||
packages: ghostscript | ||
version: 1.0 | ||
|
||
- name: Install ghostscript (for macos) | ||
run: brew install ghostscript | ||
if: matrix.platform.runner == 'macos-latest' | ||
|
||
- name: Build | ||
run: cargo build --verbose | ||
run: cargo build --locked --target ${{ matrix.platform.target }} | ||
|
||
- name: Run tests | ||
run: cargo test --verbose | ||
run: cargo test --locked --target ${{ matrix.platform.target }} |
Oops, something went wrong.