Skip to content

Commit

Permalink
fix(ci): enable bridge withdrawer building with tag (#1374)
Browse files Browse the repository at this point in the history
## Summary
Updates the image build to work on a specific tag when binary name and
image name don't match

## Background
The `astria-bridge-withdrawer` binary is pushed to an
`evm-bridge-withdrawer` docker package and the tag used is
`bridge-withdrawer-v<semantic version>` for releases. This is
potentially suboptimal but has already been done. Our image build script
doesn't work with this setup.

## Changes
- update image build to consider `binary-name` without `astria` prefix
and take a separate `package-name` for most instances these are the same
but for when they are not it supports it. There is also a
`binary-prefix` which can be set to provide more flexibility for the
future.

## Testing
CI/CD tests

## Related Issues

closes #1373
  • Loading branch information
joroshiba authored Aug 20, 2024
1 parent 2ce5fd9 commit a603923
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
with:
package-name: 'conductor'
tag: ${{ inputs.tag }}

composer:
uses: './.github/workflows/reusable-build.yml'
with:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
with:
depot-project-id: mhgvgvsjnx
package-name: composer
target-binary: astria-composer
binary-name: composer
tag: ${{ inputs.tag }}
secrets: inherit

Expand All @@ -64,7 +64,7 @@ jobs:
with:
depot-project-id: zrh9t1d84s
package-name: conductor
target-binary: astria-conductor
binary-name: conductor
tag: ${{ inputs.tag }}
secrets: inherit

Expand All @@ -79,7 +79,7 @@ jobs:
with:
depot-project-id: brzhxfbv9b
package-name: sequencer
target-binary: astria-sequencer
binary-name: sequencer
tag: ${{ inputs.tag }}
secrets: inherit

Expand All @@ -94,7 +94,7 @@ jobs:
with:
depot-project-id: 86q4kz4wfs
package-name: sequencer-relayer
target-binary: astria-sequencer-relayer
binary-name: sequencer-relayer
tag: ${{ inputs.tag }}
secrets: inherit

Expand All @@ -109,7 +109,7 @@ jobs:
with:
depot-project-id: dl81f3fc6x
package-name: evm-bridge-withdrawer
target-binary: astria-bridge-withdrawer
binary-name: bridge-withdrawer
tag: ${{ inputs.tag }}
secrets: inherit

Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/reusable-docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ on:
package-name:
required: true
type: string
target-binary:
binary-name:
required: true
type: string
binary-prefix:
type: string
default: astria
tag:
required: false
type: string
Expand All @@ -23,15 +26,15 @@ on:
env:
REGISTRY: ghcr.io
FULL_REF: ${{ inputs.tag && format('refs/tags/{0}', inputs.tag) || github.ref }}

FULL_BINARY_NAME: ${{ inputs.binary-prefix }}-${{ inputs.binary-name }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
if: startsWith(inputs.tag, inputs.package-name) || !inputs.tag && (startsWith(github.ref, format('refs/tags/{0}-v', inputs.package-name)) || github.ref == 'refs/heads/main' || github.event_name == 'pull_request' || github.event_name == 'merge_group')
if: startsWith(inputs.tag, inputs.binary-name) || !inputs.tag && (startsWith(github.ref, format('refs/tags/{0}-v', inputs.binary-name)) || github.ref == 'refs/heads/main' || github.event_name == 'pull_request' || github.event_name == 'merge_group')
steps:
# Checking out the repo
- uses: actions/checkout@v4
Expand Down Expand Up @@ -59,7 +62,7 @@ jobs:
images: ${{ format('ghcr.io/astriaorg/{0}', inputs.package-name) }}
tags: |
type=ref,event=pr
type=match,pattern=refs/tags/${{ inputs.package-name }}-v(.*),group=1,enable=${{ startsWith(env.FULL_REF, 'refs/tags/') }},value=${{ env.FULL_REF }}
type=match,pattern=refs/tags/${{ inputs.binary-name }}-v(.*),group=1,enable=${{ startsWith(env.FULL_REF, 'refs/tags/') }},value=${{ env.FULL_REF }}
type=sha
# set latest tag for `main` branch
type=raw,value=latest,enable=${{ env.FULL_REF == format('refs/heads/{0}', 'main') }}
Expand All @@ -72,7 +75,7 @@ jobs:
context: .
file: containerfiles/Dockerfile
build-args: |
TARGETBINARY=${{ inputs.target-binary }}
TARGETBINARY=${{ env.FULL_BINARY_NAME }}
platforms: "linux/amd64,linux/arm64"
push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'astriaorg/astria' }}
tags: ${{ steps.metadata.outputs.tags }}
Expand Down

0 comments on commit a603923

Please sign in to comment.