Skip to content
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
58 changes: 0 additions & 58 deletions .github/workflows/publish.yml

This file was deleted.

2 changes: 0 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ jobs:

- name: Install uv
uses: astral-sh/[email protected]
with:
version: latest

- name: Setup
run: uv run task setup
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Release
on:
push:
branches:
- main
- master

permissions:
contents: write # Required to create tags & GitHub Releases

jobs:
release:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-release-${{ github.ref_name }}
cancel-in-progress: false
environment:
name: release

steps:
# Use a merge queue to avoid `main` commit race conditions.
- name: Checkout release branch
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
fetch-depth: 0
fetch-tags: true

- name: Set up Python
uses: actions/setup-python@v5

- name: Install uv
uses: astral-sh/[email protected]

- name: Setup
run: uv run task setup

- name: Build
run: uv run task build

- name: Release (ECR)
run: uv run task release-ecr-no-build
14 changes: 14 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,17 @@ tasks:
run: once
cmds:
- ./scripts/local-instance.sh stop {{.DOCKER_IMAGE}}

release-ecr:
desc: Release the Docker image to ECR
run: once
deps:
- build
cmds:
- ./scripts/release-ecr.sh

release-ecr-no-build:
desc: Release the Docker image to ECR without building it first
run: once
cmds:
- ./scripts/release-ecr.sh
41 changes: 41 additions & 0 deletions scripts/release-ecr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

set -euo pipefail

ECR_REPOSITORY_URL="${1:-$ECR_REPOSITORY_URL}"

IMAGE_NAME="$(echo "$ECR_REPOSITORY_URL" | cut -d '/' -f 2)"
IMAGE_TAG="$(./scripts/get-version.sh)"
AWS_ACCOUNT_ID="$(echo "$ECR_REPOSITORY_URL" | cut -d '.' -f 1)"
AWS_ECR_REGION="$(echo "$ECR_REPOSITORY_URL" | cut -d '.' -f 4)"

function ensure_parameters() {
if [ -z "$ECR_REPOSITORY_URL" ]; then
echo "ECR_REPOSITORY_URL is not set"
exit 1
fi
}

function ecr_login() {
aws ecr get-login-password --region "$AWS_ECR_REGION" | \
docker login --username AWS --password-stdin "$ECR_REPOSITORY_URL"
}

function ecr_tag() {
echo "Tagging image: $ECR_REPOSITORY_URL:$IMAGE_TAG"
docker tag "$IMAGE_NAME:$IMAGE_TAG" "$ECR_REPOSITORY_URL:$IMAGE_TAG"
}

function ecr_push() {
echo "Pushing image to ECR: $ECR_REPOSITORY_URL:$IMAGE_TAG"
docker push "$ECR_REPOSITORY_URL:$IMAGE_TAG"
}

function main() {
ensure_parameters
ecr_login
ecr_tag
ecr_push
}

main