From 0befabab2978889f3be9fd1e88c3702864e86f9e Mon Sep 17 00:00:00 2001 From: thomasperkins1123 Date: Mon, 10 Jun 2024 18:36:11 +0100 Subject: [PATCH 1/3] Configure for automatic uploads to maven central --- pom.xml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/pom.xml b/pom.xml index ff16c2d..c7080ba 100644 --- a/pom.xml +++ b/pom.xml @@ -51,6 +51,10 @@ https://oss.sonatype.org/content/repositories/snapshots + + ossrh + https://oss.sonatype.org/service/local/staging/deploy/maven2 + @@ -64,6 +68,21 @@ 3.2.1 + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.13 + true + + ossrh + https://oss.sonatype.org/ + true + + + + stdbuild @@ -92,6 +111,7 @@ attach-sources + verify jar @@ -107,6 +127,7 @@ attach-javadocs + verify jar @@ -195,6 +216,16 @@ sign verify + + true + ${gpg.keyname} + ${gpg.keyname} + + --batch + --pinentry-mode + loopback + + From 3b6b61081657d85fe36b05ea6ab10400e0f54f96 Mon Sep 17 00:00:00 2001 From: thomasperkins1123 Date: Mon, 10 Jun 2024 19:28:51 +0100 Subject: [PATCH 2/3] Add a workflow to automaticly release to maven central --- .github/settings.xml | 27 +++++++++++++++++ .github/workflows/release.yml | 57 +++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 .github/settings.xml create mode 100644 .github/workflows/release.yml diff --git a/.github/settings.xml b/.github/settings.xml new file mode 100644 index 0000000..4c687a0 --- /dev/null +++ b/.github/settings.xml @@ -0,0 +1,27 @@ + + + + + ${env.GPG_ID} + ${env.GPG_PASSPHRASE} + + + ossrh + ${env.MAVEN_USERNAME} + ${env.MAVEN_PASSWORD} + + + + + release + + true + + + ${env.GPG_ID} + + + + \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8598c6a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,57 @@ +name: Release to Maven Central + +on: + push: + branches: + - "main" + +jobs: + sign-build: + runs-on: ubuntu-latest + steps: + - name: Checkout this branch + uses: actions/checkout@v4 + with: + token: ${{ github.token }} + fetch-depth: 0 + + - name: Check version number has been increased + run: | + CURRENT_VERSION="v$(awk -F'[<>]' '// {print $3; exit}' pom.xml)" + echo "Current version: '$CURRENT_VERSION'" + PREVIOUS_VERSION=$(git describe --tags --abbrev=0) + echo "Previous version: '$PREVIOUS_VERSION'" + if [[ "$CURRENT_VERSION" == "$PREVIOUS_VERSION" ]]; then + echo "Version number has not changed" + echo "skip=true" >> $GITHUB_ENV + else + echo "skip=false" >> $GITHUB_ENV + fi + + - name: Configure GPG Key + if: ${{ env.skip == 'false' }} + run: | + echo -n "$GPG_KEY_BASE64" | base64 --decode | gpg --batch --passphrase ${GPG_PASSPHRASE} --import + env: + GPG_KEY_BASE64: ${{ secrets.GPG_KEY_BASE64 }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + + - name: Deploy Signed Jar to Maven Central + if: ${{ env.skip == 'false' }} + run: | + mvn clean deploy -B -P sign,stdbuild --settings .github/settings.xml repository:bundle-create + env: + GPG_ID: ${{ secrets.GPG_ID }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} + + - name: Create Release on GitHub + if: ${{ env.skip == 'false' }} + env: + GH_TOKEN: ${{ github.token }} + run: | + VERSION_NUMBER=$(awk -F'[<>]' '// {print $3; exit}' pom.xml) + git tag "v$VERSION_NUMBER" + git push origin "v$VERSION_NUMBER" + gh release create "v$VERSION_NUMBER" --repo="$GITHUB_REPOSITORY" --title="v$VERSION_NUMBER" --generate-notes From 52d8ef62da3be4c878ac099dca4facb70e4d13fc Mon Sep 17 00:00:00 2001 From: thomasperkins1123 Date: Tue, 11 Jun 2024 12:28:41 +0100 Subject: [PATCH 3/3] Add a CI README --- .github/workflows/README.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .github/workflows/README.md diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 0000000..2630def --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,7 @@ +# CI Readme + +## Release + +To create a new release make a PR from `develop` into `main`. Once this is merged if the version number has changed a signed build will then be created and pushed to maven central. If all checks pass this will go live automatically (This may take up to 48 hours). + +Once this is complete create a mergeback from `main` into `develop` to keep both branches in sync. \ No newline at end of file