Skip to content

Commit

Permalink
Publish releases to Maven Central
Browse files Browse the repository at this point in the history
Closes gh-72
  • Loading branch information
wilkinsona committed Jan 11, 2023
1 parent 8f00e68 commit 891aa75
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 51 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins {
}

group = 'io.spring.asciidoctor.backends'
description = 'Spring Asciidoctor Backends'

apply from: "$rootDir/gradle/publish-maven.gradle"

Expand Down
6 changes: 6 additions & 0 deletions ci/config/release-scripts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
spring:
main:
banner-mode: off
sonatype:
exclude:
- 'build-info\.json'
23 changes: 5 additions & 18 deletions ci/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ jobs:
- name: promote-milestone
serial: true
plan:
- get: ci-image
- get: git-repo
trigger: false
- get: artifactory-repo
Expand All @@ -192,7 +191,6 @@ jobs:
params:
save_build_info: true
- task: promote
image: ci-image
file: git-repo/ci/tasks/promote.yml
params:
RELEASE_TYPE: M
Expand All @@ -211,7 +209,6 @@ jobs:
- name: promote-rc
serial: true
plan:
- get: ci-image
- get: git-repo
trigger: false
- get: artifactory-repo
Expand All @@ -221,7 +218,6 @@ jobs:
download_artifacts: false
save_build_info: true
- task: promote
image: ci-image
file: git-repo/ci/tasks/promote.yml
params:
RELEASE_TYPE: RC
Expand All @@ -240,7 +236,6 @@ jobs:
- name: promote-release
serial: true
plan:
- get: ci-image
- get: git-repo
trigger: false
- get: artifactory-repo
Expand All @@ -250,22 +245,14 @@ jobs:
download_artifacts: true
save_build_info: true
- task: promote
image: ci-image
file: git-repo/ci/tasks/promote.yml
params:
RELEASE_TYPE: RELEASE
<<: *artifactory-task-params
- name: create-github-release
serial: true
plan:
- get: ci-image
- get: git-repo
- get: artifactory-repo
trigger: true
passed: [promote-release]
params:
download_artifacts: false
save_build_info: true
SONATYPE_USERNAME: ((s01-user-token))
SONATYPE_PASSWORD: ((s01-user-token-password))
SONATYPE_URL: ((sonatype-url))
SONATYPE_STAGING_PROFILE_ID: ((sonatype-staging-profile-id))
- task: generate-changelog
file: git-repo/ci/tasks/generate-changelog.yml
params:
Expand All @@ -281,7 +268,7 @@ groups:
- name: "builds"
jobs: ["build"]
- name: "releases"
jobs: ["stage-milestone", "stage-rc", "stage-release", "promote-milestone", "promote-rc", "promote-release", "create-github-release"]
jobs: ["stage-milestone", "stage-rc", "stage-release", "promote-milestone", "promote-rc", "promote-release"]
- name: "ci-image"
jobs: ["build-ci-image"]

36 changes: 9 additions & 27 deletions ci/scripts/promote.sh
Original file line number Diff line number Diff line change
@@ -1,35 +1,17 @@
#!/bin/bash
set -e

source $(dirname $0)/common.sh
CONFIG_DIR=git-repo/ci/config

buildName=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.name' )
buildNumber=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.number' )
version=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' )
export BUILD_INFO_LOCATION=$(pwd)/artifactory-repo/build-info.json

java -jar /concourse-release-scripts.jar \
--spring.config.location=${CONFIG_DIR}/release-scripts.yml \
publishToCentral $RELEASE_TYPE $BUILD_INFO_LOCATION artifactory-repo || { exit 1; }

if [[ $RELEASE_TYPE = "M" ]]; then
targetRepo="libs-milestone-local"
elif [[ $RELEASE_TYPE = "RC" ]]; then
targetRepo="libs-milestone-local"
elif [[ $RELEASE_TYPE = "RELEASE" ]]; then
targetRepo="libs-release-local"
else
echo "Unknown release type $RELEASE_TYPE" >&2; exit 1;
fi

echo "Promoting ${buildName}/${buildNumber} to ${targetRepo}"

curl \
-s \
--connect-timeout 240 \
--max-time 900 \
-u ${ARTIFACTORY_USERNAME}:${ARTIFACTORY_PASSWORD} \
-H "Content-type:application/json" \
-d "{\"status\": \"staged\", \"sourceRepo\": \"libs-staging-local\", \"targetRepo\": \"${targetRepo}\"}" \
-f \
-X \
POST "${ARTIFACTORY_SERVER}/api/build/promote/${buildName}/${buildNumber}" > /dev/null || { echo "Failed to promote" >&2; exit 1; }
java -jar /concourse-release-scripts.jar \
--spring.config.location=${CONFIG_DIR}/release-scripts.yml \
promote $RELEASE_TYPE $BUILD_INFO_LOCATION || { exit 1; }

echo "Promotion complete"
echo $version > version/version
echo $version > version/version
17 changes: 11 additions & 6 deletions ci/tasks/promote.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
---
platform: linux
image_resource:
type: registry-image
source:
repository: springio/concourse-release-scripts
tag: '0.3.4'
inputs:
- name: git-repo
- name: artifactory-repo
outputs:
- name: version
params:
RELEASE_TYPE:
ARTIFACTORY_SERVER:
ARTIFACTORY_USERNAME:
ARTIFACTORY_PASSWORD:
BINTRAY_SUBJECT:
BINTRAY_REPO:
BINTRAY_USERNAME:
BINTRAY_API_KEY:
RELEASE_TYPE:
SONATYPE_USER:
SONATYPE_PASSWORD:
SONATYPE_URL:
SONATYPE_STAGING_PROFILE:
run:
path: git-repo/ci/scripts/promote.sh
path: git-repo/ci/scripts/promote.sh

0 comments on commit 891aa75

Please sign in to comment.