feat: 添加PID文件管理功能,防止服务器重复启动 fix #1 #9
Workflow file for this run
This file contains hidden or 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: Generate Rust Binaries and Create Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| # 添加权限配置 | |
| permissions: | |
| contents: write | |
| packages: write | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build: | |
| name: Build ${{ matrix.target }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| name: shortlinker-linux-x86_64 | |
| - target: aarch64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| name: shortlinker-linux-aarch64 | |
| - target: i686-unknown-linux-gnu | |
| os: ubuntu-latest | |
| name: shortlinker-linux-i686 | |
| - target: x86_64-pc-windows-gnu | |
| os: ubuntu-latest | |
| name: shortlinker-windows-x86_64.exe | |
| - target: x86_64-apple-darwin | |
| os: macos-latest | |
| name: shortlinker-macos-x86_64 | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| name: shortlinker-macos-aarch64 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Install cross | |
| if: matrix.os == 'ubuntu-latest' | |
| run: cargo install cross --git https://github.com/cross-rs/cross | |
| - name: Build with cross (Linux targets) | |
| if: matrix.os == 'ubuntu-latest' | |
| run: cross build --release --target ${{ matrix.target }} | |
| - name: Build native (macOS targets) | |
| if: matrix.os == 'macos-latest' | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Rename binary | |
| run: | | |
| if [ "${{ matrix.os }}" = "ubuntu-latest" ] && [ "${{ matrix.target }}" = "x86_64-pc-windows-gnu" ]; then | |
| mv target/${{ matrix.target }}/release/shortlinker.exe ${{ matrix.name }} | |
| else | |
| mv target/${{ matrix.target }}/release/shortlinker ${{ matrix.name }} | |
| fi | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.name }} | |
| path: ${{ matrix.name }} | |
| release: | |
| name: Create Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Create release directory | |
| run: | | |
| mkdir -p release | |
| find artifacts -type f -exec cp {} release/ \; | |
| - name: Generate checksums | |
| run: | | |
| cd release | |
| sha256sum * > checksums.txt | |
| - name: Get tag name | |
| id: tag | |
| run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.tag.outputs.tag }} | |
| name: Release ${{ steps.tag.outputs.tag }} | |
| body: | | |
| ## 🚀 Release ${{ steps.tag.outputs.tag }} | |
| ### 📦 下载 | |
| 点击下方链接直接下载适合您系统的二进制文件: | |
| | 平台 | 架构 | 下载链接 | | |
| |------|------|----------| | |
| | 🐧 Linux | x86_64 | [shortlinker-linux-x86_64](https://github.com/AptS-1547/shortlinker/releases/download/${{ steps.tag.outputs.tag }}/shortlinker-linux-x86_64) | | |
| | 🐧 Linux | ARM64 | [shortlinker-linux-aarch64](https://github.com/AptS-1547/shortlinker/releases/download/${{ steps.tag.outputs.tag }}/shortlinker-linux-aarch64) | | |
| | 🐧 Linux | i686 | [shortlinker-linux-i686](https://github.com/AptS-1547/shortlinker/releases/download/${{ steps.tag.outputs.tag }}/shortlinker-linux-i686) | | |
| | 🪟 Windows | x86_64 | [shortlinker-windows-x86_64.exe](https://github.com/AptS-1547/shortlinker/releases/download/${{ steps.tag.outputs.tag }}/shortlinker-windows-x86_64.exe) | | |
| | 🍎 macOS | Intel | [shortlinker-macos-x86_64](https://github.com/AptS-1547/shortlinker/releases/download/${{ steps.tag.outputs.tag }}/shortlinker-macos-x86_64) | | |
| | 🍎 macOS | Apple Silicon | [shortlinker-macos-aarch64](https://github.com/AptS-1547/shortlinker/releases/download/${{ steps.tag.outputs.tag }}/shortlinker-macos-aarch64) | | |
| ### ✅ 校验 | |
| 📋 [下载 checksums.txt](https://github.com/AptS-1547/shortlinker/releases/download/${{ steps.tag.outputs.tag }}/checksums.txt) 来验证二进制文件的完整性。 | |
| ### 📚 使用说明 | |
| 详细使用说明请参考 [README.md](https://github.com/AptS-1547/shortlinker/blob/main/README.md) | |
| files: | | |
| release/* | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |