Skip to content

Commit 5b4107c

Browse files
committed
[CI] Fix GH token in release steps
Also adds a temporary release-adhoc.yml worklfow to handle the last pieces of the release job that failed.
1 parent c154257 commit 5b4107c

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ jobs:
189189
git tag v$VERSION
190190
git push --tags origin
191191
- name: Changelog Config File
192+
env:
193+
GH_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
192194
run: |
193195
repositoryTeam=$(gh api repos/$GITHUB_REPOSITORY/collaborators --jq 'map(select(.role_name == "admin") | .login) | tostring')
194196
repositoryTeam=$(sed 's/"//g' <<< ${repositoryTeam:1:-1})

.github/workflows/release-adhoc.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: CI
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
run-trivy-scan:
7+
description: 'Run Trivy scan ?'
8+
default: true
9+
required: false
10+
type: boolean
11+
12+
env:
13+
GCHAT_WEBHOOK_URL: ${{ secrets.SPRING_RELEASE_GCHAT_WEBHOOK_URL }}
14+
DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
15+
COMMIT_OWNER: ${{ github.event.pusher.name }}
16+
COMMIT_SHA: ${{ github.sha }}
17+
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
18+
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
19+
20+
jobs:
21+
prerequisites:
22+
name: Pre-requisites for building
23+
runs-on: ubuntu-latest
24+
if: github.repository == 'spring-projects/spring-pulsar'
25+
outputs:
26+
runjobs: ${{ steps.continue.outputs.runjobs }}
27+
project_version: ${{ steps.continue.outputs.project_version }}
28+
boot_version: ${{ steps.continue.outputs.boot_version }}
29+
steps:
30+
- uses: actions/checkout@v4
31+
- id: continue
32+
name: Determine if should continue
33+
run: |
34+
# Run jobs if in upstream repository
35+
echo "runjobs=true" >>$GITHUB_OUTPUT
36+
# Extract version from gradle.properties
37+
version=$(cat gradle.properties | grep "version=" | awk -F'=' '{print $2}')
38+
echo "project_version=$version" >>$GITHUB_OUTPUT
39+
bootVersion=$(cat gradle/libs.versions.toml | grep "spring-boot = \"" | cut -d '"' -f2)
40+
echo "boot_version=$bootVersion" >>$GITHUB_OUTPUT
41+
42+
perform_release:
43+
name: Perform Release
44+
needs: [prerequisites]
45+
runs-on: ubuntu-latest
46+
permissions:
47+
contents: write
48+
timeout-minutes: 120
49+
if: ${{ !endsWith(needs.prerequisites.outputs.project_version, '-SNAPSHOT') }}
50+
env:
51+
REPO: ${{ github.repository }}
52+
BRANCH: ${{ github.ref_name }}
53+
VERSION: ${{ needs.prerequisites.outputs.project_version }}
54+
steps:
55+
- uses: actions/checkout@v4
56+
with:
57+
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
58+
- uses: spring-io/spring-gradle-build-action@v2
59+
- name: Changelog Config File
60+
env:
61+
GH_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
62+
run: |
63+
repositoryTeam=$(gh api repos/$GITHUB_REPOSITORY/collaborators --jq 'map(select(.role_name == "admin") | .login) | tostring')
64+
repositoryTeam=$(sed 's/"//g' <<< ${repositoryTeam:1:-1})
65+
repositoryVisibility=$(gh repo view --json visibility --jq .[])
66+
repositoryVisibility=$([[ $repositoryVisibility = 'PUBLIC' ]] && echo 'true' || echo 'false')
67+
echo "changelog.contributors.exclude.names=$repositoryTeam" > changelog.properties
68+
echo "changelog.issues.generate-links=$repositoryVisibility" >> changelog.properties
69+
- name: Generate Changelog
70+
uses: spring-io/[email protected]
71+
with:
72+
milestone: ${{ env.VERSION }}
73+
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
74+
config-file: changelog.properties
75+
- name: GitHub Release
76+
run: |
77+
RELEASE_URL=$(gh release create v${{ env.VERSION }} -F changelog.md ${{ (contains(env.VERSION, '-M') || contains(env.VERSION, '-RC')) && '--prerelease' || '' }})
78+
echo "::notice title=Release Page::$RELEASE_URL"
79+
- name: Close Milestone
80+
run: |
81+
MILESTONE_ID=$(gh api repos/$GITHUB_REPOSITORY/milestones --jq '.[] | select(.title == "${{ env.VERSION }}") | .number')
82+
if [ $MILESTONE_ID ]; then
83+
gh api -X PATCH repos/$GITHUB_REPOSITORY/milestones/$MILESTONE_ID -f state='closed' --silent
84+
fi
85+
- name: Announce Release in Chat
86+
if: env.GCHAT_WEBHOOK_URL
87+
run: |
88+
curl -X POST '${{ env.GCHAT_WEBHOOK_URL }}' \
89+
-H 'Content-Type: application/json' \
90+
-d '{ text: "${{ github.event.repository.name }}-announcing `${{ env.VERSION }}`"}'
91+
- name: Update next snapshot version
92+
run: |
93+
echo "Updating $REPO@$VERSION to next snapshot version."
94+
./gradlew :updateToSnapshotVersion
95+
git commit -am "[Release $VERSION] Next development version"
96+
git push

0 commit comments

Comments
 (0)