[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.
This commit is contained in:
Chris Bono
2025-03-16 22:35:20 -05:00
parent c154257e40
commit 5b4107cbad
2 changed files with 98 additions and 0 deletions

View File

@@ -189,6 +189,8 @@ jobs:
git tag v$VERSION
git push --tags origin
- name: Changelog Config File
env:
GH_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
run: |
repositoryTeam=$(gh api repos/$GITHUB_REPOSITORY/collaborators --jq 'map(select(.role_name == "admin") | .login) | tostring')
repositoryTeam=$(sed 's/"//g' <<< ${repositoryTeam:1:-1})

96
.github/workflows/release-adhoc.yml vendored Normal file
View File

@@ -0,0 +1,96 @@
name: CI
on:
workflow_dispatch:
inputs:
run-trivy-scan:
description: 'Run Trivy scan ?'
default: true
required: false
type: boolean
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 }}
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 }}
steps:
- uses: actions/checkout@v4
- 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
perform_release:
name: Perform Release
needs: [prerequisites]
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 }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
- uses: spring-io/spring-gradle-build-action@v2
- name: Changelog Config File
env:
GH_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
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.11
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
run: |
curl -X POST '${{ env.GCHAT_WEBHOOK_URL }}' \
-H 'Content-Type: application/json' \
-d '{ text: "${{ github.event.repository.name }}-announcing `${{ env.VERSION }}`"}'
- 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