-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (59 loc) · 2.16 KB
/
Copy pathrelease.yml
File metadata and controls
66 lines (59 loc) · 2.16 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
name: Release
# Creates the tag and GitHub release for a new controller version once it lands
# on main. The version comes from the operator image in controller.yaml, the
# notes from its CHANGELOG.md section.
on:
push:
branches:
- main
paths:
- controller.yaml
workflow_dispatch:
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Read version
id: version
run: |
VERSION=$(grep -oE 'localstack/localstack-k8s-operator:v[0-9]+\.[0-9]+\.[0-9]+' controller.yaml | head -1 | cut -d: -f2)
if [ -z "$VERSION" ]; then
echo "::error::controller.yaml doesn't reference a localstack/localstack-k8s-operator:vX.Y.Z image"
exit 1
fi
if git rev-parse -q --verify "refs/tags/$VERSION" >/dev/null; then
echo "$VERSION is already released"
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
# The section for the new version, up to the next heading or the reference links
- name: Extract release notes
if: steps.version.outputs.exists == 'false'
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
awk -v heading="## [${VERSION#v}]" '
in_section && ($0 ~ "^## \\[" || $0 ~ "^\\[[0-9]") { exit }
in_section { print; next }
index($0, heading) == 1 { in_section = 1 }
' CHANGELOG.md | sed -e '/./,$!d' > notes.md
if [ ! -s notes.md ]; then
echo "::error::No '## [${VERSION#v}]' section found in CHANGELOG.md"
exit 1
fi
- name: Create release
if: steps.version.outputs.exists == 'false'
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.version.outputs.version }}
run: |
gh release create "$VERSION" --target "$GITHUB_SHA" --title "$VERSION" \
--notes-file notes.md controller.yaml api-docs.md