Add workflow to release from GitHub Actions

Co-Authored-By: Moritz Halbritter <moritz.halbritter@broadcom.com>

Closes gh-40407
This commit is contained in:
Andy Wilkinson
2024-04-15 18:02:56 +01:00
parent bc5777d0cc
commit e75c9312e0
12 changed files with 353 additions and 6 deletions

View File

@@ -1,36 +1,33 @@
name: 'Build'
description: 'Builds the project, optionally publishing it to a local deployment repository'
inputs:
java-version:
required: false
type: string
default: '17'
description: 'The Java version to compile and test with'
java-toolchain:
required: false
type: boolean
default: false
description: 'Whether a Java toolchain should be used'
publish:
required: false
type: boolean
default: false
description: 'Whether to publish artifacts ready for deployment to Artifactory'
gradle-enterprise-secret-access-key:
required: false
type: string
description: 'The secret access key for authentication with ge.spring.io'
gradle-enterprise-cache-user:
required: false
type: string
description: 'The username for authentication with the remote build cache'
gradle-enterprise-cache-password:
required: false
type: string
description: 'The password for authentication with the remote build cache'
outputs:
build-scan-url:
description: 'The URL, if any, of the build scan produced by the build'
value: ${{ (inputs.publish && steps.build-and-publish.outputs.build-scan-url) || steps.build.outputs.build-scan-url }}
version:
description: 'The version that was built'
value: ${{ steps.read-version.outputs.version }}
runs:
using: composite

View File

@@ -0,0 +1,23 @@
name: Create GitHub Release
description: Create the release on GitHub with a changelog
inputs:
milestone:
description: Name of the GitHub milestone for which a release will be created
required: true
token:
description: Token to use for authentication with GitHub
required: true
runs:
using: composite
steps:
- name: Generate Changelog
uses: spring-io/github-changelog-generator@052892c62af51f8af87a9da6de55e70864b7df12
with:
milestone: ${{ inputs.milestone }}
token: ${{ inputs.token }}
config-file: ${{ github.action_path }}/changelog-generator.yml
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ inputs.token }}
shell: bash
run: gh release create ${{ github.ref_name }} --notes-file changelog.md

View File

@@ -0,0 +1,23 @@
changelog:
repository: spring-projects/spring-boot
sections:
- title: ":star: New Features"
labels:
- "type: enhancement"
- title: ":lady_beetle: Bug Fixes"
labels:
- "type: bug"
- "type: regression"
- title: ":notebook_with_decorative_cover: Documentation"
labels:
- "type: documentation"
- title: ":hammer: Dependency Upgrades"
sort: "title"
labels:
- "type: dependency-upgrade"
issues:
ports:
- label: "status: forward-port"
bodyExpression: 'Forward port of issue #(\d+).*'
- label: "status: back-port"
bodyExpression: 'Back port of issue #(\d+).*'

View File

@@ -0,0 +1,34 @@
name: Publish Gradle Plugin
description: Publishes Spring Boot's Gradle plugin to the Plugin Portal
inputs:
jfrog-cli-config-token:
description: 'Config token for the JFrog CLI'
required: true
plugin-version:
description: 'Version of the plugin'
required: true
gradle-plugin-publish-key:
description: 'Gradle publishing key'
required: true
gradle-plugin-publish-secret:
description: 'Gradle publishing secret'
required: true
runs:
using: composite
steps:
- name: Set Up JFrog CLI
uses: jfrog/setup-jfrog-cli@d82fe26823e1f25529250895d5673f65b02af085 # v4.0.1
env:
JF_ENV_SPRING: ${{ inputs.jfrog-cli-config-token }}
- name: Download Artifacts
shell: bash
run: jf rt download --spec ${{ format('{0}/artifacts.spec', github.action_path) }} --spec-vars 'buildName=${{ format('spring-boot-{0}', inputs.plugin-version) }};buildNumber=${{ github.run_number }}'
- name: Publish
shell: bash
run: >
./gradlew publishExisting
-p ${{ github.action_path }}
-Pgradle.publish.key=${{ inputs.gradle-plugin-publish-key }}
-Pgradle.publish.secret=${{ inputs.gradle-plugin-publish-secret }}
-PbootVersion=${{ inputs.plugin-version }}
-PrepositoryRoot=$(pwd)/repository

View File

@@ -0,0 +1,20 @@
{
"files": [
{
"aql": {
"items.find": {
"$and": [
{
"@build.name": "${buildName}",
"@build.number": "${buildNumber}",
"path": {
"$match": "org/springframework/boot/spring-boot-gradle-plugin/*"
}
}
]
}
},
"target": "repository/"
}
]
}

