-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add job to release all Java modules by joining them together
- Loading branch information
1 parent
c129f12
commit 1d10f29
Showing
1 changed file
with
153 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,160 @@ | ||
name: Placeholder for consolidated Java release | ||
name: "Publish: release all java modules" | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
releaseversion: | ||
description: 'Release version' | ||
required: true | ||
nextversion: | ||
description: 'Next dev version' | ||
required: true | ||
|
||
jobs: | ||
test: | ||
release: | ||
if: github.event_name == 'workflow_dispatch' | ||
runs-on: ubuntu-latest | ||
env: | ||
RELEASE: ${{ inputs.releaseversion }} | ||
NEXT: ${{ inputs.nextversion }} | ||
steps: | ||
- run: echo "Hello Moo!" | ||
- name: Checkout main | ||
uses: actions/checkout@v3 | ||
with: | ||
path: main | ||
|
||
- name: Checkout pass-core | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: eclipse-pass/pass-core | ||
path: pass-core | ||
|
||
- name: Checkout pass-support | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: eclipse-pass/pass-support | ||
path: pass-support | ||
|
||
- name: Configure git user | ||
run: | | ||
git config --global user.name ${{ github.actor }} | ||
git config --global user.email "${{ github.actor }}@users.noreply.github.com" | ||
# Combine modules together so maven can do everything at once | ||
- name: Create combined module | ||
run: | | ||
mkdir combined | ||
cp main/pom.xml combined | ||
cp -r pass-core combined | ||
cp -r pass-support combined | ||
sed -i '/<\/developers>/a <modules><module>pass-core</module><module>pass-support</module></modules>' combined/pom.xml | ||
- name: Set the release version, commit the change, and tag it | ||
run: | | ||
(cd main && mvn versions:set -B -ntp -DnewVersion=$RELEASE && git commit -am "Update version to $RELEASE" && git tag $RELEASE) | ||
(cd pass-support && mvn versions:set -B -ntp -DnewVersion=$RELEASE && git commit -am "Update version to $RELEASE" && git tag $RELEASE) | ||
(cd pass-core && mvn versions:set -B -ntp -DnewVersion=$RELEASE && git commit -am "Update version to $RELEASE" && git tag $RELEASE) | ||
(cd combined && mvn versions:set -B -ntp -DnewVersion=$RELEASE) | ||
- name: Setup Java & Maven | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: 17 | ||
distribution: 'temurin' | ||
cache: 'maven' | ||
server-id: ossrh | ||
server-username: MAVEN_USERNAME | ||
server-password: MAVEN_PASSWORD | ||
gpg-private-key: ${{ secrets.MAVEN_GPG_KEY }} | ||
gpg-passphrase: MAVEN_GPG_PASSPHRASE | ||
|
||
# Build and deploy to sonatype if the release does not already exist. | ||
- name: Release Java modules | ||
working-directory: combined | ||
run: | | ||
goal="deploy" | ||
if curl -f -s https://oss.sonatype.org/service/local/repositories/releases/content/org/eclipse/pass/eclipse-pass-parent/$RELEASE/ > /dev/null; then | ||
echo "Release $RELEASE already exists" | ||
goal="install" | ||
fi | ||
mvn -B -U -V -ntp -P release -DstagingProgressTimeoutMinutes=15 clean $goal | tee release.log | ||
code=${PIPESTATUS[0]} | ||
marker1="Remote staging repositories are being released" | ||
marker2="Failed to execute goal org.sonatype.plugins:nexus-staging-maven-plugin" | ||
if [ "$code" -ne "0" ]; then | ||
if grep -q "$marker1" release.log && grep -q "$marker2" release.log; then | ||
echo "Failed cleaning up after pushing to Sonatype, but it may have succeeded anyway." | ||
else | ||
exit "$code" | ||
fi | ||
fi | ||
env: | ||
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | ||
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} | ||
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} | ||
|
||
- name: Wait for Sonatype artifacts | ||
run: | | ||
echo "Waiting for artifacts of $RELEASE to be released." | ||
counter=0 | ||
until curl -f -s https://oss.sonatype.org/service/local/repositories/releases/content/org/eclipse/pass/eclipse-pass-parent/$RELEASE/ > /dev/null | ||
do | ||
sleep 60 | ||
echo "." | ||
counter=$((counter+1)) | ||
if [ "$counter" -gt 20 ]; then | ||
echo "Timed out waiting for release" | ||
exit 1 | ||
fi | ||
done | ||
echo "Artifacts for $RELEASE have been released." | ||
- name: Set the next dev version and commit the change | ||
run: | | ||
(cd main && mvn versions:set -B -ntp -DnewVersion=$NEXT && git commit -am "Update version to $NEXT") | ||
(cd pass-support && mvn versions:set -B -ntp -DnewVersion=$NEXT && git commit -am "Update version to $NEXT") | ||
(cd pass-core && mvn versions:set -B -ntp -DnewVersion=$NEXT && git commit -am "Update version to $NEXT") | ||
(cd combined && mvn versions:set -B -ntp -DnewVersion=$NEXT) | ||
- name: Release dev Java modules | ||
working-directory: combined | ||
run: | | ||
mvn -B -V -ntp clean deploy -DskipTests -DskipITs | ||
env: | ||
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | ||
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} | ||
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} | ||
|
||
- name: Login to GHCR | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Push Docker image to GHCR | ||
run: | | ||
docker push ghcr.io/eclipse-pass/pass-core-main:$RELEASE | ||
docker push ghcr.io/eclipse-pass/pass-core-main:$NEXT | ||
docker push ghcr.io/eclipse-pass/deposit-services-core:$RELEASE | ||
docker push ghcr.io/eclipse-pass/deposit-services-core:$NEXT | ||
docker push ghcr.io/eclipse-pass/pass-notification-service:$RELEASE | ||
docker push ghcr.io/eclipse-pass/pass-notification-service:$NEXT | ||
docker push ghcr.io/eclipse-pass/jhu-grant-loader:$RELEASE | ||
docker push ghcr.io/eclipse-pass/jhu-grant-loader:$NEXT | ||
docker push ghcr.io/eclipse-pass/pass-journal-loader:$RELEASE | ||
docker push ghcr.io/eclipse-pass/pass-journal-loader:$NEXT | ||
docker push ghcr.io/eclipse-pass/pass-nihms-loader:$RELEASE | ||
docker push ghcr.io/eclipse-pass/pass-nihms-loader:$NEXT | ||
- name: Push the commits and tags | ||
run: | | ||
(cd main && git push origin && git push origin --tags) | ||
(cd pass-core && git push origin && git push origin --tags) | ||
(cd pass-core && git push origin && git push origin --tags) |