Files
grimmory/.github/workflows/publish-release.yml
T

124 lines
4.0 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
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: 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: |
grimmory/grimmory:${{ github.event.release.tag_name }}
grimmory/grimmory:latest
ghcr.io/grimmory-tools/grimmory:${{ github.event.release.tag_name }}
ghcr.io/grimmory-tools/grimmory:latest
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/grimmory-tools/grimmory:buildcache
cache-to: |
type=gha,scope=image-shared,mode=max
type=registry,ref=ghcr.io/grimmory-tools/grimmory:buildcache,mode=max
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 }}
permissions:
contents: read
steps:
- 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
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
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 }}