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/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 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 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 + +