Skip to content

Commit

Permalink
Publish releases to Maven Central
Browse files Browse the repository at this point in the history
Closes gh-29
Closes gh-58
  • Loading branch information
wilkinsona committed Jan 6, 2023
1 parent ead1271 commit 9955a7c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 34 deletions.
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'
6 changes: 5 additions & 1 deletion ci/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ jobs:
- name: promote-release
serial: true
plan:
- get: ci-image
- get: git-repo
trigger: false
- get: artifactory-repo
trigger: false
passed: [stage-release]
params:
download_artifacts: true
save_build_info: true
- task: promote
image: ci-image
Expand All @@ -118,6 +118,10 @@ jobs:
ARTIFACTORY_SERVER: ((artifactory-server))
ARTIFACTORY_USERNAME: ((artifactory-username))
ARTIFACTORY_PASSWORD: ((artifactory-password))
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 Down
40 changes: 9 additions & 31 deletions ci/scripts/promote.sh
Original file line number Diff line number Diff line change
@@ -1,39 +1,17 @@
#!/bin/bash

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' )
groupId=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/\(.*\):.*:.*/\1/' )
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

if [[ $RELEASE_TYPE = "RELEASE" ]]; then
targetRepo="libs-release-local"
else
echo "Unknown release type $RELEASE_TYPE" >&2; exit 1;
fi
java -jar /concourse-release-scripts.jar \
--spring.config.location=${CONFIG_DIR}/release-scripts.yml \
publishToCentral $RELEASE_TYPE $BUILD_INFO_LOCATION artifactory-repo || { exit 1; }

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 || {
result=$( curl -s -f -u ${ARTIFACTORY_USERNAME}:${ARTIFACTORY_PASSWORD} "${ARTIFACTORY_SERVER}/api/build/${buildName}/${buildNumber}" )
resultRepo=$( echo $result | jq -r '.buildInfo.statuses[0].repository' )
if [[ $resultRepo = "libs-release-local" ]]; then
echo "Already promoted"
else
echo "Failed to promote" >&2
exit 1
fi
}
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
13 changes: 11 additions & 2 deletions ci/tasks/promote.yml
Original file line number Diff line number Diff line change
@@ -1,14 +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:
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 9955a7c

Please sign in to comment.