Skip to content

Merge pull request #4 from Mathison-AG/release-please--branches--main… #10

Merge pull request #4 from Mathison-AG/release-please--branches--main…

Merge pull request #4 from Mathison-AG/release-please--branches--main… #10

Workflow file for this run

name: Release
on:
push:
branches:
- main
workflow_dispatch:
inputs:
version:
description: "Version to build (without v prefix, e.g. 0.2.0)"
required: true
permissions:
contents: write
pull-requests: write
packages: write
env:
REGISTRY: ghcr.io
IMAGE_PREFIX: ghcr.io/mathison-ag
jobs:
release-please:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
version: ${{ steps.release.outputs.version }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
build-images:
needs: release-please
if: needs.release-please.outputs.release_created == 'true' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
strategy:
matrix:
target: [web, worker, migrate]
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Determine version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "value=${{ github.event.inputs.version }}" >> "$GITHUB_OUTPUT"
else
echo "value=${{ needs.release-please.outputs.version }}" >> "$GITHUB_OUTPUT"
fi
- uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.IMAGE_PREFIX }}/mathison-${{ matrix.target }}
tags: |
type=raw,value=${{ steps.version.outputs.value }}
type=semver,pattern={{major}}.{{minor}},value=v${{ steps.version.outputs.value }}
type=sha
type=raw,value=latest
- uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.${{ matrix.target }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=${{ matrix.target }}
cache-to: type=gha,mode=max,scope=${{ matrix.target }}
helm-chart:
needs: [release-please, build-images]
if: needs.release-please.outputs.release_created == 'true' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: azure/setup-helm@v4
- name: Determine version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "value=${{ github.event.inputs.version }}" >> "$GITHUB_OUTPUT"
else
echo "value=${{ needs.release-please.outputs.version }}" >> "$GITHUB_OUTPUT"
fi
- name: Update chart version
run: |
sed -i "s/^version:.*/version: ${{ steps.version.outputs.value }}/" chart/Chart.yaml
sed -i "s/^appVersion:.*/appVersion: \"${{ steps.version.outputs.value }}\"/" chart/Chart.yaml
- name: Login to GHCR
run: echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ${{ env.REGISTRY }} -u ${{ github.actor }} --password-stdin
- name: Package and push chart
run: |
helm package chart/
helm push mathison-${{ steps.version.outputs.value }}.tgz oci://${{ env.IMAGE_PREFIX }}/charts