Merge pull request #37 from fishnetproxy/feature/credentials-page #23
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 and Release | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| checks: | |
| name: Checks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Run tests | |
| run: cargo test --workspace --all-targets | |
| build-release: | |
| name: Build ${{ matrix.target }} | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: checks | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - runner: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| use_cross: false | |
| - runner: macos-latest | |
| target: x86_64-apple-darwin | |
| use_cross: false | |
| - runner: macos-14 | |
| target: aarch64-apple-darwin | |
| use_cross: false | |
| runs-on: ${{ matrix.runner }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Cache cargo | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Install cross | |
| if: matrix.use_cross | |
| run: cargo install cross --version 0.2.5 | |
| - name: Build fishnet | |
| run: | | |
| if [ "${{ matrix.use_cross }}" = "true" ]; then | |
| cross build --release -p fishnet-cli --target ${{ matrix.target }} | |
| else | |
| cargo build --release -p fishnet-cli --target ${{ matrix.target }} | |
| fi | |
| - name: Package artifact | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| mkdir -p dist | |
| binary="target/${{ matrix.target }}/release/fishnet" | |
| archive="fishnet-${{ matrix.target }}.tar.gz" | |
| tar -czf "dist/${archive}" -C "$(dirname "${binary}")" "$(basename "${binary}")" | |
| if command -v sha256sum >/dev/null 2>&1; then | |
| (cd dist && sha256sum "${archive}" > "${archive}.sha256") | |
| else | |
| (cd dist && shasum -a 256 "${archive}" > "${archive}.sha256") | |
| fi | |
| - name: Upload artifact bundle | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: fishnet-${{ matrix.target }} | |
| path: dist/* | |
| publish-release: | |
| name: Publish GitHub Release | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: build-release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| - name: Flatten artifacts | |
| run: | | |
| set -euo pipefail | |
| mkdir -p release-assets | |
| find dist -type f -name "fishnet-*.tar.gz" -exec cp {} release-assets/ \; | |
| find dist -type f -name "fishnet-*.tar.gz.sha256" -exec cp {} release-assets/ \; | |
| cp scripts/install.sh release-assets/install.sh | |
| chmod +x release-assets/install.sh | |
| cat release-assets/*.sha256 > release-assets/SHA256SUMS.txt | |
| - name: Create release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: | | |
| release-assets/fishnet-*.tar.gz | |
| release-assets/fishnet-*.tar.gz.sha256 | |
| release-assets/SHA256SUMS.txt | |
| release-assets/install.sh |