-
Notifications
You must be signed in to change notification settings - Fork 2
107 lines (100 loc) · 3.66 KB
/
release.yml
File metadata and controls
107 lines (100 loc) · 3.66 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Release
permissions:
contents: read
# description: |
# Build a github release on either pushed tag or a manual workflow call.
#
# At this moment, the only available asset is a release note.
on:
workflow_call:
inputs:
tag:
type: string
required: true
cliff-config:
type: string
required: false
default: '.cliff.toml'
description: 'Path to the git-cliff config file in the caller repository'
cliff-config-url:
type: string
required: false
default: 'https://raw.githubusercontent.com/go-openapi/ci-workflows/refs/heads/master/.cliff.toml'
description: 'URL to the remote git-cliff config file (used if local config does not exist)'
jobs:
gh-release:
name: Create release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
-
name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 0
-
name: Extract tag message
id: get-message
# tag message is not retrieved unless we fetch the ref explictly
run: |
set -x
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
MESSAGE=$(git tag -l '${{ inputs.tag }}' --format='%(contents:subject)
%(contents:body)
')
export MESSAGE
{
echo "message<<EOF"
printenv MESSAGE
echo 'EOF'
} >> "${GITHUB_OUTPUT}"
echo "Message in git tag ${{ inputs.tag }}"
echo "$MESSAGE"
-
name: Check for local cliff config
id: check-config
run: |
if [ -f "${{ inputs.cliff-config }}" ]; then
echo "exists=true" >> "${GITHUB_OUTPUT}"
echo "::notice title=release::Local config file '${{ inputs.cliff-config }}' found"
else
echo "exists=false" >> "${GITHUB_OUTPUT}"
echo "::notice title=release::Local config file '${{ inputs.cliff-config }}' not found, will use remote config"
fi
-
name: Generate release notes (local config)
# this uses git-cliff to generate a release note from the commit history
if: ${{ steps.check-config.outputs.exists == 'true' }}
id: notes-local
env:
GITHUB_TOKEN: ${{ github.token }}
GITHUB_REPO: ${{ github.repository }}
uses: orhun/git-cliff-action@e16f179f0be49ecdfe63753837f20b9531642772 # v4.7.0
with:
config: ${{ inputs.cliff-config }}
args: >-
--current
--with-tag-message '${{ steps.get-message.outputs.message }}'
-
name: Generate release notes (remote config)
# this uses git-cliff action with remote config URL
if: ${{ steps.check-config.outputs.exists == 'false' }}
id: notes-remote
env:
GITHUB_TOKEN: ${{ github.token }}
GITHUB_REPO: ${{ github.repository }}
uses: orhun/git-cliff-action@e16f179f0be49ecdfe63753837f20b9531642772 # v4.7.0
with:
config: ''
args: >-
--config-url '${{ inputs.cliff-config-url }}'
--current
--with-tag-message '${{ steps.get-message.outputs.message }}'
-
name: Create github release
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
with:
body: ${{ steps.check-config.outputs.exists == 'true' && steps.notes-local.outputs.content || steps.notes-remote.outputs.content }}
tag_name: ${{ inputs.tag }}
generate_release_notes: false # skip auto-generated release notes from github API