Skip to content

Commit 3b524df

Browse files
committed
[CI] Add AdHoc release workflow
Adds Github workflow that can be run to handle the release process if the 'Deploy Artifacts' step fails due to timeout but the repo is eventually closed or closed manually.
1 parent 47b53d8 commit 3b524df

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed

.github/workflows/release-ad-hoc.yml

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Ad Hoc Release
2+
3+
on:
4+
push:
5+
workflow_dispatch:
6+
7+
env:
8+
GCHAT_WEBHOOK_URL: ${{ secrets.SPRING_RELEASE_GCHAT_WEBHOOK_URL }}
9+
GRADLE_ENTERPRISE_CACHE_USER: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USER }}
10+
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
11+
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
12+
COMMIT_OWNER: ${{ github.event.pusher.name }}
13+
COMMIT_SHA: ${{ github.sha }}
14+
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
15+
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
16+
17+
jobs:
18+
prerequisites:
19+
name: Pre-requisites for building
20+
runs-on: ubuntu-latest
21+
if: github.repository == 'spring-projects/spring-pulsar'
22+
outputs:
23+
runjobs: ${{ steps.continue.outputs.runjobs }}
24+
project_version: ${{ steps.continue.outputs.project_version }}
25+
boot_version: ${{ steps.continue.outputs.boot_version }}
26+
steps:
27+
- uses: actions/checkout@v4
28+
- id: continue
29+
name: Determine if should continue
30+
run: |
31+
# Run jobs if in upstream repository
32+
echo "runjobs=true" >>$GITHUB_OUTPUT
33+
# Extract version from gradle.properties
34+
version=$(cat gradle.properties | grep "version=" | awk -F'=' '{print $2}')
35+
echo "project_version=$version" >>$GITHUB_OUTPUT
36+
bootVersion=$(cat gradle/libs.versions.toml | grep "spring-boot = \"" | cut -d '"' -f2)
37+
echo "boot_version=$bootVersion" >>$GITHUB_OUTPUT
38+
perform_release:
39+
name: Perform Release
40+
needs: [prerequisites]
41+
runs-on: ubuntu-latest
42+
permissions:
43+
contents: write
44+
timeout-minutes: 120
45+
if: ${{ !endsWith(needs.prerequisites.outputs.project_version, '-SNAPSHOT') }}
46+
env:
47+
REPO: ${{ github.repository }}
48+
BRANCH: ${{ github.ref_name }}
49+
VERSION: ${{ needs.prerequisites.outputs.project_version }}
50+
steps:
51+
- uses: actions/checkout@v4
52+
with:
53+
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
54+
- uses: spring-io/spring-gradle-build-action@v2
55+
- name: Wait for Artifactory artifacts (milestone)
56+
if: ${{ contains(needs.prerequisites.outputs.project_version, '-RC') || contains(needs.prerequisites.outputs.project_version, '-M') }}
57+
run: |
58+
echo "Wait for artifacts of $REPO@$VERSION to appear on Artifactory."
59+
until curl -f -s https://repo.spring.io/artifactory/milestone/org/springframework/pulsar/spring-pulsar/$VERSION/ > /dev/null
60+
do
61+
sleep 30
62+
echo "."
63+
done
64+
echo "Artifacts for $REPO@$VERSION have been released to Artifactory."
65+
- name: Wait for Maven Central artifacts (GA)
66+
if: ${{ !contains(needs.prerequisites.outputs.project_version, '-SNAPSHOT') && !contains(needs.prerequisites.outputs.project_version, '-RC') && !contains(needs.prerequisites.outputs.project_version, '-M') }}
67+
run: |
68+
echo "Wait for artifacts of $REPO@$VERSION to appear on Maven Central."
69+
until curl -f -s https://repo1.maven.org/maven2/org/springframework/pulsar/spring-pulsar/$VERSION/ > /dev/null
70+
do
71+
sleep 30
72+
echo "."
73+
done
74+
echo "Artifacts for $REPO@$VERSION have been released to Maven Central."
75+
- name: Setup git for release tagging
76+
run: |
77+
git config user.name 'github-actions[bot]'
78+
git config user.email 'github-actions[bot]@users.noreply.github.com'
79+
- name: Tag release
80+
run: |
81+
echo "Tagging $REPO@$VERSION release."
82+
git tag v$VERSION
83+
git push --tags origin
84+
- name: Install tooling for Github release
85+
run: |
86+
curl -sSL -O https://github.com/spring-io/github-changelog-generator/releases/download/v0.0.10/github-changelog-generator.jar
87+
- name: Create Github release
88+
env:
89+
RELEASE_NOTES_FILE: ${{runner.temp}}/release_notes.md5
90+
GH_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
91+
run: |
92+
java -jar github-changelog-generator.jar \
93+
--spring.config.location=.github/changelog-generator.yml \
94+
$VERSION $RELEASE_NOTES_FILE
95+
cat $RELEASE_NOTES_FILE
96+
gh release create v$VERSION \
97+
--draft \
98+
--title "Spring Pulsar $VERSION" \
99+
--generate-notes \
100+
--notes-file $RELEASE_NOTES_FILE
101+
- name: Announce Release in Chat
102+
uses: julb/action-post-googlechat-message@v1
103+
if: env.GCHAT_WEBHOOK_URL
104+
with:
105+
message: "spring-pulsar-announcing `${{ env.VERSION }}`"
106+
gchat_webhook_url: ${{ env.GCHAT_WEBHOOK_URL }}
107+
- name: Update next snapshot version
108+
run: |
109+
echo "Updating $REPO@$VERSION to next snapshot version."
110+
./gradlew :updateToSnapshotVersion
111+
git commit -am "[Release $VERSION] Next development version"
112+
git push

0 commit comments

Comments
 (0)