-
Notifications
You must be signed in to change notification settings - Fork 395
151 lines (147 loc) · 5.59 KB
/
release-milestone.yml
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
name: Release Milestone
on:
workflow_dispatch:
inputs:
milestone:
description: 'Milestone version like, M1 or RC1, etc'
required: true
jobs:
staging:
runs-on: ubuntu-latest
outputs:
project-version: ${{ steps.output.outputs.project-version }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: adopt
java-version: 17
- uses: jvalkeal/setup-maven@v1
with:
maven-version: 3.8.4
- uses: jfrog/setup-jfrog-cli@v3
with:
version: 2.21.5
env:
JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
- name: Configure JFrog Cli
run: |
jf rt gradlec \
--use-wrapper \
--uses-plugin \
--deploy-ivy-desc=false \
--server-id-resolve repo.spring.io \
--server-id-deploy repo.spring.io \
--repo-resolve milestone \
--repo-deploy libs-staging-local
echo JFROG_CLI_BUILD_NAME=spring-shell-main-milestone >> $GITHUB_ENV
echo JFROG_CLI_BUILD_NUMBER=$GITHUB_RUN_NUMBER >> $GITHUB_ENV
- name: Configure Milestone Version
run: |
snapshotVersion=$( awk -F '=' '$1 == "version" { print $2 }' gradle.properties )
plainVersion=${snapshotVersion%-SNAPSHOT}
milestoneVersion="$plainVersion-${{ github.event.inputs.milestone }}"
sed -i "s/version=$snapshotVersion/version=$milestoneVersion/" gradle.properties
echo PROJECT_VERSION=$milestoneVersion >> $GITHUB_ENV
- name: Tag Release
env:
PROJECT_VERSION: ${{ env.PROJECT_VERSION }}
run: |
git config --global user.name github-actions[bot]
git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com
git checkout -b $PROJECT_VERSION
git commit -a -m "Release $PROJECT_VERSION"
git tag "v$PROJECT_VERSION"
- name: Build and Publish
env:
DISABLE_SAMPLES: true
run: |
jf rt gradle build distZip artifactoryPublish
jf rt build-publish
- name: Push Release
env:
PROJECT_VERSION: ${{ env.PROJECT_VERSION }}
run: |
git push origin $PROJECT_VERSION
git push --tags origin
- name: Output
id: output
env:
PROJECT_VERSION: ${{ env.PROJECT_VERSION }}
run: |
echo "project-version=$PROJECT_VERSION" >> $GITHUB_OUTPUT
promote:
runs-on: ubuntu-latest
needs: staging
environment: promote
steps:
- uses: actions/checkout@v3
- uses: jfrog/setup-jfrog-cli@v3
with:
version: 2.21.5
env:
JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
- name: Configure JFrog Cli
run: |
echo JFROG_CLI_BUILD_NAME=spring-shell-main-milestone >> $GITHUB_ENV
echo JFROG_CLI_BUILD_NUMBER=$GITHUB_RUN_NUMBER >> $GITHUB_ENV
- name: Promote Build
run: |
jf rt build-promote libs-milestone-local
ghrelease:
runs-on: ubuntu-latest
needs: [staging, promote]
steps:
- uses: actions/checkout@v3
- name: Install Tooling
run: |
curl -sSL https://github.com/cbroglie/mustache/releases/download/v1.2.2/mustache_1.2.2_linux_amd64.tar.gz | sudo tar -C /usr/local/bin/ --no-same-owner -xzv mustache
- name: GitHub Release
env:
PROJECT_VERSION: ${{needs.staging.outputs.project-version}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
RELEASE_NOTES_FILE: ${{runner.temp}}/release_notes.md5
RELEASE_NOTES_DATA: ${{runner.temp}}/release_notes_data.json
RELEASE_NOTES_HEADERS: ${{runner.temp}}/release_notes_headers.json
RELEASE_NOTES_FOOTERS: ${{runner.temp}}/release_notes_footers.json
RELEASE_NOTES_ISSUES: ${{runner.temp}}/release_notes_issues.json
RELEASE_NOTES_PRS: ${{runner.temp}}/release_notes_prs.json
run: |
gh issue list \
--repo spring-projects/spring-shell \
--search milestone:$PROJECT_VERSION \
--label automation/rlnotes-header \
--state all --json title,body \
--jq '{headers:map(.),headerslength:(length)}' \
> $RELEASE_NOTES_HEADERS
gh issue list \
--repo spring-projects/spring-shell \
--search milestone:$PROJECT_VERSION \
--label automation/rlnotes-footer \
--state all --json title,body \
--jq '{footers:map(.),footerslength:(length)}' \
> $RELEASE_NOTES_FOOTERS
gh issue list \
--repo spring-projects/spring-shell \
--search milestone:$PROJECT_VERSION \
--state all --json number,title,labels \
--jq '{issues:map(select((.labels | length == 0) or (any(.labels[].name; startswith("automation/rlnotes")|not))))}' \
> $RELEASE_NOTES_ISSUES
gh pr list \
--repo spring-projects/spring-shell \
--search milestone:$PROJECT_VERSION \
--state all --json number,title,labels \
--jq '{prs:map(.),prslength:(length)}' \
> $RELEASE_NOTES_PRS
jq -s '{issues:(.[0].issues),prs:(.[1].prs),prslength:(.[1].prslength),headers:(.[2].headers),headerslength:(.[2].headerslength),footers:(.[3].footers), footerslength:(.[3].footerslength)}' \
$RELEASE_NOTES_ISSUES \
$RELEASE_NOTES_PRS \
$RELEASE_NOTES_HEADERS \
$RELEASE_NOTES_FOOTERS \
> $RELEASE_NOTES_DATA
mustache $RELEASE_NOTES_DATA .github/rlnotes.mustache > $RELEASE_NOTES_FILE
gh release create v$PROJECT_VERSION \
--draft \
--prerelease \
--title "$PROJECT_VERSION" \
--notes-file $RELEASE_NOTES_FILE