mirror of
https://github.com/phusion/baseimage-docker.git
synced 2026-09-21 08:48:10 +00:00
Fix weekly release builds
- Fix quote handling in gh release list output - Gracefully skip tracks without existing releases - Increase release search limit to 100 - Add conditional checks to subsequent steps
This commit is contained in:
committed by
Jeshua Ben Joseph
parent
113d19ac83
commit
4a0a4053ae
@@ -8,6 +8,8 @@ on:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
packages: write
|
packages: write
|
||||||
|
id-token: write
|
||||||
|
pull-requests: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -15,6 +17,8 @@ jobs:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
packages: write
|
packages: write
|
||||||
|
id-token: write
|
||||||
|
pull-requests: read
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -31,34 +35,43 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
LATEST_TAG=$(gh release list \
|
LATEST_TAG=$(gh release list \
|
||||||
--repo ${{ github.repository }} \
|
--repo ${{ github.repository }} \
|
||||||
|
--limit 100 \
|
||||||
--exclude-pre-releases \
|
--exclude-pre-releases \
|
||||||
--exclude-drafts \
|
--exclude-drafts \
|
||||||
--json tagName \
|
--json tagName \
|
||||||
--jq '[.[] | select(.tagName | startswith("${{ matrix.ubuntu_codename }}-"))] | first | .tagName')
|
--jq "[.[] | select(.tagName | startswith(\"${{ matrix.ubuntu_codename }}-\"))] | first | .tagName" | jq -r '.')
|
||||||
if [ -z "${LATEST_TAG}" ]; then
|
|
||||||
echo "No release found for ${{ matrix.ubuntu_codename }} track" >&2
|
if [ -z "${LATEST_TAG}" ] || [ "${LATEST_TAG}" == "null" ]; then
|
||||||
exit 1
|
echo "No release found for ${{ matrix.ubuntu_codename }} track. Skipping."
|
||||||
|
echo "should_build=false" >> $GITHUB_OUTPUT
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Extract version and bump patch: noble-1.0.2 -> noble-1.0.3
|
# Extract version and bump patch: noble-1.0.2 -> noble-1.0.3
|
||||||
if ! echo "${LATEST_TAG}" | grep -qE '^[a-z]+-[0-9]+\.[0-9]+\.[0-9]+$'; then
|
if ! echo "${LATEST_TAG}" | grep -qE '^[a-z]+-[0-9]+\.[0-9]+\.[0-9]+$'; then
|
||||||
echo "Tag '${LATEST_TAG}' does not match expected format <codename>-<major>.<minor>.<patch>" >&2
|
echo "Tag '${LATEST_TAG}' does not match expected format <codename>-<major>.<minor>.<patch>" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PREFIX="${LATEST_TAG%.*}" # noble-1.0
|
PREFIX="${LATEST_TAG%.*}" # noble-1.0
|
||||||
PATCH="${LATEST_TAG##*.}" # 2
|
PATCH="${LATEST_TAG##*.}" # 2
|
||||||
NEXT_PATCH=$((PATCH + 1))
|
NEXT_PATCH=$((PATCH + 1))
|
||||||
NEXT_TAG="${PREFIX}.${NEXT_PATCH}" # noble-1.0.3
|
NEXT_TAG="${PREFIX}.${NEXT_PATCH}" # noble-1.0.3
|
||||||
|
|
||||||
echo "current_tag=${LATEST_TAG}" >> $GITHUB_OUTPUT
|
echo "current_tag=${LATEST_TAG}" >> $GITHUB_OUTPUT
|
||||||
echo "next_tag=${NEXT_TAG}" >> $GITHUB_OUTPUT
|
echo "next_tag=${NEXT_TAG}" >> $GITHUB_OUTPUT
|
||||||
|
echo "should_build=true" >> $GITHUB_OUTPUT
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
|
||||||
- name: Checkout release tag
|
- name: Checkout release tag
|
||||||
|
if: steps.release.outputs.should_build == 'true'
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: ${{ steps.release.outputs.current_tag }}
|
ref: ${{ steps.release.outputs.current_tag }}
|
||||||
|
|
||||||
- name: Prepare
|
- name: Prepare
|
||||||
|
if: steps.release.outputs.should_build == 'true'
|
||||||
id: prep
|
id: prep
|
||||||
run: |
|
run: |
|
||||||
DOCKER_IMAGE=phusion/baseimage
|
DOCKER_IMAGE=phusion/baseimage
|
||||||
@@ -72,11 +85,13 @@ jobs:
|
|||||||
echo "platforms=${PLATFORMS}" >> $GITHUB_OUTPUT
|
echo "platforms=${PLATFORMS}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
|
if: steps.release.outputs.should_build == 'true'
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
with:
|
with:
|
||||||
platforms: ${{ steps.prep.outputs.platforms }}
|
platforms: ${{ steps.prep.outputs.platforms }}
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
|
if: steps.release.outputs.should_build == 'true'
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
install: true
|
install: true
|
||||||
@@ -84,19 +99,22 @@ jobs:
|
|||||||
driver-opts: image=moby/buildkit:latest
|
driver-opts: image=moby/buildkit:latest
|
||||||
|
|
||||||
- name: Login to GHCR (Github Container Registry)
|
- name: Login to GHCR (Github Container Registry)
|
||||||
|
if: steps.release.outputs.should_build == 'true'
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ github.token }}
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
|
if: steps.release.outputs.should_build == 'true'
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
- name: Build and Push
|
- name: Build and Push
|
||||||
|
if: steps.release.outputs.should_build == 'true'
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: image
|
context: image
|
||||||
@@ -107,22 +125,28 @@ jobs:
|
|||||||
no-cache: true
|
no-cache: true
|
||||||
|
|
||||||
- name: Check gh auth status
|
- name: Check gh auth status
|
||||||
|
if: steps.release.outputs.should_build == 'true'
|
||||||
run: gh auth status
|
run: gh auth status
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
|
||||||
- name: Create GitHub Release
|
- name: Create GitHub Release
|
||||||
|
if: steps.release.outputs.should_build == 'true'
|
||||||
run: |
|
run: |
|
||||||
gh release create "${{ steps.release.outputs.next_tag }}" \
|
cat <<EOF > release_notes.md
|
||||||
--repo "${{ github.repository }}" \
|
Automated weekly security rebuild of \`${{ steps.release.outputs.current_tag }}\` with latest \`${{ matrix.base_image }}\` packages.
|
||||||
--target "${{ steps.release.outputs.current_tag }}" \
|
|
||||||
--title "${{ steps.release.outputs.next_tag }}" \
|
|
||||||
--notes "Automated weekly security rebuild of \`${{ steps.release.outputs.current_tag }}\` with latest \`${{ matrix.base_image }}\` packages.
|
|
||||||
|
|
||||||
Images pushed:
|
Images pushed:
|
||||||
- \`phusion/baseimage:${{ steps.release.outputs.next_tag }}\`
|
- \`phusion/baseimage:${{ steps.release.outputs.next_tag }}\`
|
||||||
- \`phusion/baseimage:${{ matrix.ubuntu_codename }}\`
|
- \`phusion/baseimage:${{ matrix.ubuntu_codename }}\`
|
||||||
- \`ghcr.io/${{ github.repository_owner }}/baseimage:${{ steps.release.outputs.next_tag }}\`
|
- \`ghcr.io/${{ github.repository_owner }}/baseimage:${{ steps.release.outputs.next_tag }}\`
|
||||||
- \`ghcr.io/${{ github.repository_owner }}/baseimage:${{ matrix.ubuntu_codename }}\`"
|
- \`ghcr.io/${{ github.repository_owner }}/baseimage:${{ matrix.ubuntu_codename }}\`
|
||||||
|
EOF
|
||||||
|
|
||||||
|
gh release create "${{ steps.release.outputs.next_tag }}" \
|
||||||
|
--repo "${{ github.repository }}" \
|
||||||
|
--target "$(git rev-parse HEAD)" \
|
||||||
|
--title "${{ steps.release.outputs.next_tag }}" \
|
||||||
|
--notes-file release_notes.md
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
|||||||
Reference in New Issue
Block a user