Skip to content

Commit 97a9a64

Browse files
committed
Migrate release process to GitHub Actions
Complete migration to GitHub Actions. See gh-411
1 parent 8495f29 commit 97a9a64

File tree

8 files changed

+236
-3
lines changed

8 files changed

+236
-3
lines changed

Diff for: .github/actions/create-github-release/action.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Create GitHub Release
2+
description: Create the release on GitHub with a changelog
3+
inputs:
4+
milestone:
5+
required: true
6+
token:
7+
required: true
8+
runs:
9+
using: composite
10+
steps:
11+
- name: Generate Changelog
12+
uses: spring-io/[email protected]
13+
with:
14+
milestone: ${{ inputs.milestone }}
15+
token: ${{ inputs.token }}
16+
config-file: .github/actions/create-github-release/changelog-generator.yml
17+
- name: Create GitHub Release
18+
env:
19+
GITHUB_TOKEN: ${{ inputs.token }}
20+
shell: bash
21+
run: gh release create ${{ format('v{0}', inputs.milestone) }} --notes-file changelog.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
changelog:
2+
repository: spring-io/spring-javaformat
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: 'Publish Eclipse Update Site '
2+
inputs:
3+
version:
4+
required: true
5+
build-number:
6+
required: true
7+
artifactory-username:
8+
required: true
9+
artifactory-password:
10+
required: true
11+
runs:
12+
using: composite
13+
steps:
14+
- name: Stage
15+
id: stage
16+
shell: bash
17+
run: . ${{ github.action_path }}/publish-eclipse-update-site.sh;
18+
env:
19+
VERSION: "${{ inputs.version }}"
20+
BUILD_NUMBER: "${{ inputs.build-number }}"
21+
ARTIFACTORY_USERNAME: "${{ inputs.artifactory-username }}"
22+
ARTIFACTORY_PASSWORD: "${{ inputs.artifactory-password }}"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>org.eclipse.m2e.maveneclipse</groupId>
6+
<artifactId>m2eclipse-maveneclipse-publish</artifactId>
7+
<version>0.0.0-SNAPSHOT</version>
8+
<packaging>pom</packaging>
9+
<properties>
10+
<tycho-extras-version>1.1.0</tycho-extras-version>
11+
</properties>
12+
<build>
13+
<plugins>
14+
<plugin>
15+
<groupId>org.eclipse.tycho.extras</groupId>
16+
<artifactId>tycho-p2-extras-plugin</artifactId>
17+
<version>${tycho-extras-version}</version>
18+
<executions>
19+
<execution>
20+
<phase>prepare-package</phase>
21+
<goals>
22+
<goal>mirror</goal>
23+
</goals>
24+
</execution>
25+
</executions>
26+
<configuration>
27+
<source>
28+
##repositories##
29+
</source>
30+
<destination>${project.build.directory}/repository</destination>
31+
<compress>true</compress>
32+
</configuration>
33+
</plugin>
34+
<plugin>
35+
<groupId>org.apache.maven.plugins</groupId>
36+
<artifactId>maven-antrun-plugin</artifactId>
37+
<version>1.8</version>
38+
<executions>
39+
<execution>
40+
<phase>prepare-package</phase>
41+
<configuration>
42+
<propertyPrefix>mvn</propertyPrefix>
43+
<target>
44+
<mkdir dir="${mvnproject.build.directory}/repackage"/>
45+
<unzip src="${mvnproject.build.directory}/repository/artifacts.jar" dest="${mvnproject.build.directory}/repackage"/>
46+
<replace file="${mvnproject.build.directory}/repackage/artifacts.xml" token="${repoUrl}" value="@@@{repoUrl}/@@@{version}"/>
47+
<replace file="${mvnproject.build.directory}/repackage/artifacts.xml" token="@@@" value="$"/>
48+
<touch file="${mvnproject.build.directory}/repackage/artifacts.xml" millis="0" />
49+
<zip destfile="${mvnproject.build.directory}/repository/artifacts.jar" update="true" basedir="${mvnproject.build.directory}/repackage"/>
50+
</target>
51+
</configuration>
52+
<goals>
53+
<goal>run</goal>
54+
</goals>
55+
</execution>
56+
</executions>
57+
</plugin>
58+
</plugins>
59+
</build>
60+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
buildInfo=$( jfrog rt curl api/build/spring-javaformat-${VERSION}/${BUILD_NUMBER} )
2+
groupId=$( echo ${buildInfo} | jq -r '.buildInfo.modules[0].id' | sed 's/\(.*\):.*:.*/\1/' )
3+
version=$( echo ${buildInfo} | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' )
4+
5+
echo "Publishing ${buildName}/${buildNumber} (${groupId}:${version}) to Eclipse Update Site"
6+
7+
jfrog rt dl --build spring-javaformat-${VERSION}/${BUILD_NUMBER} '**/io.spring.javaformat.eclipse.site*.zip'
8+
9+
curl \
10+
-s \
11+
--connect-timeout 240 \
12+
--max-time 2700 \
13+
-u ${ARTIFACTORY_USERNAME}:${ARTIFACTORY_PASSWORD} \
14+
-f \
15+
-H "X-Explode-Archive: true" \
16+
-X PUT \
17+
-T "io/spring/javaformat/io.spring.javaformat.eclipse.site/${version}/io.spring.javaformat.eclipse.site-${version}.zip" \
18+
"https://repo.spring.io/javaformat-eclipse-update-site/${version}/" > /dev/null || { echo "Failed to publish" >&2; exit 1; }
19+
20+
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 )
21+
22+
repositories=""
23+
while read -r releasedVersion; do
24+
echo "Adding repository for ${releasedVersion}"
25+
repositories="${repositories}<repository><url>https://repo.spring.io/javaformat-eclipse-update-site/${releasedVersion}</url><layout>p2</layout></repository>"
26+
done <<< "${releasedVersions}"
27+
28+
sed "s|##repositories##|${repositories}|" ${GITHUB_ACTION_PATH}/publish-eclipse-update-site-pom-template.xml > publish-eclipse-update-site-pom.xml
29+
./mvnw -f publish-eclipse-update-site-pom.xml clean package || { echo "Failed to publish" >&2; exit 1; }
30+
31+
curl \
32+
-s \
33+
--connect-timeout 240 \
34+
--max-time 2700 \
35+
-u ${ARTIFACTORY_USERNAME}:${ARTIFACTORY_PASSWORD} \
36+
-f \
37+
-X PUT \
38+
-T "target/repository/content.jar" \
39+
"https://repo.spring.io/javaformat-eclipse-update-site/" > /dev/null || { echo "Failed to publish" >&2; exit 1; }
40+
41+
curl \
42+
-s \
43+
--connect-timeout 240 \
44+
--max-time 2700 \
45+
-u ${ARTIFACTORY_USERNAME}:${ARTIFACTORY_PASSWORD} \
46+
-f \
47+
-X PUT \
48+
-T "target/repository/artifacts.jar" \
49+
"https://repo.spring.io/javaformat-eclipse-update-site/" > /dev/null || { echo "Failed to publish" >&2; exit 1; }
50+
51+
echo "Publish complete"

