Release To Maven Central #125
This file contains hidden or 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
| name: Release To Maven Central | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| releaseversion: | |
| description: "Version to release and publish to maven central." | |
| required: true | |
| copyDocsToCurrent: | |
| description: "Mark docs as 'latest'? This will create a redirect from /current to the version being published. This should only be set for the latest version of the documentation." | |
| required: true | |
| type: boolean | |
| default: false | |
| env: | |
| VERSION: ${{ github.event.inputs.releaseversion }} | |
| jobs: | |
| publish-central-and-pages: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - run: echo "Will start a Maven Central upload with version ${{ github.event.inputs.releaseversion }}" | |
| - name: free disk space | |
| continue-on-error: true | |
| run: | | |
| df -h | |
| sudo swapoff -a | |
| sudo rm -f /swapfile | |
| sudo apt clean | |
| if [ -n "$(docker image ls -q)" ]; then | |
| docker rmi -f $(docker image ls -aq) || true | |
| fi | |
| df -h | |
| - uses: actions/checkout@v6 | |
| - name: Set up settings.xml for Maven Central Repository | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| server-id: central | |
| server-username: MAVEN_USERNAME | |
| server-password: MAVEN_PASSWORD | |
| gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} | |
| gpg-passphrase: MAVEN_GPG_PASSPHRASE | |
| cache: 'maven' | |
| env: | |
| MAVEN_USERNAME: ${{ secrets.OSS_SONATYPE_USERNAME }} | |
| MAVEN_PASSWORD: ${{ secrets.OSS_SONATYPE_PASSWORD }} | |
| MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} | |
| - name: Cache node modules | |
| uses: actions/cache@v5 | |
| env: | |
| cache-name: cache-node-modules | |
| with: | |
| path: ~/.npm | |
| key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-build-${{ env.cache-name }}- | |
| - name: Set projects Maven version to GitHub Action GUI set version | |
| run: ./mvnw versions:set "-DnewVersion=${{ github.event.inputs.releaseversion }}" --no-transfer-progress | |
| - name: Publish package | |
| run: ./mvnw -B deploy --no-transfer-progress -P central-deploy -DskipTests | |
| env: | |
| #TODO: This is a workaround for NEXUS-27902 which uses XStream that fails on JVM >16 | |
| JDK_JAVA_OPTIONS: "--add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.text=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED" | |
| MAVEN_USERNAME: ${{ secrets.OSS_SONATYPE_USERNAME }} | |
| MAVEN_PASSWORD: ${{ secrets.OSS_SONATYPE_PASSWORD }} | |
| MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} | |
| - name: Build documentation with Maven | |
| run: ./mvnw -B --no-transfer-progress -pl spring-boot-admin-docs site | |
| - name: Deploy documentation to GitHub Pages for version ${{ github.event.inputs.releaseversion }} | |
| uses: JamesIves/github-pages-deploy-action@v4.8.0 | |
| with: | |
| branch: gh-pages | |
| folder: spring-boot-admin-docs/target/generated-docs/build | |
| target-folder: ${{ github.event.inputs.releaseversion }} | |
| clean: true | |
| - name: Deploy redirect for /current to /${{ github.event.inputs.releaseversion }} | |
| uses: JamesIves/github-pages-deploy-action@v4.8.0 | |
| if: github.event.inputs.copyDocsToCurrent == 'true' | |
| with: | |
| branch: gh-pages | |
| folder: spring-boot-admin-docs/target/generated-docs/build/current | |
| target-folder: /current | |
| clean: true | |
| - name: Deploy deeplink redirect for /current/* to /${{ github.event.inputs.releaseversion }}/* | |
| uses: JamesIves/github-pages-deploy-action@v4.8.0 | |
| if: github.event.inputs.copyDocsToCurrent == 'true' | |
| with: | |
| branch: gh-pages | |
| folder: spring-boot-admin-docs/target/generated-docs/build/current | |
| target-folder: / | |
| clean: false | |
| publish-github-release: | |
| needs: publish-central-and-pages | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: free disk space | |
| continue-on-error: true | |
| run: | | |
| df -h | |
| sudo swapoff -a | |
| sudo rm -f /swapfile | |
| sudo apt clean | |
| if [ -n "$(docker image ls -q)" ]; then | |
| docker rmi -f $(docker image ls -aq) || true | |
| fi | |
| df -h | |
| - name: Generate changelog | |
| id: changelog | |
| uses: metcalfc/changelog-generator@v4.6.2 | |
| with: | |
| myToken: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create GitHub Release | |
| id: create_release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.event.inputs.releaseversion }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| draft: false | |
| prerelease: ${{ contains(github.event.inputs.releaseversion, '-') }} | |