Files
grimmory/.github/workflows/publish-release.yml
T
dependabot[bot] 4a2aa1f2bc chore(deps): bump docker/build-push-action from 7.2.0 to 7.3.0 (#1926)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-07-03 13:28:53 -04:00

189 lines
6.3 KiB
YAML

name: On Release Published
on:
release:
types:
- released
jobs:
build-and-release:
name: Build, Publish, and Finalize Stable Release
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout Repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 1
ref: ${{ github.sha }}
- name: Set Up QEMU for Multi-Arch Builds
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0
with:
cache-image: false
- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
- name: Authenticate to Docker Hub
if: ${{ vars.DOCKERHUB_REGISTRY != '' }}
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Authenticate to GitHub Container Registry
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Docker meta
id: meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
with:
images: |
${{ vars.DOCKERHUB_REGISTRY }}
ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern=v{{version}},value=${{ github.event.release.tag_name }},match=^v(.+)$
type=semver,pattern=v{{major}}.{{minor}},value=${{ github.event.release.tag_name }},match=^v(.+)$
- name: Build and push Stable image
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
annotations: ${{ steps.meta.outputs.annotations }}
build-args: |
APP_VERSION=${{ github.event.release.tag_name }}
APP_REVISION=${{ github.sha }}
cache-from: |
type=gha,scope=image-shared
type=registry,ref=ghcr.io/${{ github.repository }}:buildcache
cache-to: |
type=gha,scope=image-shared,mode=max
type=registry,ref=ghcr.io/${{ github.repository }}:buildcache,mode=max
publish-helm-chart:
name: Publish Helm Chart to GHCR
needs:
- build-and-release
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout Repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 1
ref: ${{ github.sha }}
- name: Set Up Helm
uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5.0.1
- name: Authenticate to GitHub Container Registry
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Package and Push Helm Chart
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
set -eu
VERSION="${RELEASE_TAG#v}"
helm dependency update deploy/helm/grimmory
helm package deploy/helm/grimmory \
--version "${VERSION}" \
--app-version "${RELEASE_TAG}"
helm push "grimmory-${VERSION}.tgz" "oci://ghcr.io/${{ github.repository_owner }}/helm-charts"
prepare-release-notification:
name: Prepare Stable Release Notification
needs:
- build-and-release
runs-on: ubuntu-latest
outputs:
base_tag: ${{ steps.metadata.outputs.base_tag }}
compare_url: ${{ steps.metadata.outputs.compare_url }}
available: ${{ steps.webhook_secrets_check.outputs.available }}
permissions:
contents: read
steps:
- name: Check Discord Webhook secrets
id: webhook_secrets_check
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_STABLE_WEBHOOK }}
run: |
# Check here rather than in the `if`.
# Github actions does not support the `secrets` context in `if` blocks.
if [[ -n "${DISCORD_WEBHOOK}" ]]; then
echo "available=true" >> $GITHUB_OUTPUT
else
echo "available=false" >> $GITHUB_OUTPUT
fi
- name: Checkout Repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
ref: ${{ github.event.release.tag_name }}
- name: Extract Stable Release Metadata
id: metadata
if: ${{ steps.webhook_secrets_check.outputs.available == 'true' }}
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
RELEASE_URL: ${{ github.event.release.html_url }}
run: |
set -eu
git fetch origin main --tags --force
BASE_TAG="$(git tag --sort=-version:refname 'v*' | grep -Fxv "$RELEASE_TAG" | head -n 1 || true)"
COMPARE_URL="${RELEASE_URL}"
if [ -n "$BASE_TAG" ]; then
COMPARE_URL="https://github.com/${GITHUB_REPOSITORY}/compare/${BASE_TAG}...${RELEASE_TAG}"
fi
{
echo "base_tag=${BASE_TAG}"
echo "compare_url=${COMPARE_URL}"
} >> "$GITHUB_OUTPUT"
notify-discord:
name: Notify Discord Release
needs:
- prepare-release-notification
- publish-helm-chart
if: ${{ needs.prepare-release-notification.outputs.available == 'true' }}
permissions: {}
uses: ./.github/workflows/notify-discord-release-notes.yml
secrets:
discord_webhook: ${{ secrets.DISCORD_STABLE_WEBHOOK }}
with:
channel: stable
current_version: ${{ github.event.release.tag_name }}
predicted_version: ${{ github.event.release.tag_name }}
details_url: ${{ github.event.release.html_url }}
candidate_sha: ${{ github.sha }}
base_tag: ${{ needs.prepare-release-notification.outputs.base_tag }}
compare_url: ${{ needs.prepare-release-notification.outputs.compare_url }}
mention_text: ${{ vars.DISCORD_STABLE_MENTIONS }}