fix auto version increment #1080
Workflow file for this run
This file contains 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: Continuous Integration | |
on: [push, pull_request, workflow_dispatch] | |
jobs: | |
publish: | |
name : Publish | |
runs-on: ubuntu-latest | |
env: | |
# https://proandroiddev.com/publishing-a-maven-artifact-3-3-step-by-step-instructions-to-mavencentral-publishing-bd661081645d | |
SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }} | |
SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} | |
# https://blog.solidsoft.pl/2020/06/03/simpler-and-safer-artifact-signing-on-ci-server-with-gradle/ | |
# https://stackoverflow.com/questions/57921325/gradle-signarchives-unable-to-read-secret-key | |
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SONATYPE_SIGNING_KEY_PASSWORD }} | |
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SONATYPE_SIGNING_PRIVATE_KEY }} | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
persist-credentials: false # without this, all access tokens set later on will be ignored | |
- name: Check if snapshot version | |
run: | | |
VERSION_NAME=$(./gradlew -q printVersionName | tail -n 1) | |
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV | |
IS_SNAPSHOT_VERSION=$([[ "$VERSION_NAME" =~ ^[0-9]+\.[0-9]+\.[0-9]+-SNAPSHOT$ ]] && echo "true" || echo "false") | |
echo "IS_SNAPSHOT_VERSION=$IS_SNAPSHOT_VERSION" >> $GITHUB_ENV | |
- name: Set next snapshot version | |
if: ${{ env.IS_SNAPSHOT_VERSION == 'false' }} | |
run: | | |
echo "Setting next snapshot version" | |
./gradlew incrementPatchVersion --info | |
./gradlew setSnapshotVersionSuffix --info | |
git config user.name github-actions | |
git config user.email [email protected] | |
git add gradle.properties | |
git commit -m "Setting next snapshot version [skip ci]" | |
git push --follow-tags |