Skip to content

fix: 修复log输出,创建配置文件bug #60

fix: 修复log输出,创建配置文件bug

fix: 修复log输出,创建配置文件bug #60

Workflow file for this run

name: Build and Release
on:
push:
tags: [ '*.*.*' ] # 推送合法的版本号的时候触发(支持携带后缀)
workflow_dispatch: # 手动触发
permissions:
contents: write
jobs:
build:
name: build
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [ x86_64-linux,x86_64-windows,x86_64-macos,aarch64-macos ]
include:
- build: x86_64-linux
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-gnu
archive-name: maimai-search-${{ github.ref_name }}-linux-x86_64.tar.gz
- build: x86_64-macos
os: macos-latest
rust: nightly
target: x86_64-apple-darwin
archive-name: maimai-search-${{ github.ref_name }}-macos-x86_64.tar.gz
- build: x86_64-windows
os: windows-latest
rust: nightly-x86_64-msvc
target: x86_64-pc-windows-msvc
archive-name: maimai-search-${{ github.ref_name }}-windows-x86_64.7z
- build: aarch64-macos
os: macos-latest
rust: stable
target: aarch64-apple-darwin
archive-name: maimai-search-${{ github.ref_name }}-macos-aarch64.tar.gz
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get commit messages
if: startsWith(github.ref, 'refs/tags/')
id: commit_message
shell: bash
run: |
git fetch --tags
echo "::set-output name=message::$(git log --pretty=format:"%h - %s")"
- name: Rust Cache
uses: Swatinem/[email protected]
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
target: ${{ matrix.target }}
- name: Build binary
run: |
cargo build --verbose --release --target ${{ matrix.target }}
env:
RUST_BACKTRACE: 1
- name: Strip binary (linux and macos)
if: matrix.build == 'aarch64-macos' || matrix.build == 'x86_64-macos' || matrix.build == 'x86_64-linux'
run: strip "target/${{ matrix.target }}/release/maimai-search"
- name: Build archive
if: startsWith(github.ref, 'refs/tags/')
shell: bash
run: |
mkdir archive
cp LICENSE README.md archive/
cd archive
if [ "${{ matrix.build }}" = "x86_64-windows" ]; then
cp "../target/${{ matrix.target }}/release/maimai-search.exe" ./
7z a "${{ matrix.archive-name }}" LICENSE README.md maimai-search.exe
else
cp "../target/${{ matrix.target }}/release/maimai-search" ./
tar -czf "${{ matrix.archive-name }}" LICENSE README.md maimai-search
fi
- name: Upload archive
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v1
with:
name: ${{ matrix.archive-name }}
path: archive/${{ matrix.archive-name }}
- name: Create Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
name: Release ${{ github.ref_name }}
body: ${{ steps.commit_message.outputs.message }}
files: |
archive/${{ matrix.archive-name }}
token: ${{ secrets.GITHUB_TOKEN }}