Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name-template: "$RESOLVED_VERSION"
tag-template: "$RESOLVED_VERSION"
categories:
- title: "🚀 Features"
semver-increment: minor
when:
labels:
- feature
- enhancement
- title: "🐛 Bug fixes"
semver-increment: patch
when:
labels:
- bug
- bugfix
- fix
- title: "🧰 Maintenance"
semver-increment: patch
when:
labels:
- chore
- maintenance
- type: pre-exclude
when:
labels:
- skip-changelog
- type: version-resolver
semver-increment: major
when:
labels:
- breaking
- major
- type: version-resolver
semver-increment: patch
template: |
## What's Changed

$CHANGES

**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...$RESOLVED_TAG
137 changes: 109 additions & 28 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,54 +1,135 @@
name: publish
name: Release

on:
push:
tags:
- '*'
workflow_dispatch:

permissions:
actions: read
checks: write
contents: read
packages: write
permissions: {}

concurrency:
group: release-${{ github.repository }}
cancel-in-progress: false

jobs:
publish:
plan:
if: github.ref_name == github.event.repository.default_branch
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
has-changes: ${{ steps.plan.outputs.has-changes }}
tag: ${{ steps.version.outputs.tag }}
steps:
- uses: actions/checkout@v7
- id: plan
uses: hoverkraft-tech/ci-github-publish/actions/release/plan@a0a9d185c51c10710a5987822e78feb2b5ce1932 # 0.29.0
with:
fetch-depth: 1
github-token: ${{ github.token }}

- id: version
env:
PLANNED_TAG: ${{ steps.plan.outputs.tag }}
run: |
if [[ ! "$PLANNED_TAG" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then
echo "Release Drafter returned an invalid stable semantic version: $PLANNED_TAG" >&2
exit 1
fi

- name: Get TAG
id: get_tag
run: echo TAG=${GITHUB_REF#refs/tags/} >> $GITHUB_ENV
major=${BASH_REMATCH[1]}
minor=${BASH_REMATCH[2]}
patch=${BASH_REMATCH[3]}
if (( major == 0 && minor < 3 || major == 0 && minor == 3 && patch < 7 )); then
PLANNED_TAG=0.3.7
fi

- name: Get Repo Owner
id: get_repo_owner
run: echo "REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" > $GITHUB_ENV
echo "tag=$PLANNED_TAG" >> "$GITHUB_OUTPUT"

publish-image:
needs: plan
if: needs.plan.outputs.has-changes == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.sha }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4

- name: Login to Docker Registry
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
username: ${{ github.actor }}
password: ${{ github.token }}
registry: ghcr.io

- name: Local build
id: local_build
- name: Publish multi-architecture image
uses: docker/build-push-action@v7
with:
build-args: |
Version=${{ env.TAG }}
Version=${{ needs.plan.outputs.tag }}
GitCommit=${{ github.sha }}
outputs: "type=registry,push=true"
platforms: linux/amd64,linux/arm/v7,linux/arm64
push: true
tags: |
ghcr.io/${{ env.REPO_OWNER }}/registry-creds:${{ github.sha }}
ghcr.io/${{ env.REPO_OWNER }}/registry-creds:${{ env.TAG }}
ghcr.io/${{ env.REPO_OWNER }}/registry-creds:latest
ghcr.io/${{ github.repository }}:${{ github.sha }}
ghcr.io/${{ github.repository }}:${{ needs.plan.outputs.tag }}
ghcr.io/${{ github.repository }}:latest

- name: Make container package public
env:
GH_TOKEN: ${{ secrets.GHCR_PACKAGE_ADMIN_TOKEN }}
run: |
if [[ -z "$GH_TOKEN" ]]; then
echo "GHCR_PACKAGE_ADMIN_TOKEN is required to make the container package public." >&2
exit 1
fi

package_visibility_endpoint="/orgs/${GITHUB_REPOSITORY_OWNER}/packages/container/registry-creds/visibility"
gh api --method PUT \
"$package_visibility_endpoint" \
-f visibility=public

publish-release:
needs: [plan, publish-image]
if: needs.plan.outputs.has-changes == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: read
steps:
- uses: hoverkraft-tech/ci-github-publish/actions/release/create@a0a9d185c51c10710a5987822e78feb2b5ce1932 # 0.29.0
with:
tag: ${{ needs.plan.outputs.tag }}
target-sha: ${{ github.sha }}
github-token: ${{ github.token }}

update-manifests:
needs: [plan, publish-image, publish-release]
if: needs.plan.outputs.has-changes == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event.repository.default_branch }}

- name: Update deployment manifests
env:
IMAGE: ghcr.io/${{ github.repository }}
TAG: ${{ needs.plan.outputs.tag }}
run: make shrinkwrap

- uses: hoverkraft-tech/ci-github-common/actions/create-and-merge-pull-request@3a27d31e9ccefbe9609cc9165017ed100ff34a22 # 0.38.0
with:
github-token: ${{ github.token }}
branch: release/update-manifest-${{ needs.plan.outputs.tag }}
title: "chore(release): update manifest for ${{ needs.plan.outputs.tag }}"
body: "Update the deployment manifest to use registry-creds ${{ needs.plan.outputs.tag }}."
commit-message: "chore(release): update manifest for ${{ needs.plan.outputs.tag }}"
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@ The normal process is as follows, which becomes tedious and repetitive when you

* [Install the tool](GUIDE.md)

## Releases

Run the **Release** workflow manually from the default branch. Release Drafter
uses pull-request labels to calculate Semantic Versioning increments:
`breaking`/`major` for major releases, `feature`/`enhancement` for minor
releases, and `bug`/`bugfix`/`fix` or `chore`/`maintenance` for patch releases.
The first release is floored at `0.3.7` to avoid conflicting with upstream
versions.

The workflow requires a `GHCR_PACKAGE_ADMIN_TOKEN` repository secret containing
a classic personal access token with package write access and permission to
change the container package visibility. GitHub Actions must also be allowed to
create and merge pull requests so the workflow can update the deployment
manifest.

## Do you use `registry-creds`?

`k3sup` was created by [Alex Ellis](https://github.com/users/alexellis/sponsorship) - the founder of [OpenFaaS &reg;](https://www.openfaas.com/) & [inlets](https://inlets.dev/).
Expand Down
Loading