-
Notifications
You must be signed in to change notification settings - Fork 79
199 lines (193 loc) · 8.57 KB
/
ci-release-adhoc-2_0_2.yml
File metadata and controls
199 lines (193 loc) · 8.57 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
196
197
198
199
name: CI (Ad Hoc 2.0.2)
on:
workflow_dispatch:
env:
GCHAT_WEBHOOK_URL: ${{ secrets.SPRING_RELEASE_GCHAT_WEBHOOK_URL }}
DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
COMMIT_OWNER: ${{ github.event.pusher.name }}
COMMIT_SHA: ${{ github.sha }}
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
GH_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
jobs:
prerequisites:
name: Pre-requisites for building
runs-on: ubuntu-latest
if: github.repository == 'spring-projects/spring-pulsar'
outputs:
runjobs: ${{ steps.continue.outputs.runjobs }}
project_version: ${{ steps.continue.outputs.project_version }}
boot_version: ${{ steps.continue.outputs.boot_version }}
should_deploy_artifacts: ${{ steps.should-deploy-artifacts.outputs.result }}
steps:
- uses: actions/checkout@v6
- id: continue
name: Determine if should continue
run: |
# Run jobs if in upstream repository
echo "runjobs=true" >>$GITHUB_OUTPUT
# Extract version from gradle.properties
version=$(cat gradle.properties | grep "version=" | awk -F'=' '{print $2}')
echo "project_version=$version" >>$GITHUB_OUTPUT
bootVersion=$(cat gradle/libs.versions.toml | grep "spring-boot = \"" | cut -d '"' -f2)
echo "boot_version=$bootVersion" >>$GITHUB_OUTPUT
- id: should-deploy-artifacts
name: Check Deploy Artifacts using Secrets
if: ${{ runner.os == 'Linux' }}
run: |
if [[ -z "$ARTIFACTORY_PASSWORD" ]] ; then
echo "result=false" >> $GITHUB_OUTPUT
else
echo "result=true" >> $GITHUB_OUTPUT
fi
deploy_artifacts:
name: Deploy Artifacts
needs: [prerequisites]
runs-on: ubuntu-latest
if: ${{ needs.prerequisites.outputs.should_deploy_artifacts }}
steps:
- uses: actions/checkout@v6
- uses: spring-io/spring-gradle-build-action@v2
with:
java-version: '25'
distribution: 'liberica'
- id: branch-name
name: Extract Branch Name
env:
BRANCH: ${{ github.ref_name }}
VERSION: ${{ needs.prerequisites.outputs.project_version }}
run: |
branch=$BRANCH
if [[ "$branch" = "main" ]] ; then
branch="${VERSION%.*}.x"
fi
echo "branch=$branch" >> $GITHUB_OUTPUT
- id: deploy-location
name: Default the Deploy Location
env:
VERSION: ${{ needs.prerequisites.outputs.project_version }}
run: |
if [[ "$VERSION" =~ "-SNAPSHOT" ]] ; then
deploy_location=artifactory
else
deploy_location=central
fi
echo "deploy_location=$deploy_location" >> $GITHUB_OUTPUT
- name: Still publish docs module to Artifactory when deploy location is Central (stage)
if: ${{ steps.deploy-location.outputs.deploy_location == 'central' }}
shell: bash
run: |
./gradlew \
-PdeploymentRepository=$(pwd)/deployment-repository \
-PforceLocalPublish=true \
:spring-pulsar-docs:publishAllPublicationsToDeploymentRepository
echo "deployRepo=$(pwd)/deployment-repository" >> $GITHUB_OUTPUT
echo "ls -R $(pwd)/deployment-repository"
ls -R $(pwd)/deployment-repository
- name: Still publish docs module to Artifactory when deploy location is Central (publish)
if: ${{ steps.deploy-location.outputs.deploy_location == 'central' }}
uses: spring-io/artifactory-deploy-action@926d7f7cc810569395346bf3a4d91b380b3e355b # v0.0.4
with:
artifact-properties: |
/**/*docs-*.zip::zip.name=spring-pulsar,zip.type=docs,zip.deployed=false
uri: 'https://repo.spring.io'
repository: 'libs-release-local'
build-name: 'spring-pulsar-2.0.x'
folder: 'deployment-repository'
signing-key: ${{ secrets.GPG_PRIVATE_KEY }}
signing-passphrase: ${{ secrets.GPG_PASSPHRASE }}
username: ${{ secrets.ARTIFACTORY_USERNAME }}
password: ${{ secrets.ARTIFACTORY_PASSWORD }}
perform_release:
name: Perform Release
needs: [prerequisites, deploy_artifacts]
runs-on: ubuntu-latest
permissions:
contents: write
timeout-minutes: 120
if: ${{ !endsWith(needs.prerequisites.outputs.project_version, '-SNAPSHOT') }}
env:
REPO: ${{ github.repository }}
BRANCH: ${{ github.ref_name }}
VERSION: ${{ needs.prerequisites.outputs.project_version }}
TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
MILESTONE_REPO: https://repo1.maven.org/maven2
RELEASE_REPO: https://repo1.maven.org/maven2
ARTIFACT_PATH: org/springframework/pulsar/spring-pulsar
steps:
- uses: actions/checkout@v6
with:
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
- uses: spring-io/spring-gradle-build-action@v2
with:
java-version: '25'
distribution: 'liberica'
- name: Wait for Milestone Artifacts
if: ${{ contains(needs.prerequisites.outputs.project_version, '-RC') || contains(needs.prerequisites.outputs.project_version, '-M') }}
env:
VERSION: ${{ needs.prerequisites.outputs.project_version }}
run: |
echo "Wait for artifacts of $REPO@$VERSION to appear on milestone repository ($MILESTONE_REPO)."
until curl -f -s $MILESTONE_REPO/$ARTIFACT_PATH/$VERSION/ > /dev/null
do
sleep 30
echo "."
done
echo "Artifacts for $REPO@$VERSION have been released to milestone repository ($MILESTONE_REPO)."
- name: Wait for Release Artifacts
if: ${{ !contains(needs.prerequisites.outputs.project_version.version, '-RC') && !contains(needs.prerequisites.outputs.project_version, '-M') }}
env:
VERSION: ${{ needs.prerequisites.outputs.project_version }}
run: |
echo "Wait for artifacts of $REPO@$VERSION to appear on release repository ($RELEASE_REPO)."
until curl -f -s $RELEASE_REPO/$ARTIFACT_PATH/$VERSION/ > /dev/null
do
sleep 30
echo "."
done
echo "Artifacts for $REPO@$VERSION have been released to release repository ($RELEASE_REPO)."
- name: Setup git for release tagging
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
- name: Tag release
run: |
echo "Tagging $REPO@$VERSION release."
git tag v$VERSION
git push --tags origin
- name: Changelog Config File
run: |
repositoryTeam=$(gh api repos/$GITHUB_REPOSITORY/collaborators --jq 'map(select(.role_name == "admin") | .login) | tostring')
repositoryTeam=$(sed 's/"//g' <<< ${repositoryTeam:1:-1})
repositoryVisibility=$(gh repo view --json visibility --jq .[])
repositoryVisibility=$([[ $repositoryVisibility = 'PUBLIC' ]] && echo 'true' || echo 'false')
echo "changelog.contributors.exclude.names=$repositoryTeam" > changelog.properties
echo "changelog.issues.generate-links=$repositoryVisibility" >> changelog.properties
- name: Generate Changelog
uses: spring-io/github-changelog-generator@v0.0.14
with:
milestone: ${{ env.VERSION }}
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
config-file: changelog.properties
- name: GitHub Release
run: |
RELEASE_URL=$(gh release create v${{ env.VERSION }} -F changelog.md ${{ (contains(env.VERSION, '-M') || contains(env.VERSION, '-RC')) && '--prerelease' || '' }})
echo "::notice title=Release Page::$RELEASE_URL"
- name: Close Milestone
run: |
MILESTONE_ID=$(gh api repos/$GITHUB_REPOSITORY/milestones --jq '.[] | select(.title == "${{ env.VERSION }}") | .number')
if [ $MILESTONE_ID ]; then
gh api -X PATCH repos/$GITHUB_REPOSITORY/milestones/$MILESTONE_ID -f state='closed' --silent
fi
- name: Announce Release in Chat
if: env.GCHAT_WEBHOOK_URL
uses: spring-io/spring-release-actions/announce-on-gchat@0.0.5
with:
version: ${{ env.VERSION }}
gchat-webhook-url: ${{ env.GCHAT_WEBHOOK_URL }}
- name: Update next snapshot version
run: |
echo "Updating $REPO@$VERSION to next snapshot version."
./gradlew :updateToSnapshotVersion
git commit -am "[Release $VERSION] Next development version"
git push