-
Notifications
You must be signed in to change notification settings - Fork 6
195 lines (164 loc) · 8.21 KB
/
Copy pathspring-post-release.yml
File metadata and controls
195 lines (164 loc) · 8.21 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
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
name: Perform Post Release Procedures
on:
workflow_call:
inputs:
preview:
description: 'True if this is a preview release'
required: false
type: string
default: 'false'
secrets:
SPRING_RELEASE_CHAT_WEBHOOK_URL:
required: false
GH_ACTIONS_REPO_TOKEN:
required: true
env:
GITHUB_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
jobs:
post-release:
runs-on: ubuntu-latest
if: github.event.created && startsWith(github.ref_name, 'v')
steps:
# Full history + a push-capable token, needed by "Merge Release Tag into Dev Branch" below.
- uses: actions/checkout@v7
with:
token: ${{ env.GITHUB_TOKEN }}
fetch-depth: 0
show-progress: false
- name: Compute Milestone
run: |
MILESTONE=${GITHUB_REF_NAME#v}
echo "MILESTONE=$MILESTONE" >> "$GITHUB_ENV"
echo "HOTFIX=$([[ $MILESTONE =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]] && echo true || echo false)" >> "$GITHUB_ENV"
- name: Transfer Commercial Issues to OSS Milestone
if: ${{ vars.COMMERCIAL != 'true' }}
shell: bash
env:
OSS_REPO: ${{ github.repository }}
COMMERCIAL_REPO: ${{ github.repository }}-commercial
run: |
# A missing repository/milestone (gh api failure) is swallowed rather than failing the job.
milestoneNumber=$(gh api "repos/$COMMERCIAL_REPO/milestones?state=open" --jq ".[] | select(.title == \"$MILESTONE\") | .number" 2>/dev/null) || true
if [ -z "$milestoneNumber" ]; then
echo "::notice title=No Commercial Milestone::No open '$MILESTONE' milestone found in $COMMERCIAL_REPO, skipping issue transfer"
exit 0
fi
gh issue list -R "$COMMERCIAL_REPO" --milestone "$MILESTONE" --state all --limit 1000 --json number,title,state,labels --jq '.[] | @base64' |
while read -r encodedIssue; do
issue=$(echo "$encodedIssue" | base64 -d)
number=$(jq -r '.number' <<< "$issue")
title=$(jq -r '.title' <<< "$issue")
state=$(jq -r '.state | ascii_downcase' <<< "$issue")
mapfile -t labels < <(jq -r '.labels[].name' <<< "$issue")
createArgs=(--title "$title" --body "Backport of: https://github.com/$COMMERCIAL_REPO/issues/$number" --milestone "$MILESTONE")
for label in "${labels[@]}"; do
gh label create "$label" -R "$OSS_REPO" 2>/dev/null || true
createArgs+=(--label "$label")
done
newIssueUrl=$(gh issue create -R "$OSS_REPO" "${createArgs[@]}")
if [ "$state" = "closed" ]; then
gh issue close "$newIssueUrl" -R "$OSS_REPO" --reason completed
fi
echo "::notice title=Transferred Issue::$COMMERCIAL_REPO#$number -> $newIssueUrl"
done
gh api "repos/$COMMERCIAL_REPO/milestones/$milestoneNumber" -X PATCH -f state=closed
- name: Changelog Config File
run: |
repositoryTeam=$(gh api repos/$GITHUB_REPOSITORY/collaborators --jq 'map(select(.role_name == "admin") | .login) | join(",")')
repositoryVisibility=$(gh repo view --json visibility --jq 'if .visibility == "PUBLIC" then "true" else "false" end')
cat > changelog.properties <<EOF
changelog.contributors.exclude.names=$repositoryTeam
changelog.issues.generate-links=$repositoryVisibility
changelog.issues.ports[0].label=type: backport
changelog.issues.ports[0].body-expression=Backport of gh-(\d+).*
changelog.add-sections=true
changelog.sections[0].title=:warning: Attention Required
changelog.sections[0].labels[0]=for: upgrade-attention
changelog.sections[0].summary.mode=member-comment
changelog.sections[0].summary.config.prefix=Attention required:
EOF
- name: Generate Changelog
uses: spring-io/github-changelog-generator@v0.0.14
with:
milestone: ${{ env.MILESTONE }}
token: ${{ env.GITHUB_TOKEN }}
config-file: changelog.properties
- name: GitHub Release
# Workaround until spring-io/spring-release-actions/publish-release-notes accepts a token
# input: https://github.com/spring-io/spring-release-actions/issues/202
# It hardcodes GH_TOKEN to the default github.token, ignoring the GH_ACTIONS_REPO_TOKEN
# (env.GITHUB_TOKEN) applied everywhere else in this workflow.
env:
PRERELEASE: ${{ (contains(github.ref_name, '-M') || contains(github.ref_name, '-RC')) && '--prerelease' || '' }}
run: |
gh release delete "$GITHUB_REF_NAME" -y || true
RELEASE_URL=$(gh release create "$GITHUB_REF_NAME" -F changelog.md $PRERELEASE --target "$GITHUB_SHA")
echo "::notice title=Release Page::$RELEASE_URL"
- name: Close Milestone
if: ${{ inputs.preview != 'true' }}
uses: spring-io/spring-release-actions/close-milestone@0.0.6
with:
version: ${{ env.MILESTONE }}
- name: Update Spring IO website for new version
if: ${{ env.HOTFIX != 'true' }}
uses: spring-io/spring-github-workflows/.github/actions/spring-website-project-version-update@main
with:
newVersion: ${{ env.MILESTONE }}
- name: Announce Release in Chat
if: ${{ inputs.preview != 'true' && env.CHAT_WEBHOOK_URL }}
uses: spring-io/spring-release-actions/announce-on-gchat@0.0.6
with:
gchat-webhook-url: ${{ env.CHAT_WEBHOOK_URL }}
version: ${{ env.MILESTONE }}
env:
CHAT_WEBHOOK_URL: ${{ secrets.SPRING_RELEASE_CHAT_WEBHOOK_URL }}
- id: support-window
if: ${{ env.HOTFIX != 'true' && !contains(env.MILESTONE, '-') }}
uses: spring-io/spring-release-actions/compute-support-window@0.0.6
with:
version: ${{ env.MILESTONE }}
- id: next-snapshot
if: ${{ env.HOTFIX != 'true' && steps.support-window.outputs.support-type != 'eol' }}
uses: spring-io/spring-release-actions/compute-next-snapshot@0.0.6
with:
version: ${{ env.MILESTONE }}
- name: Merge Release Tag into Dev Branch
if: ${{ env.HOTFIX != 'true' && steps.support-window.outputs.support-type != 'eol' }}
run: |
git config --global user.name 'Spring Builds'
git config --global user.email 'builds@springframework.org'
MAJOR_MINOR=$(echo "$MILESTONE" | cut -d '.' -f1-2)
DEV_BRANCH="$MAJOR_MINOR.x"
if ! git ls-remote --exit-code --heads origin "$DEV_BRANCH" > /dev/null
then
DEV_BRANCH='${{ github.event.repository.default_branch }}'
fi
# actions/checkout with fetch-depth:0 should already fetch tags, but don't rely on it silently.
git fetch origin tag "$GITHUB_REF_NAME"
git checkout "$DEV_BRANCH"
if git merge "$GITHUB_REF_NAME"
then
NEXT_VERSION="${{ steps.next-snapshot.outputs.version }}"
if test -f pom.xml
then
mvn versions:set -DnewVersion=$NEXT_VERSION -DgenerateBackupPoms=false -DprocessAllModules=true -B -ntp
else
sed -i "s/version=.*/version=$NEXT_VERSION/" gradle.properties
fi
git commit -a -m "[CI/CD] Next development version"
git push origin "$DEV_BRANCH"
else
git merge --abort
echo "::error title=Cannot merge release tag::Merging $GITHUB_REF_NAME into $DEV_BRANCH failed. Manual procedure required"
exit 1
fi
- id: next-milestone
if: ${{ env.HOTFIX != 'true' && !contains(env.MILESTONE, '-') && steps.support-window.outputs.support-type != 'eol' }}
continue-on-error: true
uses: spring-io/spring-release-actions/compute-next-version@0.0.6
with:
version: ${{ env.MILESTONE }}
# No due_on on the next milestone according to the day/week pattern since release might be skipped for next month
- name: Create Next Milestone
if: ${{ env.HOTFIX != 'true' && steps.next-milestone.outputs.version }}
run: gh api repos/$GITHUB_REPOSITORY/milestones -f title=${{ steps.next-milestone.outputs.version }} || true