diff --git a/ci/config/release-scripts.yml b/ci/config/release-scripts.yml new file mode 100644 index 0000000..d18538f --- /dev/null +++ b/ci/config/release-scripts.yml @@ -0,0 +1,6 @@ +spring: + main: + banner-mode: off +sonatype: + exclude: + - 'build-info\.json' diff --git a/ci/pipeline.yml b/ci/pipeline.yml index 7129ec9..92b09bb 100644 --- a/ci/pipeline.yml +++ b/ci/pipeline.yml @@ -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 @@ -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: diff --git a/ci/scripts/promote.sh b/ci/scripts/promote.sh index 0e45ace..bd16001 100755 --- a/ci/scripts/promote.sh +++ b/ci/scripts/promote.sh @@ -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 \ No newline at end of file +echo $version > version/version diff --git a/ci/tasks/promote.yml b/ci/tasks/promote.yml index 7f71a70..603a58c 100644 --- a/ci/tasks/promote.yml +++ b/ci/tasks/promote.yml @@ -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 \ No newline at end of file + path: git-repo/ci/scripts/promote.sh