fix(windows): 正确处理存储加载错误 #80
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: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| permissions: | |
| contents: write | |
| packages: write | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build-frontend: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '24' | |
| - name: Build frontend | |
| working-directory: admin-panel | |
| run: | | |
| npm install -g bun@latest | |
| bun install --frozen-lockfile | |
| bun run build | |
| - name: Package frontend | |
| run: | | |
| VERSION="${GITHUB_REF#refs/tags/}" | |
| tar -czf "shortlinker-admin-panel_${VERSION}.tar.gz" -C admin-panel/dist . | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: frontend-dist | |
| path: admin-panel/dist | |
| retention-days: 1 | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: frontend-package | |
| path: shortlinker-admin-panel_*.tar.gz | |
| retention-days: 1 | |
| build-linux-windows: | |
| needs: build-frontend | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| include: | |
| - target: x86_64-unknown-linux-musl | |
| name: linux_x86_64 | |
| packages: musl-tools | |
| - target: x86_64-pc-windows-gnu | |
| name: windows_x86_64.exe | |
| packages: gcc-mingw-w64-x86-64 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: frontend-dist | |
| path: admin-panel/dist | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: ${{ matrix.target }} | |
| - name: Install dependencies | |
| run: sudo apt-get update && sudo apt-get install -y ${{ matrix.packages }} | |
| - name: Configure linker | |
| run: | | |
| case "${{ matrix.target }}" in | |
| x86_64-unknown-linux-musl) | |
| echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc" >> $GITHUB_ENV | |
| ;; | |
| x86_64-pc-windows-gnu) | |
| echo "CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER=x86_64-w64-mingw32-gcc" >> $GITHUB_ENV | |
| ;; | |
| esac | |
| - name: Build | |
| run: | | |
| RUSTFLAGS="-C target-feature=+crt-static -C link-arg=-s" \ | |
| cargo build --release --target ${{ matrix.target }} --all-features | |
| - name: Rename binary | |
| run: | | |
| VERSION="${GITHUB_REF#refs/tags/}" | |
| SRC="target/${{ matrix.target }}/release/shortlinker" | |
| [[ "${{ matrix.target }}" == *windows* ]] && SRC="${SRC}.exe" | |
| mv "$SRC" "shortlinker_${VERSION}_${{ matrix.name }}" | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: binary-${{ matrix.name }} | |
| path: shortlinker_* | |
| build-arm64: | |
| needs: build-frontend | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: frontend-dist | |
| path: admin-panel/dist | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: aarch64-unknown-linux-gnu | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: aarch64-unknown-linux-gnu | |
| - name: Install ARM64 toolchain | |
| run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu | |
| - name: Build | |
| env: | |
| CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc | |
| RUSTFLAGS: "-C target-feature=+crt-static -C link-arg=-s" | |
| run: cargo build --release --target aarch64-unknown-linux-gnu --all-features | |
| - name: Rename binary | |
| run: | | |
| VERSION="${GITHUB_REF#refs/tags/}" | |
| mv target/aarch64-unknown-linux-gnu/release/shortlinker "shortlinker_${VERSION}_linux_aarch64" | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: binary-linux_aarch64 | |
| path: shortlinker_* | |
| build-macos: | |
| needs: build-frontend | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: frontend-dist | |
| path: admin-panel/dist | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: aarch64-apple-darwin | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: aarch64-apple-darwin | |
| - name: Build | |
| env: | |
| RUSTFLAGS: "-C link-arg=-s" | |
| run: cargo build --release --target aarch64-apple-darwin --all-features | |
| - name: Rename binary | |
| run: | | |
| VERSION="${GITHUB_REF#refs/tags/}" | |
| mv target/aarch64-apple-darwin/release/shortlinker "shortlinker_${VERSION}_macos_aarch64" | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: binary-macos_aarch64 | |
| path: shortlinker_* | |
| release: | |
| needs: [build-linux-windows, build-arm64, build-macos] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Prepare release files | |
| run: | | |
| mkdir -p release | |
| find artifacts -type f \( -name "shortlinker_*" -o -name "*.tar.gz" \) -exec cp {} release/ \; | |
| cd release && sha256sum * > checksums.txt | |
| - name: Extract changelog | |
| id: changelog | |
| run: | | |
| VERSION="${GITHUB_REF#refs/tags/}" | |
| # 从 CHANGELOG.md 提取当前版本的内容 | |
| CONTENT=$(awk "/^## \[${VERSION}\]/{flag=1; next} /^## \[v/{if(flag) exit} flag" CHANGELOG.md) | |
| if [ -z "$CONTENT" ]; then | |
| CONTENT="Release ${VERSION}" | |
| fi | |
| { | |
| echo 'body<<EOF' | |
| echo "$CONTENT" | |
| echo 'EOF' | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| name: ShortLinker ${{ github.ref_name }} | |
| body: | | |
| ${{ steps.changelog.outputs.body }} | |
| --- | |
| ## Downloads | |
| | Platform | Architecture | Download | | |
| |----------|--------------|----------| | |
| | Linux | x86_64 | [shortlinker_${{ github.ref_name }}_linux_x86_64](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/shortlinker_${{ github.ref_name }}_linux_x86_64) | | |
| | Linux | ARM64 | [shortlinker_${{ github.ref_name }}_linux_aarch64](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/shortlinker_${{ github.ref_name }}_linux_aarch64) | | |
| | Windows | x86_64 | [shortlinker_${{ github.ref_name }}_windows_x86_64.exe](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/shortlinker_${{ github.ref_name }}_windows_x86_64.exe) | | |
| | macOS | ARM64 | [shortlinker_${{ github.ref_name }}_macos_aarch64](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/shortlinker_${{ github.ref_name }}_macos_aarch64) | | |
| | Admin Panel | - | [shortlinker-admin-panel_${{ github.ref_name }}.tar.gz](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/shortlinker-admin-panel_${{ github.ref_name }}.tar.gz) | | |
| **Checksums**: [checksums.txt](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/checksums.txt) | |
| files: release/* | |
| draft: false | |
| prerelease: ${{ contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'rc') }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |