name: Rust on: push: branches: [ main ] pull_request: branches: [ main ] concurrency: # Documentation suggests ${{ github.head_ref }}, but that's only available on pull_request/pull_request_target triggers, so using ${{ github.ref }}. # On main, we want all builds to complete even if merging happens faster to make it easier to discover at which point something broke. group: ${{ github.ref == 'refs/heads/main' && format('ci-main-{0}', github.sha) || format('ci-{0}', github.ref) }} cancel-in-progress: true env: CARGO_TERM_COLOR: always jobs: lints: name: Lints runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable components: clippy - uses: Swatinem/rust-cache@v1 - name: Clippy run: cargo clippy -- -D warnings - name: Setup cargo-hack run: cargo install cargo-hack - name: Check all features run: cargo hack check --feature-powerset --no-dev-deps build: name: Build for ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: include: - os: ubuntu-latest artifact_name: rathole asset_name: rathole-linux-amd64 - os: windows-latest artifact_name: rathole.exe asset_name: rathole-windows-amd64.exe - os: macos-latest artifact_name: rathole asset_name: rathole-macos-amd64 steps: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable components: clippy - uses: Swatinem/rust-cache@v1 - name: Run tests run: cargo test --verbose - name: Build release run: cargo build --release - name: Strip if: matrix.os == 'ubuntu-latest' run: strip target/release/${{ matrix.artifact_name }} - uses: actions/upload-artifact@v2 with: name: ${{ matrix.asset_name }} path: target/release/${{ matrix.artifact_name }} - name: Release uses: svenstaro/upload-release-action@v2 if: startsWith(github.ref, 'refs/tags/') with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: target/release/${{ matrix.artifact_name }} asset_name: ${{ matrix.asset_name }} tag: ${{ github.ref }}