0.0.0 #1
Workflow file for this run
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: Gradle publish | |
| on: | |
| release: | |
| types: [created] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 3 | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: 21 | |
| cache: 'gradle' | |
| - uses: gradle/actions/setup-gradle@v4 | |
| - name: Configure Git | |
| run: git config --global user.email "no-reply@github.com" && git config --global user.name "Github Actions" | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Get commit hash | |
| run: | | |
| COMMIT_HASH=$(git rev-parse --short HEAD) | |
| echo "COMMIT_HASH=$COMMIT_HASH" >> $GITHUB_ENV | |
| - name: Set version | |
| run: | | |
| VERSION=${{ github.event.release.name }} | |
| if [ "${{ github.event.release.prerelease }}" = "true" ]; then | |
| FULL_VERSION="${VERSION}-commit-${COMMIT_HASH}" | |
| else | |
| FULL_VERSION="${VERSION}" | |
| fi | |
| echo "Setting version to $FULL_VERSION" | |
| sed -i "s/^project_version = .*/project_version = $FULL_VERSION/" gradle.properties | |
| echo "FULL_VERSION=$FULL_VERSION" >> $GITHUB_ENV | |
| - name: Commit version change | |
| run: | | |
| git config --global user.name "Gitea Actions" | |
| git config --global user.email "actions@gitea.com" | |
| git checkout -b ${{github.event.release.target_commitish}} | |
| git add . | |
| git commit -m "[ci-skip] Update version to ${{ env.FULL_VERSION }}" | |
| git push --force origin ${{github.event.release.target_commitish}} | |
| - name: Build | |
| run: ./gradlew publish --no-daemon --stacktrace | |
| env: | |
| REPOSILITE_TOKEN: ${{secrets.REPOSILITE_TOKEN}} | |
| REPOSILITE_URL: ${{secrets.REPOSILITE_URL}} | |
| REPOSILITE_USER: ${{secrets.REPOSILITE_USER}} | |
| - name: Rebuild on Failure | |
| if: ${{ failure() }} | |
| run: | | |
| ./gradlew clean cleanCache | |
| ./gradlew publish --no-daemon --stacktrace | |
| env: | |
| REPOSILITE_TOKEN: ${{secrets.REPOSILITE_TOKEN}} | |
| REPOSILITE_URL: ${{secrets.REPOSILITE_URL}} | |
| REPOSILITE_USER: ${{secrets.REPOSILITE_USER}} |