Skip to content

Build release candidate images #6

Build release candidate images

Build release candidate images #6

name: Build release candidate images
on:
workflow_dispatch:
inputs:
ref:
description: "Git ref to build from"
default: main
version:
description: "Release version (e.g. 1.4.0)"
required: true
rc:
description: "RC number (e.g. rc.1)"
required: true
dry_run:
description: "If true, skip pushing images and creating GitHub release"
type: boolean
default: true # TODO: change to `false` once validated
jobs:
rc-release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log into GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Validate semantic version
run: |
VERSION="${{ github.event.inputs.version }}"
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid version: $VERSION"
echo "Version must be semantic: MAJOR.MINOR.PATCH (e.g. 1.4.0)"
exit 1
fi
- name: Validate RC format
run: |
if [[ ! "${{ github.event.inputs.rc }}" =~ ^rc\.[0-9]+$ ]]; then
echo "RC must be in format rc.N (e.g. rc.1)"
exit 1
fi
- name: Make repo owner lowercase
id: repo
run: |
echo "owner=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Determine RC Docker image tags
id: vars
run: |
VERSION="${{ github.event.inputs.version }}"
RC="${{ github.event.inputs.rc }}"
TAG="${VERSION}-${RC}"
# GHCR URLs
GHCR_APP="ghcr.io/${{ steps.repo.outputs.owner }}/dibbs-ecr-refiner/refiner"
GHCR_LAMBDA="ghcr.io/${{ steps.repo.outputs.owner }}/dibbs-ecr-refiner/lambda"
GHCR_OPS="ghcr.io/${{ steps.repo.outputs.owner }}/dibbs-ecr-refiner/ops"
echo "app_tags=$GHCR_APP:$TAG" >> $GITHUB_OUTPUT
echo "lambda_tags=$GHCR_LAMBDA:$TAG" >> $GITHUB_OUTPUT
echo "ops_tags=$GHCR_OPS:$TAG" >> $GITHUB_OUTPUT
- name: Print RC Docker image tags
run: |
echo "===== RC IMAGE TAGS ====="
echo "App: ${{ steps.vars.outputs.app_tags }}"
echo "Lambda: ${{ steps.vars.outputs.lambda_tags }}"
echo "Ops: ${{ steps.vars.outputs.ops_tags }}"
echo "=================================="
- name: Create and push RC Git tag
if: ${{ github.event.inputs.dry_run == 'false' }}
id: rc_git_tag
run: |
GIT_TAG="v${{ github.event.inputs.version }}-${{ github.event.inputs.rc }}"
if git rev-parse "$GIT_TAG" >/dev/null 2>&1; then
echo "Tag $GIT_TAG already exists, skipping"
else
git tag -a "$GIT_TAG" -m "Release candidate $GIT_TAG"
git push origin "$GIT_TAG"
fi
echo "git_tag=$GIT_TAG" >> $GITHUB_OUTPUT
- name: Build/push Refiner App RC image to GHCR
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.app
push: ${{ github.event.inputs.dry_run == 'false' }}
tags: ${{ steps.vars.outputs.app_tags }}
build-args: |
VITE_GIT_HASH=${{ github.sha }}
VITE_GIT_BRANCH=${{ github.event.inputs.ref }}
- name: Build/push Refiner Lambda RC image to GHCR
uses: docker/build-push-action@v6
with:
context: .
provenance: false
file: Dockerfile.lambda
push: ${{ github.event.inputs.dry_run == 'false' }}
platforms: linux/amd64
tags: ${{ steps.vars.outputs.lambda_tags }}
- name: Build/push Refiner Ops RC image to GHCR
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.ops
push: ${{ github.event.inputs.dry_run == 'false' }}
tags: ${{ steps.vars.outputs.ops_tags }}
- name: Create draft pre-release GitHub release notes
if: ${{ github.event.inputs.dry_run == 'false' }}
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.rc_git_tag.outputs.git_tag }}
name: ${{ steps.rc_git_tag.outputs.git_tag }}
draft: true
prerelease: true
generate_release_notes: true