-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (62 loc) · 2.47 KB
/
github-release.yml
File metadata and controls
68 lines (62 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Source: https://github.com/panubo/reference-github-actions/blob/main/github-release.yml
# Description: Create a GitHub release
# LICENSE: MIT License, Copyright (c) 2021-2025 Volt Grid Pty Ltd t/a Panubo
#
# This workflow supports release candidate tags. If a tag contains "-rc" for
# example "v1.2.3-rc.1" then the release will be marked as a prerelease.
# Additionally when generating changelog for release notes any RC releases will
# be ignored.
#
# If you want to provide additional release notes you can add a
# _ci_release_notes to a Makefile in the root of the repo. This will be called
# while generating the release notes and will be attended to the end of the auto
# generated release notes. If the command is absent or fails the failure will be
# ignored. Additionally the tag/ref_name will be passed with TAG="${TAG#v}"
# which will strip the "v" prefix from the tag, this is useful for listing
# container images with their tag.
name: GitHub Release
on:
push:
tags:
- "v*"
workflow_call:
permissions:
contents: write
jobs:
build:
name: Create GitHub Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0 # Required for git log to work
- name: Get Release Notes
env:
TAG: ${{ github.ref_name }}
id: get_release_notes
run: |
tag1="$(git -c 'versionsort.suffix=-' tag --sort=-v:refname | head -1)"
tag2="$(git -c 'versionsort.suffix=-' tag --sort=-v:refname | grep -v '\-rc' | grep -v -w "${tag1}" | head -1)"
{
echo 'notes<<EOF'
echo "## Changes since last release:"
echo
git log --graph --pretty=tformat:'%s %H' --abbrev-commit --date=relative "${tag1}"..."${tag2}"
echo
echo "**Full Changelog**: https://github.com/${GITHUB_REPOSITORY}/compare/${tag2}...${tag1}"
# Optionally allow the Makefile to generate some release notes too
make _ci_release_notes TAG=${TAG#v} || true
echo EOF
} >> "${GITHUB_OUTPUT}"
- name: Create Release
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.ref_name }}
run: |
gh release create "$TAG" \
--title "$TAG" \
--notes "${{ steps.get_release_notes.outputs.notes }}" \
--draft=false \
--prerelease="${{ contains(github.ref, '-rc') }}"