Skip to content

Commit

Permalink
Release from GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkinsona committed May 3, 2024
1 parent b5ed22b commit 70f3e08
Show file tree
Hide file tree
Showing 10 changed files with 290 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ inputs:
develocity-access-key:
description: Access key for authentication with https://ge.spring.io
required: true
outputs:
version:
description: 'The version that was built'
value: ${{ steps.read-version.outputs.version }}
runs:
using: composite
steps:
Expand All @@ -26,3 +30,10 @@ runs:
env:
DEVELOCITY_ACCESS_KEY: ${{ inputs.develocity-access-key }}
run: ./gradlew -PdeploymentRepository=$(pwd)/artifactory build publishAllPublicationsToDeploymentRepository
- name: Read Version From gradle.properties
id: read-version
shell: bash
run: |
version=$(sed -n 's/version=\(.*\)/\1/p' gradle.properties)
echo "Version is $version"
echo "version=$version" >> $GITHUB_OUTPUT
23 changes: 23 additions & 0 deletions .github/actions/create-github-release/action.yml
Original file line number Diff line number Diff line change
@@ -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/actions/create-github-release/changelog-generator.yml
- name: Create GitHub Release
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.token }}
run: gh release create ${{ format('v{0}', inputs.milestone) }} --notes-file changelog.md
23 changes: 23 additions & 0 deletions .github/actions/create-github-release/changelog-generator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
changelog:
repository: spring-gradle-plugins/dependency-management-plugin
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+).*'
38 changes: 38 additions & 0 deletions .github/actions/publish-to-plugin-portal/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Publish Gradle Plugin
description: Publishes the plugin to Gradle's 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
build-number:
description: 'The build number to use when downloading plugin artifacts'
required: false
default: ${{ github.run_number }}
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('dependency-management-plugin-{0}', inputs.plugin-version) }};buildNumber=${{ inputs.build-number }}'
- name: Set Up Java
uses: actions/setup-java@v4
with:
distribution: 'liberica'
java-version: '17'
- name: Publish
shell: bash
working-directory: ${{ github.action_path }}
run: ${{ github.workspace }}/gradlew publishExisting -Pgradle.publish.key=${{ inputs.gradle-plugin-publish-key }} -Pgradle.publish.secret=${{ inputs.gradle-plugin-publish-secret }} -PpluginVersion=${{ inputs.plugin-version }} -PrepositoryRoot=${{ github.workspace }}/gradle-plugin-portal
20 changes: 20 additions & 0 deletions .github/actions/publish-to-plugin-portal/artifacts.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"files": [
{
"aql": {
"items.find": {
"$and": [
{
"@build.name": "${buildName}",
"@build.number": "${buildNumber}",
"path": {
"$match": "io/spring/gradle/dependency-management-plugin/*"
}
}
]
}
},
"target": "gradle-plugin-portal/"
}
]
}
14 changes: 14 additions & 0 deletions .github/actions/publish-to-plugin-portal/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
plugins {
id "com.gradle.plugin-publish" version "1.2.1"
}

tasks.register("publishExisting", com.gradle.publish.PublishExistingTask) {
pluginId = "io.spring.dependency-management"
fileRepositoryRoot = new File("${repositoryRoot}")
pluginVersion = "${pluginVersion}"
pluginCoordinates = "io.spring.gradle:dependency-management-plugin:${pluginVersion}"
displayName = "Dependency Management Plugin"
pluginDescription = "A Gradle plugin that provides Maven-like dependency management functionality"
website = "https://github.com/spring-gradle-plugins/dependency-management-plugin"
vcsUrl = "https://github.com/spring-gradle-plugins/dependency-management-plugin"
}
Empty file.
50 changes: 50 additions & 0 deletions .github/actions/sync-to-maven-central/action.yml
Original file line number Diff line number Diff line change
@@ -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
version:
description: 'The version 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: ${{ inputs.jfrog-cli-config-token }}
- name: Download Release Artifacts
shell: bash
run: jf rt download --spec ${{ format('{0}/artifacts.spec', github.action_path) }} --spec-vars 'buildName=${{ format('dependency-management-plugin-{0}', inputs.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: ${{ inputs.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/io/spring/gradle/dependency-management-plugin/{0}/dependency-management-plugin-{0}.jar', inputs.version) }}
echo "Waiting for $url"
until curl --fail --head --silent $url > /dev/null
do
echo "."
sleep 60
done
echo "$url is available"
20 changes: 20 additions & 0 deletions .github/actions/sync-to-maven-central/artifacts.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"files": [
{
"aql": {
"items.find": {
"$and": [
{
"@build.name": "${buildName}",
"@build.number": "${buildNumber}",
"name": {
"$nmatch": "*docs*"
}
}
]
}
},
"target": "nexus/"
}
]
}
91 changes: 91 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Release
on:
push:
tags:
- v1.1.[0-9]+
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
jobs:
build-and-stage-release:
if: ${{ github.repository == 'spring-gradle-plugins/dependency-management-plugin' }}
name: Build and Stage Release
runs-on: ubuntu-latest
steps:
- name: Check Out Code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Build
id: build
uses: ./.github/actions/build
with:
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
- name: Stage Release
uses: ./.github/actions/deploy-to-artifactory
with:
build-name-version: ${{ steps.build.outputs.version }}
repository: 'libs-staging-local'
username: ${{ secrets.ARTIFACTORY_USERNAME }}
password: ${{ secrets.ARTIFACTORY_PASSWORD }}
signing-key: ${{ secrets.GPG_PRIVATE_KEY }}
signing-passphrase: ${{ secrets.GPG_PASSPHRASE }}
outputs:
version: ${{ steps.build.outputs.version }}
sync-to-maven-central:
name: Sync to Maven Central
needs:
- build-and-stage-release
runs-on: ubuntu-latest
steps:
- name: Check Out Code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Sync to Maven Central
uses: ./.github/actions/sync-to-maven-central
with:
jfrog-cli-config-token: ${{ secrets.JF_ARTIFACTORY_SPRING }}
ossrh-s01-staging-profile: ${{ secrets.OSSRH_S01_STAGING_PROFILE }}
ossrh-s01-token-password: ${{ secrets.OSSRH_S01_TOKEN_PASSWORD }}
ossrh-s01-token-username: ${{ secrets.OSSRH_S01_TOKEN_USERNAME }}
version: ${{ needs.build-and-stage-release.outputs.version }}
promote-release:
name: Promote Release
needs:
- build-and-stage-release
- sync-to-maven-central
runs-on: ubuntu-latest
steps:
- name: Set up JFrog CLI
uses: jfrog/setup-jfrog-cli@d82fe26823e1f25529250895d5673f65b02af085 # v4.0.1
env:
JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
- name: Promote build
run: jfrog rt build-promote ${{ format('dependency-management-plugin-{0}', needs.build-and-stage-release.outputs.version)}} ${{ github.run_number }} plugins-release-local
publish-to-plugin-portal:
name: Publish to Plugin Portal
needs:
- build-and-stage-release
- sync-to-maven-central
runs-on: ubuntu-latest
steps:
- name: Check Out Code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Publish
uses: ./.github/actions/publish-to-plugin-portal
with:
gradle-plugin-publish-key: ${{ secrets.GRADLE_PUBLISH_KEY_CREDENTIAL }}
gradle-plugin-publish-secret: ${{ secrets.GRADLE_PUBLISH_SECRET_CREDENTIAL }}
jfrog-cli-config-token: ${{ secrets.JF_ARTIFACTORY_SPRING }}
plugin-version: ${{ needs.build-and-stage-release.outputs.version }}
create-github-release:
name: Create GitHub Release
needs:
- build-and-stage-release
- promote-release
- publish-to-plugin-portal
runs-on: ubuntu-latest
steps:
- name: Check Out Code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Create GitHub Release
uses: ./.github/actions/create-github-release
with:
milestone: ${{ needs.build-and-stage-release.outputs.version }}
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}

0 comments on commit 70f3e08

Please sign in to comment.