Diff for: .github/actions/stage-code/action.yml

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name: 'Stage '
2-
description: 'Stage Code'
32
inputs:
43
current-version:
54
required: true

Diff for: .github/artifacts.spec

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"files": [
3+
{
4+
"aql": {
5+
"items.find": {
6+
"$and": [
7+
{
8+
"@build.name": "${buildName}",
9+
"@build.number": "${buildNumber}",
10+
"name": {
11+
"$nmatch": "*.zip"
12+
},
13+
"name": {
14+
"$nmatch": "*.zip.asc"
15+
}
16+
}
17+
]
18+
}
19+
},
20+
"target": "nexus/"
21+
}
22+
]
23+
}

Diff for: .github/workflows/promote.yml

+57-2
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,60 @@ jobs:
3333
name: Promote
3434
runs-on: ubuntu-latest
3535
steps:
36-
- name: Promote
37-
run: echo "Promote happens here"
36+
- name: Check Out
37+
uses: actions/checkout@v4
38+
- name: Set Up JFrog CLI
39+
uses: jfrog/setup-jfrog-cli@7c95feb32008765e1b4e626b078dfd897c4340ad # v4.1.2
40+
env:
41+
JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
42+
- name: Check Maven Central Sync Status
43+
id: check-sync-status
44+
run: |
45+
url=${{ format('https://repo.maven.apache.org/maven2/io/spring/javaformat/spring-javaformat/{0}/spring-javaformat-{0}.pom', inputs.version) }}
46+
status_code=$( curl --write-out '%{http_code}' --head --silent --output /dev/null ${url} )
47+
if [ "${status_code}" != 200 ] && [ "${status_code}" != 404 ]; then
48+
echo "Unexpected status code ${status_code}"
49+
exit 1
50+
fi
51+
echo "status-code=${status_code}" >> $GITHUB_OUTPUT
52+
- name: Download Release Artifacts
53+
if: ${{ steps.check-sync-status.outputs.status-code == '404' }}
54+
run: jf rt download --spec ./.github/artifacts.spec --spec-vars 'buildName=${{ format('spring-javaformat-{0}', inputs.version) }};buildNumber=${{ inputs.build-number }}'
55+
- name: Sync to Maven Central
56+
if: ${{ steps.check-sync-status.outputs.status-code == '404' }}
57+
uses: spring-io/[email protected]
58+
with:
59+
username: ${{ secrets.OSSRH_S01_TOKEN_USERNAME }}
60+
password: ${{ secrets.OSSRH_S01_TOKEN_PASSWORD }}
61+
staging-profile-name: ${{ secrets.OSSRH_S01_STAGING_PROFILE }}
62+
create: true
63+
upload: true
64+
close: true
65+
release: true
66+
generate-checksums: true
67+
- name: Await Maven Central Sync
68+
if: ${{ steps.check-sync-status.outputs.status-code == '404' }}
69+
run: |
70+
url=${{ format('https://repo.maven.apache.org/maven2/io/spring/javaformat/spring-javaformat/{0}/spring-javaformat-{0}.pom', inputs.version) }}
71+
echo "Waiting for $url"
72+
until curl --fail --head --silent $url > /dev/null
73+
do
74+
echo "."
75+
sleep 60
76+
done
77+
echo "$url is available"
78+
- name: Promote Build
79+
if: ${{ steps.check-sync-status.outputs.status-code == '404' }}
80+
run: jfrog rt build-promote ${{ format('spring-javaformat-{0}', inputs.version)}} ${{ inputs.build-number }} libs-release-local
81+
- name: Publish Eclipse Update Site
82+
uses: ./.github/actions/publish-eclipse-update-site
83+
with:
84+
version: ${{ inputs.version }}
85+
build-number: ${{ inputs.build-number }}
86+
artifactory-username: ${{ secrets.ARTIFACTORY_USERNAME }}
87+
artifactory-password: ${{ secrets.ARTIFACTORY_PASSWORD }}
88+
- name: Create GitHub Release
89+
uses: ./.github/actions/create-github-release
90+
with:
91+
milestone: ${{ inputs.version }}
92+
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}

0 commit comments

Comments
 (0)