-
-
Notifications
You must be signed in to change notification settings - Fork 4
104 lines (89 loc) · 3.02 KB
/
Copy pathcreate-release.yml
File metadata and controls
104 lines (89 loc) · 3.02 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
name: Create release
on:
workflow_call:
inputs:
image-name:
description: "The name of the image"
required: true
type: string
version:
description: "The version of the image"
required: true
type: string
pretty-version:
description: "The pretty version of the image"
required: true
type: string
latest-image-ref:
description: "The latest image reference"
required: true
type: string
permissions:
contents: write
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Fetch Changelogs
id: download-changelogs
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v4
with:
pattern: changelog-${{ inputs.image-name }}-*
merge-multiple: true
path: /tmp/changelogs
- name: Fetch SBOMs
id: download-sbom
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v4
with:
pattern: "*.spdx.json"
merge-multiple: true
path: /tmp/sboms
- name: Compress SBOMs
id: compress-sbom
shell: bash
run: |
mkdir -p "${{ steps.download-sbom.outputs.download-path }}" && cd $_
for f in *.spdx.json; do
gzip -9 "$f"
done
- name: Prepare Release
id: prepare-release
shell: bash
run: |
echo "Automated release for ${{ inputs.image-name }} version \`${{ inputs.version }}\`." > ./changelog.md
for changelog in ${{ steps.download-changelogs.outputs.download-path }}/*.txt; do
# Remove empty Package Changes
sed -i '/^#### Package Changes$/{
N
N
/#### Package Changes\n[[:space:]]*-[[:space:]]*\n[[:space:]]*$/d
}' $changelog
# Remove empty Commits
sed -i '/^#### Commits$/{
N
N
/#### Commits\n[[:space:]]*-[[:space:]]*\n[[:space:]]*$/d
}' $changelog
# If there are no changes, remove the section altogether
sed -zi 's/\n### Changes since[^#]*$//' $changelog
cat $changelog >> ./changelog.md
done
cat <<'EOF' >> ./changelog.md
## How to rebase
If you're already using this image, upgrade with the following command:
```bash
sudo bootc upgrade
```
To switch to this image from another, type the following command in your terminal:
```bash
sudo bootc switch ${{ inputs.latest-image-ref }}
```
EOF
- name: Create Release
uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v2
with:
name: "${{ inputs.image-name }} version ${{ inputs.version }}"
tag_name: ${{ inputs.version }}
body_path: ./changelog.md
make_latest: true
files: "${{ steps.download-sbom.outputs.download-path }}/*.spdx.json.gz"