Skip to content

Commit d509c91

Browse files
committed
Update workflows
1 parent 0a97ec4 commit d509c91

File tree

2 files changed

+115
-14
lines changed

2 files changed

+115
-14
lines changed

.github/workflows/github-release.yml

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
# Source: https://github.com/panubo/reference-github-actions/blob/main/github-release.yml
22
# Description: Create a GitHub release
33
# LICENSE: MIT License, Copyright (c) 2021-2025 Volt Grid Pty Ltd t/a Panubo
4+
#
5+
# This workflow supports release candidate tags. If a tag contains "-rc" for
6+
# example "v1.2.3-rc.1" then the release will be marked as a prerelease.
7+
# Additionally when generating changelog for release notes any RC releases will
8+
# be ignored.
9+
#
10+
# If you want to provide additional release notes you can add a
11+
# _ci_release_notes to a Makefile in the root of the repo. This will be called
12+
# while generating the release notes and will be attended to the end of the auto
13+
# generated release notes. If the command is absent or fails the failure will be
14+
# ignored. Additionally the tag/ref_name will be passed with TAG="${TAG#v}"
15+
# which will strip the "v" prefix from the tag, this is useful for listing
16+
# container images with their tag.
417

518
name: GitHub Release
619

@@ -24,23 +37,32 @@ jobs:
2437
fetch-depth: 0 # Required for git log to work
2538

2639
- name: Get Release Notes
40+
env:
41+
TAG: ${{ github.ref_name }}
2742
id: get_release_notes
2843
run: |
29-
NOTES=$(git log --pretty=format:%s $(git tag --sort=-v:refname | head -1)...$(git tag --sort=-v:refname | head -2 | tail -1) | awk '{ print "-", $0 }')
30-
printf "notes<<EOF\\n%s\\nEOF\\n" "${NOTES}" >> "$GITHUB_OUTPUT"
44+
tag1="$(git -c 'versionsort.suffix=-' tag --sort=-v:refname | head -1)"
45+
tag2="$(git -c 'versionsort.suffix=-' tag --sort=-v:refname | grep -v '\-rc' | grep -v -w "${tag1}" | head -1)"
46+
{
47+
echo 'notes<<EOF'
48+
echo "## Changes since last release:"
49+
echo
50+
git log --graph --pretty=tformat:'%s %H' --abbrev-commit --date=relative "${tag1}"..."${tag2}"
51+
echo
52+
echo "**Full Changelog**: https://github.com/${GITHUB_REPOSITORY}/compare/${tag2}...${tag1}"
53+
# Optionally allow the Makefile to generate some release notes too
54+
make _ci_release_notes TAG=${TAG#v} || true
55+
echo EOF
56+
} >> "${GITHUB_OUTPUT}"
3157
3258
- name: Create Release
3359
id: create_release
34-
uses: actions/create-release@v1
3560
env:
36-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
37-
with:
38-
tag_name: ${{ github.ref }}
39-
release_name: ${{ github.ref }}
40-
body: |
41-
Changes since last release:
42-
43-
${{ steps.get_release_notes.outputs.notes }}
44-
45-
draft: false
46-
prerelease: false
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
TAG: ${{ github.ref_name }}
63+
run: |
64+
gh release create "$TAG" \
65+
--title "Release $TAG" \
66+
--notes "${{ steps.get_release_notes.outputs.notes }}" \
67+
--draft=false \
68+
--prerelease="${{ contains(github.ref, '-rc') }}"
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Source: https://github.com/panubo/reference-github-actions/blob/main/docker-images/update-registry-metadata.yml
2+
3+
name: Update Registry Metadata
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
10+
env:
11+
GITHUB_ROLE_ARN: arn:aws:iam::461800378586:role/GitHubECRPublic
12+
13+
permissions:
14+
id-token: write # Required for OIDC
15+
contents: read # This is required for actions/checkout
16+
17+
jobs:
18+
update_repo_metadata:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v5
23+
24+
- name: Get repo name
25+
id: image_name
26+
run: |
27+
sed -E -e 's/docker-//' -e 's/^/image_name=/' <<<"${{ github.repository }}" >> "$GITHUB_OUTPUT"
28+
29+
- name: Get repo description
30+
id: repo_description
31+
run: |
32+
description=$(gh repo view ${{ github.repository }} --json description -q .description)
33+
echo "description=$description" >> "$GITHUB_OUTPUT"
34+
env:
35+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
37+
# There are numerous issues with extracting a Usage section
38+
# * Varying levels of header ie "# Usage" or "## Usage"
39+
# * The match should continue until the next header of the same level or a higher level
40+
# * The next header could be indented in a quote or alert/note eg "> # Next Section"
41+
# * The section name could differ, Usage | usage | Install | Example etc
42+
# Note: if we put this back in it needs to be added to the Update Catalog Data step
43+
# - name: Extract Usage from README
44+
# id: usage
45+
# run: |
46+
# if awk '/^#+ *Install \/ Usage/{flag=1; next} /^#+/{flag=0} flag' README.md | grep -q .; then
47+
# usage=$(awk '/^#+ *Install \/ Usage/{flag=1; next} /^#+/{flag=0} flag' README.md)
48+
# echo "usage<<EOF" >> "$GITHUB_OUTPUT"
49+
# echo "$usage" >> "$GITHUB_OUTPUT"
50+
# echo "EOF" >> "$GITHUB_OUTPUT"
51+
# fi
52+
53+
- name: Configure AWS Credentials
54+
uses: aws-actions/configure-aws-credentials@v4
55+
with:
56+
role-to-assume: ${{ env.GITHUB_ROLE_ARN }}
57+
aws-region: us-east-1 # ECR Public is in us-east-1
58+
59+
- name: Update ECR Repository Catalog Data
60+
env:
61+
# ECR only wants the image_name not owner/image_name so we add image_name as an env then strip the owner with bash variable manipulation
62+
IMAGE_NAME: ${{ steps.image_name.outputs.image_name }}
63+
run: |
64+
set -x
65+
aws ecr-public get-repository-catalog-data --repository-name ${IMAGE_NAME#*/} > catalog-data.json
66+
if [[ -n "${{ steps.repo_description.outputs.description }}" ]]; then
67+
jq --arg description "${{ steps.repo_description.outputs.description }}" '.catalogData.description = $description' catalog-data.json > catalog-data.json.tmp && mv catalog-data.json.tmp catalog-data.json
68+
fi
69+
jq --arg about "$(cat README.md)" --arg repo "${IMAGE_NAME#*/}" '.catalogData.aboutText = $about | .repositoryName = $repo | del(.catalogData.logoUrl)' catalog-data.json > catalog-data.json.tmp && mv catalog-data.json.tmp catalog-data.json
70+
aws ecr-public put-repository-catalog-data --repository-name ${IMAGE_NAME#*/} --cli-input-json file://catalog-data.json
71+
72+
- name: Update Quay.io Repository Description
73+
run: |
74+
JSON_DESCRIPTION="$(jq -n --arg desc "$(<README.md)" '{description: $desc}')"
75+
curl -sSf -X PUT \
76+
-H "Authorization: Bearer ${{ secrets.PANUBUILD_QUAYIO_API_TOKEN }}" \
77+
-H "Content-Type: application/json" \
78+
-d "${JSON_DESCRIPTION}" \
79+
'https://quay.io/api/v1/repository/${{ steps.image_name.outputs.image_name }}'

0 commit comments

Comments
 (0)