diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2ec70863..3fcb7599 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,11 +1,10 @@ name: Publish on: + release: + types: [ created ] push: branches: [ main ] - tags: - - "v[0-9]+.[0-9]+.[0-9]+" # Push events to matching v*, i.e. v1.0, v20.15.10 - - "v[0-9]+.[0-9]+.[0-9]+-rc*" # Push events to matching v*, i.e. v1.0-rc1, v20.15.10-rc5 jobs: publish-libraries: @@ -37,20 +36,21 @@ jobs: GPG_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} run: | VERSION=noop - if [[ $GITHUB_REF == refs/tags/* ]]; then - VERSION=${GITHUB_REF#refs/tags/} - elif [[ $GITHUB_REF == refs/heads/* ]]; then + SNAPSHOT=1.0-SNAPSHOT + if [[ $GITHUB_REF == refs/tags/* ]]; then # If its a tag, then its a release, and we use that + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + VERSION=$(echo $VERSION | sed -e 's/^v//') + elif [[ $GITHUB_REF == refs/heads/* ]]; then # If its a head branch, check if its the default, and set to snapshot version VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') - echo ::set-output name=branch::${VERSION} if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then - VERSION=latest + VERSION=$SNAPSHOT fi fi echo version::${VERSION} ./gradlew publishToSonatype \ + $(if [ $VERSION = $SNAPSHOT ]; then echo 'closeSonatypeStagingRepository'; else echo 'closeAndReleaseSonatypeStagingRepository'; fi) \ -Pversion=${VERSION} \ -PartifactVersion=${VERSION} \ - closeAndReleaseSonatypeStagingRepository \ -Psigning.keyId=B7D30ABE \ -Psigning.password="$GPG_PASSWORD" \ -Psigning.secretKeyRingFile=$GITHUB_WORKSPACE/release.gpg \