View File

@@ -0,0 +1,14 @@
plugins {
id "com.gradle.plugin-publish" version "1.2.1"
}
tasks.register("publishExisting", com.gradle.publish.PublishExistingTask) {
pluginId = "org.springframework.boot"
fileRepositoryRoot = new File("${repositoryRoot}")
pluginVersion = "${bootVersion}"
pluginCoordinates = "org.springframework.boot:spring-boot-gradle-plugin:${bootVersion}"
displayName = "Spring Boot Gradle Plugin"
pluginDescription = "Spring Boot Gradle Plugin"
website = "https://spring.io/projects/spring-boot"
vcsUrl = "https://github.com/spring-projects/spring-boot"
}

View File

View File

@@ -0,0 +1,38 @@
name: Publish to SDKMAN!
description: Publishes the release as a new candidate version on SDKMAN!
inputs:
sdkman-consumer-key:
description: 'Key for publishing to SDKMAN!'
required: true
sdkman-consumer-secret:
description: 'Secret for publishing to SDKMAN!'
required: true
spring-boot-version:
description: 'The version to publish'
required: true
make-default:
description: 'Whether the release should be made the default version'
required: false
default: false
runs:
using: composite
steps:
- shell: bash
run: >
curl -X POST \
-H "Consumer-Key: ${{ inputs.sdkman-consumer-key }}"
-H "Consumer-Token: ${{ inputs.sdkman-consumer-token }}"
-H "Content-Type: application/json"
-H "Accept: application/json"
-d '{"candidate": "springboot", "version": "${{ inputs.spring-boot-version }}", "url": "${{ format('https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-cli/{0}/spring-boot-cli-{0}-bin.zip', inputs.spring-boot-version)"}'
https://vendors.sdkman.io/release
- shell: bash
if: ${{ inputs.make-default }}
run: >
curl -X POST \
-H "Consumer-Key: ${{ inputs.sdkman-consumer-key }}"
-H "Consumer-Token: ${{ inputs.sdkman-consumer-token }}"
-H "Content-Type: application/json"
-H "Accept: application/json"
-d '{"candidate": "springboot", "version": "${{ inputs.spring-boot-version }}"}'
https://vendors.sdkman.io/default

View File

@@ -0,0 +1,50 @@
name: Sync to Maven Central
description: Syncs a release to Maven Central and waits for it to be available for use
inputs:
jfrog-cli-config-token:
description: 'Config token for the JFrog CLI'
required: true
spring-boot-version:
description: 'The version of Spring Boot that is being synced to Central'
required: true
ossrh-s01-token-username:
description: 'Username for authentication with s01.oss.sonatype.org'
required: true
ossrh-s01-token-password:
description: 'Password for authentication with s01.oss.sonatype.org'
required: true
ossrh-s01-staging-profile:
description: 'Staging profile to use when syncing to Central'
required: true
runs:
using: composite
steps:
- name: Set Up JFrog CLI
uses: jfrog/setup-jfrog-cli@d82fe26823e1f25529250895d5673f65b02af085 # v4.0.1
env:
JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
- name: Download Release Artifacts
shell: bash
run: jf rt download --spec ${{ format('{0}/artifacts.spec', github.action_path) }} --spec-vars 'buildName=${{ format('spring-boot-{0}', inputs.spring-boot-version) }};buildNumber=${{ github.run_number }}'
- name: Sync
uses: spring-io/nexus-sync-action@42477a2230a2f694f9eaa4643fa9e76b99b7ab84 # v0.0.1
with:
username: ${{ inputs.ossrh-s01-token-username }}
password: ${{ inputs.ossrh-s01-token-password }}
staging-profile-name: ${{ secrets.ossrh-s01-staging-profile }}
create: true
upload: true
close: true
release: true
generate-checksums: true
- name: Await
shell: bash
run: |
url=${{ format('https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot/{0}/spring-boot-{0}.jar', inputs.spring-boot-version) }}
echo "Waiting for $url"
until curl --fail --head --silent $url > /dev/null
do
echo "."
sleep 60
done
echo "$url is available"

View File

@@ -0,0 +1,20 @@
{
"files": [
{
"aql": {
"items.find": {
"$and": [
{
"@build.name": "${buildName}",
"@build.number": "${buildNumber}",
"path": {
"$nmatch": "org/springframework/boot/spring-boot-docs/*"
}
}
]
}
},
"target": "nexus/"
}
]
}