forked from DSpace/xoai
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add manual workflow trigger for releases - Switch to Temurin - Determine Java version from POM instead of hardcoding
- Loading branch information
1 parent
0324546
commit 8dffbac
Showing
2 changed files
with
99 additions
and
39 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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Trigger release to Maven Central Repository | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: "The version to set for this release" | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
trigger: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
# We need write permission so we can push the next snapshot version | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: | | ||
git config user.name "github-actions[bot]" | ||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
# Alternative command if we just inherit the jdk.version from the parent (grep is faster): | ||
# $(mvn help:evaluate -Dexpression=jdk.version -q -DforceStdout) | ||
- name: Determine Java version from POM | ||
run: | | ||
echo "JAVA_VERSION=$(grep '<jdk.version>' pom.xml | cut -f2 -d'>' | cut -f1 -d'<')" >> ${GITHUB_ENV} | ||
- name: Set up JDK ${{ env.JAVA_VERSION }} | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: ${{ env.JAVA_VERSION }} | ||
distribution: 'temurin' | ||
cache: 'maven' | ||
|
||
- name: Update version in pom.xml and tag | ||
run: | | ||
mvn -B versions:set -DnewVersion="${{ inputs.version }}" -DgenerateBackupPoms=false | ||
git add pom.xml **/pom.xml | ||
git commit -m "[github-action] Release version ${{ inputs.version }}" | ||
git tag "xoai-${{ inputs.version }}" | ||
- name: Increment to next version, commit and push | ||
run: | | ||
mvn -B versions:set -DnextSnapshot -DnextSnapshotIndexToIncrement=2 -DgenerateBackupPoms=false | ||
git add pom.xml **/pom.xml | ||
git commit -m "[github-action] Increment version after release of ${{ inputs.version }}" | ||
git push --tags origin branch-5.0 | ||
release: | ||
name: Run release workflow | ||
uses: ./.github/workflows/maven-release.yml | ||
needs: [trigger] | ||
secrets: inherit | ||
with: | ||
version: "xoai-${{ inputs.version }}" |
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,44 +1,51 @@ | ||
name: Release to Maven Central Repository | ||
on: | ||
push: | ||
tags: | ||
- '*' | ||
push: | ||
tags: | ||
- '*' | ||
workflow_call: | ||
inputs: | ||
version: | ||
type: string | ||
required: true | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Java | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'adopt' | ||
- name: Cache Maven packages | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.m2 | ||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: ${{ runner.os }}-m2 | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- if: ${{ github.event_name == 'push' }} | ||
uses: actions/checkout@v4 | ||
- if: ${{ inputs.version }} | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: "${{ inputs.version }}" | ||
# Alternative command if we just inherit the jdk.version from the parent (grep is faster): | ||
# $(mvn help:evaluate -Dexpression=jdk.version -q -DforceStdout) | ||
- name: Determine Java version from POM | ||
run: | | ||
echo "JAVA_VERSION=$(grep '<jdk.version>' pom.xml | cut -f2 -d'>' | cut -f1 -d'<')" >> ${GITHUB_ENV} | ||
- name: Build, test, verify | ||
run: mvn -B verify | ||
- name: Check POM metadata for release | ||
run: mvn pomchecker:check-maven-central | ||
- name: Set up JDK ${{ env.JAVA_VERSION }} | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: ${{ env.JAVA_VERSION }} | ||
distribution: 'temurin' | ||
cache: 'maven' | ||
|
||
# Running setup-java again overwrites the settings.xml - IT'S MANDATORY TO DO THIS SECOND SETUP!!! | ||
- name: Set up Maven Central Repository | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'adopt' | ||
server-id: ossrh | ||
server-username: MAVEN_USERNAME | ||
server-password: MAVEN_PASSWORD | ||
gpg-private-key: ${{ secrets.DATAVERSEBOT_GPG_KEY }} | ||
gpg-passphrase: MAVEN_GPG_PASSPHRASE | ||
- name: Sign + Publish release | ||
run: mvn -Prelease deploy -pl '!report,!xoai-data-provider-tck' -DskipAnalysis -DskipUT -DskipIT | ||
env: | ||
MAVEN_USERNAME: ${{ secrets.DATAVERSEBOT_SONATYPE_USERNAME }} | ||
MAVEN_PASSWORD: ${{ secrets.DATAVERSEBOT_SONATYPE_TOKEN }} | ||
MAVEN_GPG_PASSPHRASE: ${{ secrets.DATAVERSEBOT_GPG_PASSWORD }} | ||
# Running setup-java again overwrites the settings.xml - IT'S MANDATORY TO DO THIS SECOND SETUP!!! | ||
- name: Set up Maven Central Repository | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: ${{ env.JAVA_VERSION }} | ||
distribution: 'temurin' | ||
server-id: ossrh | ||
server-username: MAVEN_USERNAME | ||
server-password: MAVEN_PASSWORD | ||
gpg-private-key: ${{ secrets.DATAVERSEBOT_GPG_KEY }} | ||
gpg-passphrase: MAVEN_GPG_PASSPHRASE | ||
- name: Sign + Publish release | ||
run: mvn -Prelease deploy -pl '!report,!xoai-data-provider-tck' -DskipAnalysis -DskipUT -DskipIT | ||
env: | ||
MAVEN_USERNAME: ${{ secrets.DATAVERSEBOT_SONATYPE_USERNAME }} | ||
MAVEN_PASSWORD: ${{ secrets.DATAVERSEBOT_SONATYPE_TOKEN }} | ||
MAVEN_GPG_PASSPHRASE: ${{ secrets.DATAVERSEBOT_GPG_PASSWORD }} |