Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
|
with:
|
|
fetch-depth: 1
|
|
ref: ${{ github.sha }}
|
|
|
|
- name: Set Up QEMU for Multi-Arch Builds
|
|
uses: docker/setup-qemu-action@06116385d9baf250c9f4dcb4858b16962ea869c3 # v4.1.0
|
|
with:
|
|
cache-image: false
|
|
|
|
- name: Set Up Docker Buildx
|
|
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.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@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6.1.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@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.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@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
|
with:
|
|
fetch-depth: 1
|
|
ref: ${{ github.sha }}
|
|
|
|
- name: Set Up Helm
|
|
uses: azure/setup-helm@dda3372f752e03dde6b3237bc9431cdc2f7a02a2 # v5.0.0
|
|
|
|
- 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@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
|
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 }}
|