diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 23b796f..304bff5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: distribution: zulu java-version: | 8 - 21 + 23 - name: Cache Dependencies uses: actions/cache@v4 diff --git a/.github/workflows/deploy_to_maven_central.yml b/.github/workflows/deploy_to_maven_central.yml index 0459188..e57e4cc 100644 --- a/.github/workflows/deploy_to_maven_central.yml +++ b/.github/workflows/deploy_to_maven_central.yml @@ -16,7 +16,8 @@ jobs: open-release: runs-on: ubuntu-latest outputs: - INITIAL_REF_POSITION: ${{ steps.create-tag.outputs.INITIAL_REF_POSITION }} + INITIAL_MASTER_POSITION: ${{ steps.create-tag.outputs.INITIAL_MASTER_POSITION }} + INITIAL_GH_PAGES_POSITION: ${{ steps.create-tag.outputs.INITIAL_GH_PAGES_POSITION }} TAG: ${{ steps.create-tag.outputs.TAG }} VERSION: ${{ steps.create-tag.outputs.VERSION }} STAGING_PROFILE_ID: ${{ steps.parse-profile-id.outputs.STAGING_PROFILE_ID }} @@ -32,7 +33,7 @@ jobs: distribution: zulu java-version: | 8 - 21 + 23 server-id: maven-central-releases # Server authentication corresponds to "user token" returned by https://oss.sonatype.org/ server-username: OSSRH_USERNAME @@ -66,7 +67,7 @@ jobs: - name: Create tag id: create-tag run: | - echo "INITIAL_REF_POSITION=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" + echo "INITIAL_MASTER_POSITION=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" ./mvnw release:prepare --batch-mode -V -e TAG=$(git describe --tag --abbrev=0) echo "TAG=${TAG}" >> "$GITHUB_OUTPUT" @@ -113,7 +114,7 @@ jobs: distribution: zulu java-version: | 8 - 21 + 23 server-id: maven-central-releases # Server authentication corresponds to "user token" returned by https://oss.sonatype.org/ server-username: OSSRH_USERNAME @@ -139,8 +140,34 @@ jobs: -Dstaging_host="${{ env.STAGING_HOST }}" deploy -P release + document: + name: Publish Javadoc documentation + needs: deploy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.open-release.outputs.TAG }} + - uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: 23 + + - name: Generate Javadoc + run: | + ./mvnw --batch-mode -V -e javadoc:aggregate -pl !dropwizard,!jersey + mv target/reports/apidocs "${{ steps.create-tag.outputs.VERSION }}/docs/api" + + - name: Commit changes + run: > + git checkout gh-pages + echo "INITIAL_GH_PAGES_POSITION=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" + git add "${{ steps.create-tag.outputs.VERSION }}/docs/api" + git tag -a ${{ steps.create-tag.outputs.TAG }} -m "Released version ${{ steps.create-tag.outputs.VERSION }}" + git push + close-release: - needs: [ open-release, deploy ] + needs: [ open-release, deploy, document ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -152,7 +179,7 @@ jobs: distribution: zulu java-version: | 8 - 21 + 23 server-id: maven-central-releases # Server authentication corresponds to "user token" returned by https://oss.sonatype.org/ server-username: OSSRH_USERNAME @@ -176,7 +203,7 @@ jobs: # Cleanup on failure: https://stackoverflow.com/a/74562058/14731 on-failure: - needs: [ open-release, deploy, close-release ] + needs: [ open-release, deploy, document, close-release ] runs-on: ubuntu-latest if: ${{ failure() || cancelled() }} steps: @@ -190,7 +217,7 @@ jobs: distribution: zulu java-version: | 8 - 21 + 23 server-id: maven-central-releases # Server authentication corresponds to "user token" returned by https://oss.sonatype.org/ server-username: OSSRH_USERNAME @@ -198,13 +225,6 @@ jobs: gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} gpg-passphrase: MAVEN_GPG_PASSPHRASE - - name: Cache Dependencies - uses: actions/cache@v4 - with: - path: | - ~/.m2/repository/* - key: "${{ runner.OS }}-maven-${{ hashFiles('**/pom.xml') }}" - - name: Drop staging repository if: needs.open-release.outputs.STAGING_REPOSITORY_ID != '' && needs.open-release.outputs.STAGING_PROFILE_ID != '' run: > @@ -213,24 +233,37 @@ jobs: -d '{"data": {"stagedRepositoryId": "${{ needs.open-release.outputs.STAGING_REPOSITORY_ID }}", "description": "Dropping repository"}}' 'https://${{ env.STAGING_HOST }}/service/local/staging/profiles/${{ needs.open-release.outputs.STAGING_PROFILE_ID }}/drop' - - name: Configure Git User + - name: Restore the master ref to its original position + if: needs.open-release.outputs.INITIAL_MASTER_POSITION != '' run: | - git config user.email "cowwoc2020@gmail.com" - git config user.name "Gili Tzabari" + CURRENT_REF_POSITION=$(git rev-parse HEAD) + if [ "${CURRENT_REF_POSITION}" != "${{ needs.open-release.outputs.INITIAL_MASTER_POSITION }}" ]; then + git reset --hard ${{ needs.open-release.outputs.INITIAL_MASTER_POSITION }} + if [ "${{ github.ref_type }}" == "tag" ]; then + git ${{ github.ref_type }} -f ${{ github.ref_name }} + fi + git push -f origin ${{ github.ref_name }} + fi + + - name: Delete master's tag + if: needs.open-release.outputs.INITIAL_MASTER_POSITION != '' + run: | + git push --delete origin ${{ needs.open-release.outputs.TAG }} - - name: Restore the workflow ref to its original position - if: needs.open-release.outputs.INITIAL_REF_POSITION != '' + - name: Restore the gh-pages ref to its original position + if: needs.open-release.outputs.INITIAL_GH_PAGES_POSITION != '' run: | CURRENT_REF_POSITION=$(git rev-parse HEAD) - if [ "${CURRENT_REF_POSITION}" != "${{ needs.open-release.outputs.INITIAL_REF_POSITION }}" ]; then - git reset --hard ${{ needs.open-release.outputs.INITIAL_REF_POSITION }} + if [ "${CURRENT_REF_POSITION}" != "${{ needs.open-release.outputs.INITIAL_GH_PAGES_POSITION }}" ]; then + git reset --hard ${{ needs.open-release.outputs.INITIAL_GH_PAGES_POSITION }} if [ "${{ github.ref_type }}" == "tag" ]; then git ${{ github.ref_type }} -f ${{ github.ref_name }} fi git push -f origin ${{ github.ref_name }} fi - - name: Delete tag - if: needs.open-release.outputs.TAG != '' + - name: Delete gh-pages' tag + if: needs.open-release.outputs.INITIAL_GH_PAGES_POSITION != '' run: | - git push --delete origin ${{ needs.open-release.outputs.TAG }} \ No newline at end of file + git push --delete origin ${{ needs.open-release.outputs.TAG }} + git push