diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1d74ab1821..b59875d372 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,10 +3,8 @@ on: # TODO: allow workflow dispatch to specify which binaries to build workflow_dispatch: inputs: - ref: - description: | - Fully qualified git ref which will be checked out and built. Defaults to using the branch workflow is run on. - Example: refs/tags/sequencer-v0.8.0 will then only build sequencer code at that tag. + tag: + description: Git branch, or tag to build from required: false push: tags: @@ -20,31 +18,31 @@ jobs: uses: './.github/workflows/reusable-build.yml' with: package-name: 'cli' - git-ref: ${{ inputs.ref || github.ref }} + tag: ${{ inputs.tag }} conductor: uses: './.github/workflows/reusable-build.yml' with: package-name: 'conductor' - git-ref: ${{ inputs.ref || github.ref }} + tag: ${{ inputs.tag }} composer: uses: './.github/workflows/reusable-build.yml' with: package-name: 'composer' - git-ref: ${{ inputs.ref || github.ref }} + tag: ${{ inputs.tag }} sequencer: uses: './.github/workflows/reusable-build.yml' with: package-name: 'sequencer' - git-ref: ${{ inputs.ref || github.ref }} + tag: ${{ inputs.tag }} relayer: uses: './.github/workflows/reusable-build.yml' with: package-name: 'sequencer-relayer' - git-ref: ${{ inputs.ref || github.ref }} + tag: ${{ inputs.tag }} build: if: ${{ always() && !cancelled() }} diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index ce88c932b2..6f04b830e1 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -4,10 +4,8 @@ name: Docker on: workflow_dispatch: inputs: - ref: - description: | - Fully qualified git ref which will be checked out and built. Defaults to using the branch workflow is run on. - Example: refs/tags/sequencer-v0.8.0 will then only build sequencer code at that tag. + tag: + description: Git branch, or tag to build from. required: false push: branches: @@ -38,7 +36,7 @@ jobs: with: package-name: composer target-binary: astria-composer - git-ref: ${{ inputs.ref || github.ref }} + tag: ${{ inputs.tag }} secrets: inherit conductor: @@ -48,7 +46,7 @@ jobs: with: package-name: conductor target-binary: astria-conductor - git-ref: ${{ inputs.ref || github.ref }} + tag: ${{ inputs.tag }} secrets: inherit sequencer: @@ -58,7 +56,7 @@ jobs: with: package-name: sequencer target-binary: astria-sequencer - git-ref: ${{ inputs.ref || github.ref }} + tag: ${{ inputs.tag }} secrets: inherit sequencer-relayer: @@ -68,7 +66,7 @@ jobs: with: package-name: sequencer-relayer target-binary: astria-sequencer-relayer - git-ref: ${{ inputs.ref || github.ref }} + tag: ${{ inputs.tag }} secrets: inherit docker: diff --git a/.github/workflows/reusable-build.yml b/.github/workflows/reusable-build.yml index 69aced5506..ae2d86eca1 100644 --- a/.github/workflows/reusable-build.yml +++ b/.github/workflows/reusable-build.yml @@ -6,16 +6,17 @@ on: package-name: required: true type: string - git-ref: - required: true + tag: + required: false type: string env: REGISTRY: ghcr.io + FULL_REF: ${{ inputs.tag && format('refs/tags/{0}', inputs.tag) || github.ref }} jobs: upload-binaries: - if: startsWith(inputs.git-ref, format('refs/tags/{0}-v', inputs.package-name)) || github.event_name == 'workflow_dispatch' + if: startsWith(github.ref, format('refs/tags/{0}-v', inputs.package-name)) || !inputs.tag && github.event_name == 'workflow_dispatch' || startsWith(inputs.tag, inputs.package-name) strategy: matrix: include: @@ -32,7 +33,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: ${{ inputs.git-ref }} + ref: ${{ inputs.tag }} - uses: dtolnay/rust-toolchain@1.76.0 - uses: arduino/setup-protoc@v2 with: @@ -40,9 +41,9 @@ jobs: repo-token: ${{ secrets.GITHUB_TOKEN }} - uses: taiki-e/upload-rust-binary-action@v1 with: - ref: ${{ inputs.git-ref }} + ref: ${{ env.FULL_REF }} bin: astria-${{ inputs.package-name }} - dry-run: ${{ !startsWith(inputs.git-ref, format('refs/tags/{0}-v', inputs.package-name)) }} + dry-run: ${{ !startsWith(env.FULL_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) diff --git a/.github/workflows/reusable-docker-build.yml b/.github/workflows/reusable-docker-build.yml index 25e1f36c08..2eb21a17bb 100644 --- a/.github/workflows/reusable-docker-build.yml +++ b/.github/workflows/reusable-docker-build.yml @@ -9,8 +9,8 @@ on: target-binary: required: true type: string - git-ref: - required: true + tag: + required: false type: string secrets: DOCKER_TOKEN: @@ -19,16 +19,17 @@ on: required: true env: REGISTRY: ghcr.io + FULL_REF: ${{ inputs.tag && format('refs/tags/{0}', inputs.tag) || github.ref }} jobs: build-and-push: runs-on: buildjet-8vcpu-ubuntu-2204 - if: ${{ startsWith(inputs.git-ref, format('refs/tags/{0}-v', inputs.package-name)) || inputs.git-ref == 'refs/heads/main' || github.event_name == 'pull_request' }} + if: ${{ startsWith(inputs.tag, inputs.package-name) || startsWith(github.ref, format('refs/tags/{0}-v', inputs.package-name)) || github.ref == 'refs/heads/main' || github.ref == 'pull_request' }} steps: # Checking out the repo - uses: actions/checkout@v3 with: - ref: ${{ inputs.git-ref }} + ref: ${{ inputs.tag }} # https://github.com/docker/setup-qemu-action - name: Login to Docker Hub uses: docker/login-action@v2 @@ -55,10 +56,10 @@ jobs: images: ${{ format('ghcr.io/astriaorg/{0}', inputs.package-name) }} tags: | type=ref,event=pr - type=match,pattern=refs/tags/([a-z-]+)-v(.*),group=2,enable=${{ startsWith('refs/tags/', inputs.git-ref) }},value=${{ inputs.git-ref }} + type=match,pattern=refs/tags/([a-z-]+)-v(.*),group=2,enable=${{ startsWith('refs/tags/', env.FULL_REF) }},value=${{ env.FULL_REF }} type=sha # set latest tag for `main` branch - type=raw,value=latest,enable=${{ inputs.git-ref == format('refs/heads/{0}', 'main') }} + type=raw,value=latest,enable=${{ env.FULL_REF == format('refs/heads/{0}', 'main') }} - name: Build and push uses: docker/build-push-action@v4 with: