Skip to content

ci: 调整输出格式避免错误 #35

ci: 调整输出格式避免错误

ci: 调整输出格式避免错误 #35

Workflow file for this run

name: Build and Release
on:
push:
tags: [ '*' ] # 推送标签时触发
permissions:
contents: write
env:
env_version: 1.0.0
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
outputs:
COMMIT_MESSAGE: ${{ steps.commit_message.outputs.COMMIT_MESSAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4

Check failure on line 52 in .github/workflows/release.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/release.yaml

Invalid workflow file

You have an error in your yaml syntax on line 52
- name: Get commit messages
id: commit_message
shell: bash
run: |
git fetch --tags
LATEST_TAG=$(git describe --tags --abbrev=0)
PREVIOUS_TAG=$(git tag | tail -n2 | head -n1)
# echo "> Automatically generated by the GitHub Action" > commit.log
# echo "" >> commit.log
git log $PREVIOUS_TAG...$LATEST_TAG --pretty=format:"%h - %s" -5 > commit.log
echo "===== Commit file ====="
cat commit.log
echo "====== files end ======"
echo "COMMIT_MESSAGE=$(cat commit.log)" >> $GITHUB_OUTPUT
- 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:
body: ${{ env.COMMIT_MESSAGE }}
files: |
archive/${{ matrix.archive-name }}
token: ${{ secrets.GITHUB_TOKEN }}