chore: fix CI and clippy warning #37
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
name: "Release" | |
on: | |
push: | |
branches: | |
- main | |
- test | |
tags: | |
- v* | |
# release: | |
# types: [created] | |
jobs: | |
compile: | |
name: release ${{ matrix.target }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- target: x86_64-pc-windows-gnu | |
os: windows-2019 | |
cross: false | |
# archive: zip | |
#- target: x86_64-unknown-linux-musl | |
# os: ubuntu-latest | |
# cross: false | |
# # archive: tar.gz tar.xz | |
#- target: aarch64-unknown-linux-musl | |
# os: ubuntu-latest | |
# cross: true | |
#- target: x86_64-apple-darwin | |
# os: macos-latest | |
# cross: false | |
# # archive: zip | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
target: ${{ matrix.target }} | |
override: true | |
profile: minimal | |
- name: Build with cargo | |
run: cargo build --features bin-build --bin zhconv --release --target ${{ matrix.target }} | |
if: matrix.cross == false | |
- name: Build with cross | |
run: | | |
cargo install cross --git https://github.com/cross-rs/cross.git | |
cross build --features bin-build --bin zhconv --release --target ${{ matrix.target }} | |
if: matrix.cross == true | |
# some error with the default cross version | |
# - uses: actions-rs/cargo@v1 | |
# with: | |
# command: build | |
# args: --features bin-build --bin zhconv --release --target ${{ matrix.target }} | |
# use-cross: ${{ matrix.cross }} | |
- name: Prepare asset | |
shell: bash # on win, the default is ps | |
run: | | |
mkdir bin | |
if [ "${{ matrix.os }}" = "windows-2019" ]; then | |
# 7z a "$staging.zip" "$staging" | |
f="bin/zhconv-${{ matrix.target }}.exe" | |
mv target/${{ matrix.target }}/release/zhconv.exe "$f" | |
else | |
# tar czf "$staging.tar.gz" "$staging" | |
f="bin/zhconv-${{ matrix.target }}" | |
mv target/${{ matrix.target }}/release/zhconv "$f" | |
fi | |
strip -v "$f" || echo "strip failed" | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: binaries | |
path: bin/ | |
release: | |
runs-on: ubuntu-latest | |
if: "startsWith(github.ref, 'refs/tags/')" | |
needs: [compile] | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: binaries | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: | | |
* |