diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a79f98871..d30f4dda2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,13 +1,22 @@ name: CD Pipeline -on: [push] +on: + push: + branches: + - "master" + tags: + - "*" + +# Build jobs only need to read the repository. The publish job below is the +# only job that gets write access, and it only runs for tag pushes. +permissions: + contents: read jobs: build-nix: env: IN_PIPELINE: true runs-on: ${{ matrix.os }} - if: github.ref == 'refs/heads/master' strategy: matrix: type: [ubuntu-x64, ubuntu-x86, armv7, aarch64] @@ -39,28 +48,23 @@ jobs: steps: - uses: actions/checkout@v7 - name: Cache cargo & target directories - uses: Swatinem/rust-cache@v2 + uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 - name: Build binary - uses: houseabsolute/actions-rust-cross@v1 + uses: houseabsolute/actions-rust-cross@21b0f18dc621b25bfae556ff2791fca4173121e8 # v1.0.8 with: command: build target: ${{ matrix.target }} args: "--locked --release" strip: true toolchain: stable - - name: Build tar.gz for homebrew installs - if: matrix.type == 'ubuntu-x64' - run: | - tar czf ${{ matrix.name }}.tar.gz -C target/x86_64-unknown-linux-musl/release rustscan - - uses: actions/upload-artifact@v7 - with: - name: ${{ matrix.name }} - path: ${{ matrix.path }} - - uses: actions/upload-artifact@v7 - if: matrix.type == 'ubuntu-x64' + - name: Package and upload artifacts + uses: houseabsolute/actions-rust-release@9e126fd5fc18f4cecf358b3909f3991ad59663dc # v1.0.1 with: - name: ${{ matrix.name }}.tar.gz - path: ${{ matrix.name }}.tar.gz + executable-name: rustscan + target: ${{ matrix.target }} + archive-name: ${{ matrix.name }} + changes-file: "" + build-deb: needs: [build-nix] runs-on: ubuntu-latest @@ -70,7 +74,7 @@ jobs: - uses: actions/checkout@v7 - name: Install cargo-deb run: cargo install -f cargo-deb - - uses: awalsh128/cache-apt-pkgs-action@v1 + - uses: awalsh128/cache-apt-pkgs-action@553a35bb8ebd9fcabcb1c9451aa4c98e1b4ca8a9 # v1.6.3 with: packages: musl-tools # provides musl-gcc version: 1.0 @@ -88,65 +92,54 @@ jobs: env: IN_PIPELINE: true runs-on: macos-latest - if: github.ref == 'refs/heads/master' steps: - uses: actions/checkout@v7 - name: Cache cargo & target directories - uses: Swatinem/rust-cache@v2 + uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 - name: Build binary - uses: houseabsolute/actions-rust-cross@v1 + uses: houseabsolute/actions-rust-cross@21b0f18dc621b25bfae556ff2791fca4173121e8 # v1.0.8 with: command: build target: x86_64-apple-darwin args: "--locked --release" strip: true toolchain: stable - - name: Build tar.gz for homebrew installs - run: | - tar czf x86_64-macos-rustscan.tar.gz -C target/x86_64-apple-darwin/release rustscan - - uses: actions/upload-artifact@v7 + - name: Package and upload artifacts + uses: houseabsolute/actions-rust-release@9e126fd5fc18f4cecf358b3909f3991ad59663dc # v1.0.1 with: - name: x86_64-macos-rustscan - path: target/x86_64-apple-darwin/release/rustscan - - uses: actions/upload-artifact@v7 - with: - name: x86_64-macos-rustscan.tar.gz - path: x86_64-macos-rustscan.tar.gz - + executable-name: rustscan + target: x86_64-apple-darwin + archive-name: x86_64-macos-rustscan + changes-file: "" + build-macos-aarch64: env: IN_PIPELINE: true runs-on: macos-latest - if: github.ref == 'refs/heads/master' steps: - uses: actions/checkout@v7 - name: Cache cargo & target directories - uses: Swatinem/rust-cache@v2 + uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 - name: Build binary - uses: houseabsolute/actions-rust-cross@v1 + uses: houseabsolute/actions-rust-cross@21b0f18dc621b25bfae556ff2791fca4173121e8 # v1.0.8 with: command: build target: aarch64-apple-darwin args: "--locked --release" strip: true toolchain: stable - - name: Build tar.gz for homebrew installs - run: | - tar czf aarch64-macos-rustscan.tar.gz -C target/aarch64-apple-darwin/release rustscan - - uses: actions/upload-artifact@v7 - with: - name: aarch64-macos-rustscan - path: target/aarch64-apple-darwin/release/rustscan - - uses: actions/upload-artifact@v7 + - name: Package and upload artifacts + uses: houseabsolute/actions-rust-release@9e126fd5fc18f4cecf358b3909f3991ad59663dc # v1.0.1 with: - name: aarch64-macos-rustscan.tar.gz - path: aarch64-macos-rustscan.tar.gz + executable-name: rustscan + target: aarch64-apple-darwin + archive-name: aarch64-macos-rustscan + changes-file: "" build-windows: env: IN_PIPELINE: true runs-on: ${{ matrix.os }} - if: github.ref == 'refs/heads/master' strategy: matrix: type: [windows-x64, windows-x86] @@ -154,26 +147,55 @@ jobs: - type: windows-x64 os: windows-latest target: x86_64-pc-windows-msvc - name: x86_64-windows-rustscan.exe - path: target\x86_64-pc-windows-msvc\release\rustscan.exe + name: x86_64-windows-rustscan - type: windows-x86 os: windows-latest target: i686-pc-windows-msvc - name: x86-windows-rustscan.exe - path: target\i686-pc-windows-msvc\release\rustscan.exe + name: x86-windows-rustscan steps: - uses: actions/checkout@v7 - name: Cache cargo & target directories - uses: Swatinem/rust-cache@v2 + uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 - name: Build binary - uses: houseabsolute/actions-rust-cross@v1 + uses: houseabsolute/actions-rust-cross@21b0f18dc621b25bfae556ff2791fca4173121e8 # v1.0.8 with: command: build - target: ${{ matrix.target }} + target: ${{ matrix.target }} args: "--locked --release" strip: true toolchain: stable - - uses: actions/upload-artifact@v7 + - name: Package and upload artifacts + uses: houseabsolute/actions-rust-release@9e126fd5fc18f4cecf358b3909f3991ad59663dc # v1.0.1 + with: + executable-name: rustscan + target: ${{ matrix.target }} + archive-name: ${{ matrix.name }} + changes-file: "" + + # Runs only for tag pushes (tags can only be created by maintainers), and + # only after every build job succeeded, so a release never ships partially. + publish: + if: github.ref_type == 'tag' + needs: + - build-nix + - build-deb + - build-macos + - build-macos-aarch64 + - build-windows + runs-on: ubuntu-latest + permissions: + contents: write # create the release / upload release assets + steps: + - name: Download build artifacts + uses: actions/download-artifact@v8 + with: + merge-multiple: true + - name: Publish artifacts to GitHub release + uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3 with: - name: ${{ matrix.name }} - path: ${{ matrix.path }} + fail_on_unmatched_files: true + files: | + *.deb + *.sha256 + *.tar.gz + *.zip diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml deleted file mode 100644 index 7f9508bde..000000000 --- a/.github/workflows/dependabot.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Dependabot Auto-Merge - -jobs: - dependabot: - runs-on: ubuntu-latest - if: ${{ github.actor == 'dependabot[bot]' }} - steps: - - name: Enable auto-merge for Dependabot PRs - run: | - gh pr review --approve "$PR_URL" - gh pr merge --auto --merge "$PR_URL" - env: - PR_URL: ${{ github.event.pull_request.html_url }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}