Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ci): build composer, and allow builds on old tags #763

Merged
merged 3 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Build Binaries
on:
# TODO: allow workflow dispatch to specify which binaries to build
workflow_dispatch:
inputs:
tag:
description: Git branch, or tag to build from
required: false
push:
tags:
- "**-v[0-9]+.[0-9]+.[0-9]+"
Expand All @@ -10,31 +14,35 @@ on:
- "**-v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+"

jobs:
# TODO: Make generic and run on any tagged release
cli:
uses: './.github/workflows/reusable-build.yml'
with:
package-name: 'cli'
tag: ${{ inputs.tag }}

conductor:
uses: './.github/workflows/reusable-build.yml'
with:
package-name: 'conductor'
tag: ${{ inputs.tag }}

composer:
uses: './.github/workflows/reusable-build.yml'
with:
package-name: 'conductor'
package-name: 'composer'
tag: ${{ inputs.tag }}

sequencer:
uses: './.github/workflows/reusable-build.yml'
with:
package-name: 'sequencer'
tag: ${{ inputs.tag }}

relayer:
uses: './.github/workflows/reusable-build.yml'
with:
package-name: 'sequencer-relayer'
tag: ${{ inputs.tag }}

build:
if: ${{ always() && !cancelled() }}
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: Docker
# Trigger on pushes to master branch, new semantic version tags, and pull request updates
on:
workflow_dispatch:
inputs:
tag:
description: Git branch, or tag to build from.
required: false
push:
branches:
- "main"
Expand Down Expand Up @@ -32,6 +36,7 @@ jobs:
with:
package-name: composer
target-binary: astria-composer
tag: ${{ inputs.tag }}
secrets: inherit

conductor:
Expand All @@ -41,6 +46,7 @@ jobs:
with:
package-name: conductor
target-binary: astria-conductor
tag: ${{ inputs.tag }}
secrets: inherit

sequencer:
Expand All @@ -50,6 +56,7 @@ jobs:
with:
package-name: sequencer
target-binary: astria-sequencer
tag: ${{ inputs.tag }}
secrets: inherit

sequencer-relayer:
Expand All @@ -59,6 +66,7 @@ jobs:
with:
package-name: sequencer-relayer
target-binary: astria-sequencer-relayer
tag: ${{ inputs.tag }}
secrets: inherit

docker:
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ on:
package-name:
required: true
type: string
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(github.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:
Expand All @@ -28,15 +32,18 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.tag }}
- uses: dtolnay/[email protected]
- uses: arduino/setup-protoc@v2
with:
version: "24.4"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: taiki-e/upload-rust-binary-action@v1
with:
ref: ${{ env.FULL_REF }}
bin: astria-${{ inputs.package-name }}
dry-run: ${{ !startsWith(github.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)
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/reusable-docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,27 @@ on:
target-binary:
required: true
type: string
tag:
required: false
type: string
secrets:
DOCKER_TOKEN:
required: true
DOCKER_USER:
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(github.ref, format('refs/tags/{0}-v', inputs.package-name)) || github.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.tag }}
# https://github.com/docker/setup-qemu-action
- name: Login to Docker Hub
uses: docker/login-action@v2
Expand All @@ -50,10 +56,10 @@ jobs:
images: ${{ format('ghcr.io/astriaorg/{0}', inputs.package-name) }}
tags: |
type=ref,event=pr
type=match,pattern=([a-z-]+)-v(.*),group=2
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=${{ github.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:
Expand Down
Loading