Merge pull request #1 from seamile/dev #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: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*.*.*' | |
| jobs: | |
| build: | |
| name: Build - ${{ matrix.target }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| artifact_name: pingx | |
| asset_name: pingx-linux-x86_64.tgz | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| artifact_name: pingx | |
| asset_name: pingx-macos-x86_64.tgz | |
| - os: macos-latest | |
| target: aarch64-apple-darwin | |
| artifact_name: pingx | |
| asset_name: pingx-macos-aarch64.tgz | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| artifact_name: pingx.exe | |
| asset_name: pingx-windows-x86_64.zip | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| components: clippy | |
| - name: Rust Cache | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Clippy | |
| run: cargo clippy --target ${{ matrix.target }} -- -D warnings | |
| - name: Test | |
| run: cargo test --release --target ${{ matrix.target }} | |
| - name: Build | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Package (POSIX) | |
| if: matrix.os != 'windows-latest' | |
| run: | | |
| cd target/${{ matrix.target }}/release | |
| tar czf ../../../${{ matrix.asset_name }} ${{ matrix.artifact_name }} | |
| - name: Package (Windows) | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| cd target/${{ matrix.target }}/release | |
| 7z a ../../../${{ matrix.asset_name }} ${{ matrix.artifact_name }} | |
| - name: Upload Artifacts | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: ${{ matrix.asset_name }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| publish: | |
| name: Publish to Crates.io | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Publish to crates.io | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_TOKEN }} | |
| run: cargo publish |