Skip to content

Commit

Permalink
Migrate release process to GitHub Actions
Browse files Browse the repository at this point in the history
Complete migration to GitHub Actions.

See gh-
  • Loading branch information
philwebb committed Jun 9, 2024
1 parent 8495f29 commit 53775a1
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 3 deletions.
16 changes: 16 additions & 0 deletions .github/actions/publish-eclipse-update-site/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: 'Publish Eclipse Update Site '
inputs:
version:
required: true
build-number:
required: true
runs:
using: composite
steps:
- name: Stage
id: stage
shell: bash
run: . ${{ github.action_path }}/publish-eclipse-update-site.sh;
env:
VERSION: "${{ inputs.version }}"
BUILD_NUMBER: "${{ inputs.build-number }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
buildInfo=$( jfrog rt curl api/build/spring-javaformat-${VERSION}/${BUILD_NUMBER} )
groupId=$( echo ${build_info} | jq -r '.buildInfo.modules[0].id' | sed 's/\(.*\):.*:.*/\1/' )
version=$( echo ${build_info} | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' )

echo "Publishing Update Site ${groupId}:${version}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash
set -e

source $(dirname $0)/common.sh

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/' )

echo "Publishing ${buildName}/${buildNumber} to Eclipse Update Site"
curl \
-s \
--connect-timeout 240 \
--max-time 2700 \
-u ${ARTIFACTORY_USERNAME}:${ARTIFACTORY_PASSWORD} \
-f \
-H "X-Explode-Archive: true" \
-X PUT \
-T "artifactory-repo/io/spring/javaformat/io.spring.javaformat.eclipse.site/${version}/io.spring.javaformat.eclipse.site-${version}.zip" \
"https://repo.spring.io/javaformat-eclipse-update-site/${version}/" > /dev/null || { echo "Failed to publish" >&2; exit 1; }

releasedVersions=$( curl -s -f -X GET https://repo.spring.io/api/storage/javaformat-eclipse-update-site | jq -r '.children[] | .uri' | cut -c 2- | grep '[0-9].*' | sort -V )

repositories=""
while read -r releasedVersion; do
echo "Adding repository for ${releasedVersion}"
repositories="${repositories}<repository><url>https://repo.spring.io/javaformat-eclipse-update-site/${releasedVersion}</url><layout>p2</layout></repository>"
done <<< "${releasedVersions}"

pushd git-repo > /dev/null
sed "s|##repositories##|${repositories}|" ci/scripts/publish-eclipse-update-site-pom-template.xml > publish-eclipse-update-site-pom.xml
run_maven -f publish-eclipse-update-site-pom.xml clean package || { echo "Failed to publish" >&2; exit 1; }

curl \
-s \
--connect-timeout 240 \
--max-time 2700 \
-u ${ARTIFACTORY_USERNAME}:${ARTIFACTORY_PASSWORD} \
-f \
-X PUT \
-T "target/repository/content.jar" \
"https://repo.spring.io/javaformat-eclipse-update-site/" > /dev/null || { echo "Failed to publish" >&2; exit 1; }

curl \
-s \
--connect-timeout 240 \
--max-time 2700 \
-u ${ARTIFACTORY_USERNAME}:${ARTIFACTORY_PASSWORD} \
-f \
-X PUT \
-T "target/repository/artifacts.jar" \
"https://repo.spring.io/javaformat-eclipse-update-site/" > /dev/null || { echo "Failed to publish" >&2; exit 1; }

popd > /dev/null

echo "Publish complete"
1 change: 0 additions & 1 deletion .github/actions/stage-code/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: 'Stage '
description: 'Stage Code'
inputs:
current-version:
required: true
Expand Down
23 changes: 23 additions & 0 deletions .github/artifacts.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"files": [
{
"aql": {
"items.find": {
"$and": [
{
"@build.name": "${buildName}",
"@build.number": "${buildNumber}",
"name": {
"$nmatch": "*.zip"
},
"name": {
"$nmatch": "*.zip.asc"
}
}
]
}
},
"target": "nexus/"
}
]
}
51 changes: 49 additions & 2 deletions .github/workflows/promote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,52 @@ jobs:
name: Promote
runs-on: ubuntu-latest
steps:
- name: Promote
run: echo "Promote happens here"
- name: Check Out
uses: actions/checkout@v4
- name: Set Up JFrog CLI
uses: jfrog/setup-jfrog-cli@7c95feb32008765e1b4e626b078dfd897c4340ad # v4.1.2
env:
JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
- name: Check Maven Central Sync Status
id: check-sync-status
run: |
url=${{ format('https://repo.maven.apache.org/maven2/io/spring/javaformat/spring-javaformat/{0}/spring-javaformat-{0}.pom', inputs.version) }}
status_code=$( curl --write-out '%{http_code}' --head --silent --output /dev/null ${url} )
if [ "${status_code}" != 200 ] && [ "${status_code}" != 404 ]; then
echo "Unexpected status code ${status_code}"
exit 1
fi
echo "status-code=${status_code}" >> $GITHUB_OUTPUT
- name: Download Release Artifacts
if: ${{ steps.check-sync-status.outputs.status-code == '404' }}
run: jf rt download --spec ./.github/artifacts.spec --spec-vars 'buildName=${{ format('spring-javaformat-{0}', inputs.version) }};buildNumber=${{ inputs.build-number }}'
- name: Sync to Maven Central
if: ${{ steps.check-sync-status.outputs.status-code == '404' }}
uses: spring-io/[email protected]
with:
username: ${{ secrets.OSSRH_S01_TOKEN_USERNAME }}
password: ${{ secrets.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 Maven Central Sync
if: ${{ steps.check-sync-status.outputs.status-code == '404' }}
run: |
url=${{ format('https://repo.maven.apache.org/maven2/io/spring/javaformat/spring-javaformat/{0}/spring-javaformat-{0}.pom', inputs.version) }}
echo "Waiting for $url"
until curl --fail --head --silent $url > /dev/null
do
echo "."
sleep 60
done
echo "$url is available"
- name: Publish Eclipse Update Site
uses: ./.github/actions/publish-eclipse-update-site
with:
version: ${{ inputs.version }}
build-number: ${{ inputs.build-number }}
- name: Create GitHub Release
run: echo "Create GitHub Release"

0 comments on commit 53775a1

Please sign in to comment.