189 lines
6.3 KiB
YAML
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
|
with:
|
|
fetch-depth: 1
|
|
ref: ${{ github.sha }}
|
|
|
|
- name: Set Up QEMU for Multi-Arch Builds
|
|
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
|
|
with:
|
|
cache-image: false
|
|
|
|
- name: Set Up Docker Buildx
|
|
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
|
|
|
- name: Authenticate to Docker Hub
|
|
if: ${{ vars.DOCKERHUB_REGISTRY != '' }}
|
|
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Authenticate to GitHub Container Registry
|
|
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ github.token }}
|
|
|
|
- name: Docker meta
|
|
id: meta
|
|
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.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@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
|
with:
|
|
fetch-depth: 1
|
|
ref: ${{ github.sha }}
|
|
|
|
- name: Set Up Helm
|
|
uses: azure/setup-helm@b9e51907a09c216f16ebe8536097933489208112 # v4.3.0
|
|
|
|
- name: Authenticate to GitHub Container Registry
|
|
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
|
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 }}
|