Skip to content

Commit 52cfe56

Browse files
committed
CI release test with manual approval
1 parent 89d6959 commit 52cfe56

2 files changed

Lines changed: 86 additions & 39 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Create Release Tag from gradle.properties
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
create-tag:
8+
name: Create and Push v<version> Tag
9+
environment: maven-central-release
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Read version from gradle.properties
17+
id: get_version
18+
run: |
19+
VERSION=$(grep "^version=" gradle.properties | cut -d'=' -f2 | tr -d '[:space:]')
20+
echo "VERSION=$VERSION"
21+
echo "version=$VERSION" >> $GITHUB_OUTPUT
22+
23+
- name: Check that version is not a SNAPSHOT
24+
run: |
25+
VERSION="${{ steps.get_version.outputs.version }}"
26+
echo "Checking version: $VERSION"
27+
if [[ "$VERSION" =~ -SNAPSHOT$ ]]; then
28+
echo "❌ Refusing to create tag for SNAPSHOT version: $VERSION"
29+
exit 1
30+
fi
31+
echo "✅ Version is valid for release."
32+
33+
- name: Check if tag already exists
34+
run: |
35+
VERSION="${{ steps.get_version.outputs.version }}"
36+
TAG="v$VERSION"
37+
echo "Checking if tag $TAG already exists..."
38+
if git ls-remote --tags origin | grep -q "refs/tags/$TAG"; then
39+
echo "❌ Tag $TAG already exists on remote. Aborting."
40+
exit 1
41+
fi
42+
echo "✅ Tag does not exist yet."
43+
44+
- name: Create and push v${{ steps.get_version.outputs.version }} tag
45+
run: |
46+
VERSION="${{ steps.get_version.outputs.version }}"
47+
TAG="v$VERSION"
48+
git config user.name "GitHub Actions"
49+
git config user.email "actions@github.com"
50+
git tag "$TAG"
51+
git push origin "$TAG"

.github/workflows/release.yml

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -24,47 +24,43 @@ jobs:
2424
echo "${{secrets.SIGNING_KEY}}" > ~/.gradle/secring.gpg.b64
2525
base64 -d ~/.gradle/secring.gpg.b64 > ~/.gradle/secring.gpg
2626
- name: Publish package
27-
run: ./gradlew publishToSonatype closeStagingRepositories -Psigning.keyId=${{ secrets.SIGNING_KEY_ID }} -Psigning.password=${{ secrets.SIGNING_PASSWORD }} -Psigning.secretKeyRingFile=$(echo ~/.gradle/secring.gpg) --warn --stacktrace
27+
run: ./gradlew publishToSonatype closeSonatypeStagingRepository -Psigning.keyId=${{ secrets.SIGNING_KEY_ID }} -Psigning.password=${{ secrets.SIGNING_PASSWORD }} -Psigning.secretKeyRingFile=$(echo ~/.gradle/secring.gpg) --warn --stacktrace
2828
env:
2929
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
3030
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
31-
# - name: Close And Release Repository
32-
# run: ./gradlew closeAndReleaseRepository
31+
32+
# verify:
33+
# name: Verify Staged Release
34+
# runs-on: ubuntu-latest
35+
# needs: publish-and-close
36+
# steps:
37+
# - uses: actions/checkout@v4
38+
# # Example checks you can add here:
39+
# # - Run dependency scanner (osv-scanner)
40+
# # - Run license checks
41+
# # - Run static code analysis
42+
#
43+
# - name: Dummy check (replace with real checks)
44+
# run: |
45+
# echo "Run your security / quality checks here."
46+
#
47+
# release:
48+
# name: Release Staging Repo
49+
# environment: maven-central-release
50+
# runs-on: ubuntu-latest
51+
# needs: verify
52+
# steps:
53+
# - uses: actions/checkout@v4
54+
#
55+
# - name: Set up JDK 11
56+
# uses: actions/setup-java@v4
57+
# with:
58+
# java-version: '11'
59+
# distribution: 'temurin'
60+
#
61+
# - name: Release Staging Repo
3362
# env:
3463
# MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
35-
# MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
36-
verify:
37-
name: Verify Staged Release
38-
runs-on: ubuntu-latest
39-
needs: publish-and-close
40-
steps:
41-
- uses: actions/checkout@v4
42-
# Example checks you can add here:
43-
# - Run dependency scanner (osv-scanner)
44-
# - Run license checks
45-
# - Run static code analysis
46-
47-
- name: Dummy check (replace with real checks)
48-
run: |
49-
echo "Run your security / quality checks here."
50-
51-
release:
52-
name: Release Staging Repo
53-
environment: maven-central-release
54-
runs-on: ubuntu-latest
55-
needs: verify
56-
steps:
57-
- uses: actions/checkout@v4
58-
59-
- name: Set up JDK 11
60-
uses: actions/setup-java@v4
61-
with:
62-
java-version: '11'
63-
distribution: 'temurin'
64-
65-
- name: Release Staging Repo
66-
env:
67-
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
68-
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
69-
run: |
70-
./gradlew releaseStagingRepositories
64+
# MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
65+
# run: |
66+
# ./gradlew releaseSonatypeStagingRepository

0 commit comments

Comments
 (0)