v0.3.0 #7
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*" | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "要发布的 Tag(例如 v0.2.9)" | |
| required: false | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| env: | |
| CARGO_TERM_COLOR: always | |
| CARGO_INCREMENTAL: 0 | |
| CARGO_PROFILE_RELEASE_DEBUG: 0 | |
| RUSTFLAGS: "-C target-feature=+crt-static" | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Install Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| target: x86_64-unknown-linux-musl | |
| - name: Install musl tools | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y musl-tools | |
| - name: Cache cargo | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| cache-all-crates: true | |
| - name: Build | |
| env: | |
| CC: musl-gcc | |
| run: | | |
| RUSTC_WRAPPER="" cargo build \ | |
| --release \ | |
| --target x86_64-unknown-linux-musl | |
| - name: Strip binary | |
| run: | | |
| strip target/x86_64-unknown-linux-musl/release/floatctf | |
| - name: Verify static binary | |
| run: | | |
| file target/x86_64-unknown-linux-musl/release/floatctf | |
| ldd target/x86_64-unknown-linux-musl/release/floatctf || true | |
| # ========================= | |
| # 核心修改点:在这里将 src/sql 目录打包并放入 dist | |
| # ========================= | |
| - name: Prepare artifact | |
| run: | | |
| mkdir -p dist | |
| # 1. 复制二进制文件 | |
| cp target/x86_64-unknown-linux-musl/release/floatctf \ | |
| dist/floatctf-linux-amd64-musl | |
| # 2. 将 src/sql 目录打包成 sql.tar.gz,并放入 dist 目录 | |
| tar -czf dist/sql.tar.gz src/sql | |
| - name: Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ inputs.tag || github.ref_name }} | |
| generate_release_notes: true | |
| # 因为上面把 sql.tar.gz 放进了 dist 里面,所以这里的 dist/* 会自动把它一起传上去 | |
| files: dist/* |