bump:0.1.8 #23
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: CI | |
| on: | |
| push: | |
| pull_request: | |
| workflow_dispatch: | |
| release: | |
| types: [published] | |
| permissions: | |
| contents: write | |
| jobs: | |
| # ────────────────────────────────────────────── | |
| # Lint & Test (对应 .cnb.yml push 中的 check/test/fmt/clippy) | |
| # 三平台全量检查 | |
| # ────────────────────────────────────────────── | |
| lint-test: | |
| name: Lint & Test - ${{ matrix.os-name }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| os-name: Linux | |
| - os: windows-latest | |
| os-name: Windows | |
| - os: macos-latest | |
| os-name: macOS | |
| steps: | |
| - name: Checkout source code | |
| uses: actions/checkout@v5 | |
| with: | |
| submodules: recursive | |
| - name: Install toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt, clippy | |
| - name: Cache cargo | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-lint-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: ${{ runner.os }}-cargo-lint- | |
| - name: Check | |
| run: cargo check --all | |
| - name: Test | |
| run: cargo test --all | |
| - name: Fmt | |
| run: cargo fmt --all -- --check | |
| - name: Clippy | |
| run: cargo clippy --all -- | |
| # ────────────────────────────────────────────── | |
| # Build (对应 .cnb.yml push 中的 build) | |
| # 覆盖 Linux / Windows / macOS 全架构 | |
| # ────────────────────────────────────────────── | |
| build: | |
| name: Build - ${{ matrix.job.name }} | |
| needs: lint-test | |
| runs-on: ${{ matrix.job.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| job: | |
| # Linux (交叉编译,使用 cross) | |
| - { name: "linux-amd64", target: "x86_64-unknown-linux-musl", os: "ubuntu-latest", use_cross: true, suffix: "x86_64-linux-musl", bin_ext: "" } | |
| - { name: "linux-arm64", target: "aarch64-unknown-linux-musl", os: "ubuntu-latest", use_cross: true, suffix: "aarch64-linux-musl", bin_ext: "" } | |
| - { name: "linux-armv7", target: "armv7-unknown-linux-musleabihf", os: "ubuntu-latest", use_cross: true, suffix: "armv7-linux-musleabihf", bin_ext: "" } | |
| - { name: "linux-i386", target: "i686-unknown-linux-musl", os: "ubuntu-latest", use_cross: true, suffix: "i686-linux-musl", bin_ext: "" } | |
| - { name: "amd64fb", target: "x86_64-unknown-freebsd", os: "ubuntu-latest", use_cross: true, suffix: "freebsd-linux-amd64fb", bin_ext: "" } | |
| # Windows (原生构建) | |
| - { name: "windows-amd64", target: "x86_64-pc-windows-msvc", os: "windows-latest", use_cross: false, suffix: "x86_64-windows", bin_ext: ".exe" } | |
| # macOS (arm64 原生构建,amd64 交叉编译) | |
| - { name: "macos-amd64", target: "x86_64-apple-darwin", os: "macos-latest", use_cross: false, suffix: "x86_64-macos", bin_ext: "" } | |
| - { name: "macos-arm64", target: "aarch64-apple-darwin", os: "macos-latest", use_cross: false, suffix: "aarch64-macos", bin_ext: "" } | |
| steps: | |
| - name: Checkout source code | |
| uses: actions/checkout@v5 | |
| with: | |
| submodules: recursive | |
| - name: Install toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.job.target }} | |
| - name: Install cross | |
| if: matrix.job.use_cross | |
| run: cargo install cross --locked | |
| - name: Build | |
| shell: bash | |
| run: | | |
| if [ "${{ matrix.job.use_cross }}" = "true" ]; then | |
| cross build --release --all-features --target=${{ matrix.job.target }} | |
| else | |
| cargo build --release --all-features --target=${{ matrix.job.target }} | |
| fi | |
| - name: Exec chmod | |
| if: runner.os != 'Windows' | |
| run: chmod -v a+x target/${{ matrix.job.target }}/release/rustproxy-server${{ matrix.job.bin_ext }} target/${{ matrix.job.target }}/release/rustproxy-client${{ matrix.job.bin_ext }} || true | |
| - name: Upload binary artifacts | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: binaries-${{ matrix.job.name }} | |
| path: | | |
| target/${{ matrix.job.target }}/release/rustproxy-server${{ matrix.job.bin_ext }} | |
| target/${{ matrix.job.target }}/release/rustproxy-client${{ matrix.job.bin_ext }} | |
| if-no-files-found: warn | |
| # ─── 以下仅在 tag 推送时执行:打包发布产物 ─── | |
| - name: Package server | |
| if: startsWith(github.ref, 'refs/tags/') | |
| shell: bash | |
| run: | | |
| mkdir -p dist/server | |
| cp target/${{ matrix.job.target }}/release/rustproxy-server${{ matrix.job.bin_ext }} dist/server/ | |
| cp configs/server.toml dist/server/ | |
| cp deploy/rustproxy-server.service dist/server/ 2>/dev/null || true | |
| cp deploy/README.md dist/server/ | |
| cd dist/server && tar czf ../rustproxy-server-${{ matrix.job.suffix }}.tar.gz * | |
| - name: Package client | |
| if: startsWith(github.ref, 'refs/tags/') | |
| shell: bash | |
| run: | | |
| mkdir -p dist/client | |
| cp target/${{ matrix.job.target }}/release/rustproxy-client${{ matrix.job.bin_ext }} dist/client/ | |
| cp configs/client.toml dist/client/ | |
| cp deploy/rustproxy-client.service dist/client/ 2>/dev/null || true | |
| cp deploy/README.md dist/client/ | |
| cd dist/client && tar czf ../rustproxy-client-${{ matrix.job.suffix }}.tar.gz * | |
| - name: Upload server package | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: rustproxy-server-${{ matrix.job.suffix }} | |
| path: dist/rustproxy-server-${{ matrix.job.suffix }}.tar.gz | |
| - name: Upload client package | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: rustproxy-client-${{ matrix.job.suffix }} | |
| path: dist/rustproxy-client-${{ matrix.job.suffix }}.tar.gz | |
| # ────────────────────────────────────────────── | |
| # Release (对应 .cnb.yml tag_push 中 Pipeline 3) | |
| # 等待所有架构打包完成,创建 GitHub Release | |
| # ────────────────────────────────────────────── | |
| release: | |
| name: Create Release | |
| if: startsWith(github.ref, 'refs/tags/') | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Checkout source code | |
| uses: actions/checkout@v5 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v7 | |
| with: | |
| path: dist | |
| merge-multiple: true | |
| - name: List artifacts | |
| run: ls -laR dist/ | |
| - name: Generate changelog | |
| run: | | |
| PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") | |
| if [ -n "$PREV_TAG" ]; then | |
| LOG=$(git log ${PREV_TAG}..HEAD --pretty=format:"- %s (%h)" --no-merges) | |
| else | |
| LOG=$(git log --pretty=format:"- %s (%h)" --no-merges -20) | |
| fi | |
| TAG_NAME=${GITHUB_REF#refs/tags/} | |
| echo "# ${TAG_NAME}" > CHANGELOG.txt | |
| echo "" >> CHANGELOG.txt | |
| echo "$LOG" >> CHANGELOG.txt | |
| cat CHANGELOG.txt | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| body_path: CHANGELOG.txt | |
| files: | | |
| dist/*.tar.gz |