Skip to content

fix(booking): finish the empty-day and minimum-notice explanation (#20) #83

fix(booking): finish the empty-day and minimum-notice explanation (#20)

fix(booking): finish the empty-day and minimum-notice explanation (#20) #83

name: Docker publish
# Builds the multi-arch (amd64 + arm64) image from the repo Dockerfile.
# * PR → build only (catches cross-arch build breaks early, e.g. an
# amd64-only step slipping back in). Nothing is pushed.
# * push to dev → push `:dev` + `:sha-<short>`. Pre-release, for deploying a
# branch to a real instance to test it before it reaches main.
# Deliberately does NOT move `:edge` or `:latest`.
# * push to main → push `:edge` + `:sha-<short>` (bleeding edge).
# * push a `vX.Y.Z` tag → push `:X.Y.Z`, `:X.Y`, and `:latest`, then cut a GitHub
# Release. So `:latest` always tracks the newest *release*,
# never raw main.
#
# Pin a deployment to `:sha-<short>`, never to `:dev` or `:edge` — those move under
# you, and then nothing records which commit an instance is actually running.
on:
push:
branches: [main, dev]
tags: ['v*.*.*']
pull_request:
concurrency:
group: docker-publish-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
# Hardcoded lowercase — GHCR tags reject the repo's actual "Calnode/calnode"
# casing (${{ github.repository }} would break the push).
IMAGE_NAME: calnode/calnode
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Computes the tag set from the git ref:
# main → edge, sha-<short>
# dev → dev, sha-<short>
# vX.Y.Z tag → X.Y.Z, X.Y, and latest (latest=auto only fires on a semver tag)
#
# sha- is emitted for every branch build, not just the default one, so a
# pre-release deploy can be pinned to an immutable tag that names its commit.
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=edge,branch=main
type=ref,event=branch,enable=${{ github.ref == 'refs/heads/dev' }}
type=sha
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build (push on branch pushes and on tags)
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.meta.outputs.version }}
COMMIT=${{ github.sha }}
release:
# Only on a version tag, and only once the image built + pushed.
if: startsWith(github.ref, 'refs/tags/v')
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
# Pull the matching version's section out of CHANGELOG.md for the release body,
# so the GitHub Release and the CHANGELOG stay identical. Index-based (not a `\[`
# regex) so it's portable across awk flavours. Falls back to GitHub's
# auto-generated notes if there's no CHANGELOG entry for the tag.
- name: Extract release notes from CHANGELOG
id: notes
run: |
version="${GITHUB_REF_NAME#v}"
awk -v tag="## [${version}]" '
index($0, tag)==1 {cap=1; next}
index($0, "## [")==1 && cap==1 {cap=0}
substr($0,1,1)=="[" && cap==1 {exit}
cap {print}
' CHANGELOG.md > release-notes.md
if [ -s release-notes.md ]; then
echo "have_notes=true" >> "$GITHUB_OUTPUT"
else
echo "have_notes=false" >> "$GITHUB_OUTPUT"
fi
# Preinstalled gh CLI + GITHUB_TOKEN (no third-party action — keeps the
# supply-chain surface small).
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ "${{ steps.notes.outputs.have_notes }}" = "true" ]; then
gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" \
--notes-file release-notes.md --verify-tag
else
gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" \
--generate-notes --verify-tag
fi