Skip to content

Add AWS CLI to infra Dockerfile and bump version to 0.0.4 #3

Add AWS CLI to infra Dockerfile and bump version to 0.0.4

Add AWS CLI to infra Dockerfile and bump version to 0.0.4 #3

Workflow file for this run

name: Release & Build Images
on:
push:
branches: [main]
paths:
- "src/bender/__init__.py"
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
release:
name: Create release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract.outputs.version }}
created: ${{ steps.check.outputs.created }}
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from __init__.py
id: extract
run: |
VERSION=$(python -c "import re; print(re.search(r'__version__\s*=\s*\"(.+?)\"', open('src/bender/__init__.py').read()).group(1))")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Extracted version: $VERSION"
- name: Check if tag already exists
id: check
run: |
VERSION="${{ steps.extract.outputs.version }}"
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
echo "Tag v$VERSION already exists, skipping"
echo "created=false" >> "$GITHUB_OUTPUT"
else
echo "Tag v$VERSION does not exist, creating release"
echo "created=true" >> "$GITHUB_OUTPUT"
fi
- name: Update Helm chart version
if: steps.check.outputs.created == 'true'
run: |
VERSION="${{ steps.extract.outputs.version }}"
sed -i "s/^version: .*/version: $VERSION/" helm/Chart.yaml
sed -i "s/^appVersion: .*/appVersion: \"$VERSION\"/" helm/Chart.yaml
sed -i "s/^ tag: .*/ tag: \"infra-$VERSION\"/" helm/values.yaml
- name: Commit Helm chart updates
if: steps.check.outputs.created == 'true'
run: |
VERSION="${{ steps.extract.outputs.version }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add helm/Chart.yaml helm/values.yaml
git commit -m "Update Helm chart to v$VERSION"
git push origin main
- name: Create tag and GitHub release
if: steps.check.outputs.created == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ steps.extract.outputs.version }}"
git tag "v$VERSION"
git push origin "v$VERSION"
gh release create "v$VERSION" --generate-notes --title "v$VERSION"
build-base:
name: Build base image
runs-on: ubuntu-latest
needs: release
if: needs.release.outputs.created == 'true'
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push base image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.release.outputs.version }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
build-infra:
name: Build infra image
runs-on: ubuntu-latest
needs: release
if: needs.release.outputs.created == 'true'
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push infra image
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:infra-${{ needs.release.outputs.version }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:infra-latest