145 lines
4.1 KiB
YAML
145 lines
4.1 KiB
YAML
name: Build
|
|
|
|
on:
|
|
push:
|
|
paths-ignore:
|
|
- '*.md'
|
|
- 'LICENSE*'
|
|
pull_request:
|
|
|
|
env:
|
|
BUILD_PROFILE: release
|
|
CARGO_TARGET_DIR: target
|
|
CARGO_INCREMENTAL: 0
|
|
|
|
jobs:
|
|
check:
|
|
name: Check
|
|
runs-on: windows-latest
|
|
env:
|
|
RUSTFLAGS: -D warnings
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Setup Rust toolchain
|
|
uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
components: clippy
|
|
toolchain: nightly-2023-09-18
|
|
- name: Cache Rust workspace
|
|
uses: Swatinem/rust-cache@v2
|
|
- name: Cargo check
|
|
run: cargo check --features debug --all-targets
|
|
- name: Cargo clippy
|
|
run: cargo clippy --features debug --all-targets
|
|
|
|
fmt:
|
|
name: Format
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
RUSTFLAGS: -D warnings
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Setup Rust toolchain
|
|
# We use nightly options in rustfmt.toml
|
|
uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
components: rustfmt
|
|
toolchain: nightly-2023-09-18
|
|
- name: Cargo fmt
|
|
run: cargo fmt --all --check
|
|
|
|
build:
|
|
name: Build
|
|
env:
|
|
CARGO_BIN_NAME: sjiswrap
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- platform: windows-latest
|
|
target: i686-pc-windows-msvc
|
|
name: windows-x86
|
|
fail-fast: false
|
|
runs-on: ${{ matrix.platform }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Setup Rust toolchain
|
|
uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
components: rust-src
|
|
targets: ${{ matrix.target }}
|
|
toolchain: nightly-2023-09-18
|
|
- name: Cache Rust workspace
|
|
uses: Swatinem/rust-cache@v2
|
|
with:
|
|
key: ${{ matrix.target }}
|
|
- name: Cargo build
|
|
run: >
|
|
cargo build --profile ${{ env.BUILD_PROFILE }} --target ${{ matrix.target }}
|
|
--bin ${{ env.CARGO_BIN_NAME }} -Z build-std=std,panic_abort --features nightly
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ env.CARGO_BIN_NAME }}-${{ matrix.name }}
|
|
path: |
|
|
${{ env.CARGO_TARGET_DIR }}/${{ matrix.target }}/${{ env.BUILD_PROFILE }}/${{ env.CARGO_BIN_NAME }}
|
|
${{ env.CARGO_TARGET_DIR }}/${{ matrix.target }}/${{ env.BUILD_PROFILE }}/${{ env.CARGO_BIN_NAME }}.exe
|
|
if-no-files-found: error
|
|
|
|
release:
|
|
name: Release
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
runs-on: ubuntu-latest
|
|
needs: [ build ]
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Check git tag against Cargo version
|
|
shell: bash
|
|
run: |
|
|
set -eou pipefail
|
|
tag='${{github.ref}}'
|
|
tag="${tag#refs/tags/}"
|
|
version=$(grep '^version' Cargo.toml | head -1 | awk -F' = ' '{print $2}' | tr -d '"')
|
|
version="v$version"
|
|
if [ "$tag" != "$version" ]; then
|
|
echo "::error::Git tag doesn't match the Cargo version! ($tag != $version)"
|
|
exit 1
|
|
fi
|
|
- name: Download artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: artifacts
|
|
- name: Rename artifacts
|
|
working-directory: artifacts
|
|
run: |
|
|
set -euo pipefail
|
|
mkdir ../out
|
|
for dir in */; do
|
|
for file in "$dir"*; do
|
|
base=$(basename "$file")
|
|
name="${base%.*}"
|
|
ext="${base##*.}"
|
|
if [ "$ext" = "$base" ]; then
|
|
ext=""
|
|
else
|
|
ext=".$ext"
|
|
fi
|
|
arch="${dir%/}" # remove trailing slash
|
|
arch="${arch##"$name-"}" # remove bin name
|
|
dst="../out/${name}-${arch}${ext}"
|
|
mv "$file" "$dst"
|
|
done
|
|
done
|
|
ls -R ../out
|
|
- name: Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
files: out/*
|
|
draft: true
|
|
generate_release_notes: true
|