From 9ad9e00431e6d2d59d46c252fd8f14c4cd9df636 Mon Sep 17 00:00:00 2001 From: Jordan Oroshiba Date: Tue, 6 Feb 2024 08:39:25 -0800 Subject: [PATCH] chore: build all binaries, restructure reusable actions --- .github/reusable/build.yml | 40 +++++++++++++ .../docker-build.yml} | 0 .../release-cargo.yml} | 0 .../run-checker.yml} | 0 .../success.yml} | 0 .github/workflows/admin.yml | 18 ++++++ .github/workflows/build.yml | 59 ++++++++++--------- .github/workflows/docker-build.yml | 12 ++-- .github/workflows/lint.yml | 17 +----- .github/workflows/release.yml | 14 ++--- .github/workflows/test.yml | 4 +- crates/astria-composer/Cargo.toml | 5 ++ crates/astria-conductor/Cargo.toml | 5 ++ crates/astria-sequencer-relayer/Cargo.toml | 5 ++ crates/astria-sequencer/Cargo.toml | 5 ++ 15 files changed, 127 insertions(+), 57 deletions(-) create mode 100644 .github/reusable/build.yml rename .github/{workflows/reusable-docker-build.yml => reusable/docker-build.yml} (100%) rename .github/{workflows/reusable-cargo-version.yml => reusable/release-cargo.yml} (100%) rename .github/{workflows/reusable-run-checker.yml => reusable/run-checker.yml} (100%) rename .github/{workflows/reusable-success.yml => reusable/success.yml} (100%) diff --git a/.github/reusable/build.yml b/.github/reusable/build.yml new file mode 100644 index 0000000000..5a6bec13c9 --- /dev/null +++ b/.github/reusable/build.yml @@ -0,0 +1,40 @@ +name: Reusable Binary Build && Push Workflow + +on: + workflow_call: + inputs: + package-name: + required: true + type: string + +env: + REGISTRY: ghcr.io + +jobs: + upload-binaries: + if: startsWith(github.ref, format('refs/tags/{0}-v', inputs.package-name)) || github.event_name == 'workflow_dispatch' + strategy: + matrix: + include: + - target: x86_64-unknown-linux-gnu + os: buildjet-4vcpu-ubuntu-2004 + build-tool: cargo + - target: aarch64-apple-darwin + os: macos-latest + build-tool: cargo + - target: x86_64-apple-darwin + os: macos-latest + build-tool: cargo + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: taiki-e/upload-rust-binary-action@v1 + with: + bin: astria-${{ github.event.inputs.package-name }} + dry-run: ${{ !startsWith(github.ref, format('refs/tags/{0}-v', inputs.package-name)) }} + # (optional) Target triple, default is host triple. + target: ${{ matrix.target }} + # (optional) Tool to build binaries (cargo, cross, or cargo-zigbuild) + build-tool: ${{ matrix.build-tool }} + # (required) GitHub token for uploading assets to GitHub Releases. + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/reusable-docker-build.yml b/.github/reusable/docker-build.yml similarity index 100% rename from .github/workflows/reusable-docker-build.yml rename to .github/reusable/docker-build.yml diff --git a/.github/workflows/reusable-cargo-version.yml b/.github/reusable/release-cargo.yml similarity index 100% rename from .github/workflows/reusable-cargo-version.yml rename to .github/reusable/release-cargo.yml diff --git a/.github/workflows/reusable-run-checker.yml b/.github/reusable/run-checker.yml similarity index 100% rename from .github/workflows/reusable-run-checker.yml rename to .github/reusable/run-checker.yml diff --git a/.github/workflows/reusable-success.yml b/.github/reusable/success.yml similarity index 100% rename from .github/workflows/reusable-success.yml rename to .github/reusable/success.yml diff --git a/.github/workflows/admin.yml b/.github/workflows/admin.yml index 1c3e519a22..bc36949893 100644 --- a/.github/workflows/admin.yml +++ b/.github/workflows/admin.yml @@ -15,3 +15,21 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/labeler@v4 + + pr_title: + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + steps: + - uses: actions/checkout@v3 + - uses: CondeNast/conventional-pull-request-action@v0.2.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + ignoreCommits: "true" + + admin: + if: ${{ always() && !cancelled() }} + needs: [pr_title] + uses: ./.github/reusable/success.yml + with: + success: ${{ !contains(needs.*.result, 'failure') }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 392036fe24..b60ea3df06 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,31 +11,34 @@ on: jobs: # TODO: Make generic and run on any tagged release - upload-cli-binaries: - if: startsWith(github.ref, 'refs/tags/cli-v') || github.event_name == 'workflow_dispatch' - strategy: - matrix: - include: - - target: x86_64-unknown-linux-gnu - os: buildjet-4vcpu-ubuntu-2004 - build-tool: cargo - - target: aarch64-apple-darwin - os: macos-latest - build-tool: cargo - - target: x86_64-apple-darwin - os: macos-latest - build-tool: cargo - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@1.73.0 - - uses: taiki-e/upload-rust-binary-action@v1 - with: - dry-run: ${{ !startsWith(github.ref, 'refs/tags/cli-v') }} - bin: astria-cli - # (optional) Target triple, default is host triple. - target: ${{ matrix.target }} - # (optional) Tool to build binaries (cargo, cross, or cargo-zigbuild) - build-tool: ${{ matrix.build-tool }} - # (required) GitHub token for uploading assets to GitHub Releases. - token: ${{ secrets.GITHUB_TOKEN }} + cli: + uses: './.github/reusable/build.yml' + with: + package-name: 'cli' + + conductor: + uses: './.github/reusable/build.yml' + with: + package-name: 'conductor' + + composer: + uses: './.github/reusable/build.yml' + with: + package-name: 'conductor' + + sequencer: + uses: './.github/reusable/build.yml' + with: + package-name: 'sequencer' + + relayer: + uses: './.github/reusable/build.yml' + with: + package-name: 'sequencer-relayer' + + build: + if: ${{ always() && !cancelled() }} + needs: [cli, composer, conductor, sequencer, relayer] + uses: ./.github/reusable/success.yml + with: + success: ${{ !contains(needs.*.result, 'failure') }} diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 2a96a085a1..3b281508fb 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -23,12 +23,12 @@ on: jobs: run_checker: - uses: ./.github/workflows/reusable-run-checker.yml + uses: ./.github/reusable/run-checker.yml composer: needs: run_checker if: needs.run_checker.outputs.run_docker == 'true' - uses: './.github/workflows/reusable-docker-build.yml' + uses: './.github/reusable/docker-build.yml' with: package-name: composer target-binary: astria-composer @@ -37,7 +37,7 @@ jobs: conductor: needs: run_checker if: needs.run_checker.outputs.run_docker == 'true' - uses: './.github/workflows/reusable-docker-build.yml' + uses: './.github/reusable/docker-build.yml' with: package-name: conductor target-binary: astria-conductor @@ -46,7 +46,7 @@ jobs: sequencer: needs: run_checker if: needs.run_checker.outputs.run_docker == 'true' - uses: './.github/workflows/reusable-docker-build.yml' + uses: './.github/reusable/docker-build.yml' with: package-name: sequencer target-binary: astria-sequencer @@ -55,7 +55,7 @@ jobs: sequencer-relayer: needs: run_checker if: needs.run_checker.outputs.run_docker == 'true' - uses: './.github/workflows/reusable-docker-build.yml' + uses: './.github/reusable/docker-build.yml' with: package-name: sequencer-relayer target-binary: astria-sequencer-relayer @@ -64,6 +64,6 @@ jobs: docker: if: ${{ always() && !cancelled() }} needs: [composer, conductor, sequencer, sequencer-relayer] - uses: ./.github/workflows/reusable-success.yml + uses: ./.github/reusable/success.yml with: success: ${{ !contains(needs.*.result, 'failure') }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d0e645da18..ed72e34582 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -7,18 +7,7 @@ on: jobs: run_checker: - uses: ./.github/workflows/reusable-run-checker.yml - - pr_title: - runs-on: ubuntu-latest - if: github.event_name == 'pull_request' - steps: - - uses: actions/checkout@v3 - - uses: CondeNast/conventional-pull-request-action@v0.2.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - ignoreCommits: "true" + uses: ./.github/reusable/run-checker.yml proto: runs-on: ubuntu-latest @@ -82,8 +71,8 @@ jobs: #.github lint: - needs: [proto, rust, toml, markdown, pr_title] + needs: [proto, rust, toml, markdown] if: ${{ always() && !cancelled() }} - uses: ./.github/workflows/reusable-success.yml + uses: ./.github/reusable/success.yml with: success: ${{ !contains(needs.*.result, 'failure') }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b8e391050d..2a5dafc9db 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,7 +7,7 @@ on: jobs: run_checker: - uses: ./.github/workflows/reusable-run-checker.yml + uses: ./.github/reusable/run-checker.yml proto: runs-on: ubuntu-latest @@ -29,7 +29,7 @@ jobs: conductor: needs: run_checker if: needs.run_checker.outputs.run_release_services == 'true' - uses: ./.github/workflows/reusable-cargo-version.yml + uses: ./.github/reusable/release-cargo.yml with: package-name: 'conductor' display-name: 'Conductor' @@ -37,7 +37,7 @@ jobs: composer: needs: run_checker if: needs.run_checker.outputs.run_release_services == 'true' - uses: ./.github/workflows/reusable-cargo-version.yml + uses: ./.github/reusable/release-cargo.yml with: package-name: 'composer' display-name: 'Composer' @@ -45,7 +45,7 @@ jobs: sequencer: needs: run_checker if: needs.run_checker.outputs.run_release_services == 'true' - uses: ./.github/workflows/reusable-cargo-version.yml + uses: ./.github/reusable/release-cargo.yml with: package-name: 'sequencer' display-name: 'Sequencer' @@ -53,7 +53,7 @@ jobs: sequencer-relayer: needs: run_checker if: needs.run_checker.outputs.run_release_services == 'true' - uses: ./.github/workflows/reusable-cargo-version.yml + uses: ./.github/reusable/release-cargo.yml with: package-name: 'sequencer-relayer' display-name: 'Sequencer Relayer' @@ -61,7 +61,7 @@ jobs: cli: needs: run_checker if: needs.run_checker.outputs.run_release_services == 'true' - uses: ./.github/workflows/reusable-cargo-version.yml + uses: ./.github/reusable/release-cargo.yml with: package-name: 'cli' display-name: 'CLI' @@ -69,6 +69,6 @@ jobs: release: needs: [proto, conductor, composer, sequencer, sequencer-relayer, cli] if: ${{ always() && !cancelled() }} - uses: ./.github/workflows/reusable-success.yml + uses: ./.github/reusable/success.yml with: success: ${{ !contains(needs.*.result, 'failure') }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 277b2c3479..d360374e33 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ on: jobs: run_checker: - uses: ./.github/workflows/reusable-run-checker.yml + uses: ./.github/reusable/run-checker.yml protos-compiled: runs-on: ubuntu-22.04 @@ -230,6 +230,6 @@ jobs: test: if: ${{ always() && !cancelled() }} needs: [compiles, protos-compiled, rust, doctest, clippy, lockfile, custom-lints, cargo-toml-synced-with-containerfiles] - uses: ./.github/workflows/reusable-success.yml + uses: ./.github/reusable/success.yml with: success: ${{ !contains(needs.*.result, 'failure') }} diff --git a/crates/astria-composer/Cargo.toml b/crates/astria-composer/Cargo.toml index df9d96938f..d00b188dac 100644 --- a/crates/astria-composer/Cargo.toml +++ b/crates/astria-composer/Cargo.toml @@ -4,6 +4,11 @@ version = "0.3.1" edition = "2021" rust-version = "1.70.0" +[[bin]] +name = "astria-composer" +test = false +bench = false + # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] diff --git a/crates/astria-conductor/Cargo.toml b/crates/astria-conductor/Cargo.toml index 755feedf50..0010421a37 100644 --- a/crates/astria-conductor/Cargo.toml +++ b/crates/astria-conductor/Cargo.toml @@ -4,6 +4,11 @@ version = "0.11.1" edition = "2021" rust-version = "1.73" +[[bin]] +name = "astria-conductor" +test = false +bench = false + [dependencies] async-trait = "0.1.73" diff --git a/crates/astria-sequencer-relayer/Cargo.toml b/crates/astria-sequencer-relayer/Cargo.toml index efa49eba57..8b5230cc0a 100644 --- a/crates/astria-sequencer-relayer/Cargo.toml +++ b/crates/astria-sequencer-relayer/Cargo.toml @@ -5,6 +5,11 @@ edition = "2021" license = "MIT OR Apache-2.0" rust-version = "1.73" +[[bin]] +name = "astria-sequencer-relayer" +test = false +bench = false + [dependencies] dirs = "5.0" http = "0.2.9" diff --git a/crates/astria-sequencer/Cargo.toml b/crates/astria-sequencer/Cargo.toml index bdf36a42b8..03712dfbcd 100644 --- a/crates/astria-sequencer/Cargo.toml +++ b/crates/astria-sequencer/Cargo.toml @@ -4,6 +4,11 @@ version = "0.8.0" edition = "2021" rust-version = "1.73.0" +[[bin]] +name = "astria-sequencer" +test = false +bench = false + [dependencies] "astria-core" = { path = "../astria-core" } config = { package = "astria-config", path = "../astria-config" }