-
Notifications
You must be signed in to change notification settings - Fork 14
43 lines (37 loc) · 1.33 KB
/
on-release-tag.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
name: Tag & Release Workflow
on:
push:
tags:
- 'v*'
jobs:
release:
if: ${{ github.repository == 'Breus/json-masker' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- name: Get version from tag
id: get-version
shell: bash
run: |
version="${GITHUB_REF_NAME#v}"
regex="^([0-9]+)\.([0-9]+)\.([0-9]+)(-[a-zA-Z0-9]+)?$"
if [[ $version =~ $regex ]]; then
echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
else
echo "Version $version is not a valid SemVer"
exit 1
fi
- name: Build
run: ./gradlew -Pversion=${{ steps.get-version.outputs.version }} publishToMavenLocal
- name: Upload release artifacts to Sonatype
env:
SONATYPE_TOKEN_USERNAME: ${{ secrets.SONATYPE_TOKEN_USERNAME }}
SONATYPE_TOKEN_PASSWORD: ${{ secrets.SONATYPE_TOKEN_PASSWORD }}
GPG_PRIV_KEY: ${{ secrets.GPG_PRIV_KEY }}
GPG_PASS_PHRASE: ${{ secrets.GPG_PASS_PHRASE }}
run: ./gradlew -Pversion=${{ steps.get-version.outputs.version }} publishAllPublicationsToSonatypeRepository closeAndReleaseSonatypeStagingRepository