Publish #27
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: Publish | |
| on: | |
| workflow_run: | |
| workflows: [ Build ] | |
| branches: [ main ] | |
| types: [ completed ] | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| publish: | |
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-java@v5 | |
| with: | |
| distribution: temurin | |
| java-version: 17 | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v6 | |
| - name: Compute publish version | |
| run: | | |
| VERSION_COUNTER=$(git rev-list --count HEAD) | |
| PROJECT_VERSION=0.${VERSION_COUNTER}.0 | |
| TAG_NAME=v${PROJECT_VERSION} | |
| echo "PROJECT_VERSION=${PROJECT_VERSION}" >> "$GITHUB_ENV" | |
| echo "TAG_NAME=${TAG_NAME}" >> "$GITHUB_ENV" | |
| - name: Publish to GitHub packages | |
| run: ./gradlew publishAllPublicationsToGitHubPackagesRepository -PprojectVersion=${PROJECT_VERSION} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Publish to local repo | |
| run: ./gradlew publishAllPublicationsToRepoLocalRepository -PprojectVersion=${PROJECT_VERSION} | |
| - name: Checkout maven2 branch | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: maven2 | |
| path: maven2-branch | |
| - name: Update maven2 branch with new artifacts | |
| run: | | |
| rsync -av build/repo/ maven2-branch/ | |
| cd maven2-branch | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add -A | |
| if git diff --cached --quiet; then | |
| echo "No changes to commit" | |
| exit 0 | |
| fi | |
| git commit -m "New release ${PROJECT_VERSION}" | |
| git push origin maven2 | |
| - name: Create GitHub pre-release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ env.TAG_NAME }} | |
| name: ${{ env.TAG_NAME }} | |
| prerelease: true | |
| generate_release_notes: true | |
| make_latest: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |