feat: 发布0.4.0版本,替换SQLite #54
Workflow file for this run
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: Build and Release | |
on: | |
push: | |
tags: [ '*.*.*' ] # 推送合法的版本号的时候触发(支持携带后缀) | |
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: nightly | |
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: nightly | |
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 | |
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 | |
override: true | |
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 | |
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 | |
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 }} |