-
Notifications
You must be signed in to change notification settings - Fork 14
144 lines (129 loc) · 5.06 KB
/
release.yaml
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Release
on:
push:
branches:
- "!not_activated_on_branches!*"
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-*"
jobs:
build:
name: Release
runs-on: ubuntu-latest
steps:
- name: Free some disk space on runner
run: |
df -h
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo rm -rf /usr/lib/jvm
sudo rm -rf /usr/lib/firefox
sudo rm -rf /opt/microsoft/powershell
sudo rm -rf /opt/hostedtoolcache
echo "free space after cleanup:"
df -h
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: 1.18
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Generate details for creating release notes
id: generate-release-details
shell: bash
run: |
set -o xtrace
RELEASE_BRANCH="main"
RELEASE_VERSION=${GITHUB_REF#refs/*/}
major=$(echo "$RELEASE_VERSION" | sed 's/^v\(.*\)/\1/' | cut -d. -f1)
minor=$(echo "$RELEASE_VERSION" | cut -d. -f2)
revision=$(echo "$RELEASE_VERSION" | cut -d. -f3 | cut -d- -f1)
if [ "$revision" -gt 0 ];then
revision=$(($revision-1))
RELEASE_BRANCH="release-${major}.${minor}"
elif [ "$minor" -gt 0 ]; then
minor=$(($minor-1))
elif [ "$major" -gt 0 ]; then
major=$(($major-1))
else
echo "Please validate that the tag release version(${RELEASE_VERSION}) conforms to semver."
exit 1
fi
git log -3 --format=oneline
LAST_TAG="v${major}.${minor}.${revision}"
echo "Last release tag - $LAST_TAG"
START_SHA=$(git rev-list -n 1 $LAST_TAG)
echo "Release note generator start SHA - $START_SHA"
END_SHA=$(git rev-list -n 1 $RELEASE_VERSION)
echo "Release note generator end SHA - $END_SHA"
echo "::set-output name=start-sha::$START_SHA"
echo "::set-output name=end-sha::$END_SHA"
echo "::set-output name=release-version::$RELEASE_VERSION"
echo "::set-output name=prev-release-version::$LAST_TAG"
echo "::set-output name=repo-name::$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')"
echo "::set-output name=repo-org::$(echo '${{ github.repository }}' | awk -F '/' '{print $1}')"
echo "::set-output name=release-branch::$RELEASE_BRANCH"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install release-note dependency
run: |
go install k8s.io/release/cmd/[email protected]
- name: Get Time
id: time
uses: nanzm/[email protected]
with:
format: 'YYYYMMDDHHmmss'
- name: Generate release notes
id: get-release-notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
release-notes \
--github-base-url https://github.com \
--org ${{ steps.generate-release-details.outputs.repo-org }} \
--repo ${{ steps.generate-release-details.outputs.repo-name }} \
--branch ${{ steps.generate-release-details.outputs.release-branch }} \
--required-author "" \
--start-sha ${{ steps.generate-release-details.outputs.start-sha }} \
--end-sha ${{ steps.generate-release-details.outputs.end-sha }} \
--output /tmp/${{ steps.time.outputs.time }}-bin-notes
- name: Get Github Release notes
uses: octokit/[email protected]
id: get-github-release-notes
with:
route: POST /repos/{owner}/{repo}/releases/generate-notes
owner: ${{ steps.generate-release-details.outputs.repo-org }}
repo: ${{ steps.generate-release-details.outputs.repo-name }}
tag_name: ${{ steps.generate-release-details.outputs.release-version }}
previous_tag_name: ${{ steps.generate-release-details.outputs.prev-release-version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 'Identify New Contributors Section'
id: get-new-contributors
run: |
githubOutput="/tmp/${{ steps.time.outputs.time }}-github-output"
echo "${{ fromJson(steps.get-github-release-notes.outputs.data).body }}" > "$githubOutput"
- name: Generate the release notes
shell: bash
run: |
NEW_CONTRIBUTORS=$(sed -n '/## New Contributors/,$p' /tmp/${{ steps.time.outputs.time }}-github-output)
RELEASE_TOOL_NOTES=$(sed 's/### Uncategorized/### Miscellaneous/g' /tmp/${{ steps.time.outputs.time }}-bin-notes)
RELEASE_NOTES=$(cat <<-END
$RELEASE_TOOL_NOTES
$NEW_CONTRIBUTORS
END
)
echo "$RELEASE_NOTES"
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
echo "$RELEASE_NOTES" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- id: create_draft_release
name: Create Draft Release
uses: softprops/action-gh-release@v1
with:
draft: true
body: ${{ env.RELEASE_NOTES }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}