Skip to content

Commit 273b4af

Browse files
authored
ci(jreleaser): jreleaser env vars (#101)
1 parent 859664c commit 273b4af

File tree

8 files changed

+379
-93
lines changed

8 files changed

+379
-93
lines changed

.github/workflows/conventional-commits.yml

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ jobs:
88
conventional-commits:
99
runs-on: ubuntu-latest
1010
name: Validate Conventional Commits
11+
permissions:
12+
pull-requests: read
13+
statuses: write
1114

1215
steps:
1316
- name: Checkout Repository
@@ -43,30 +46,3 @@ jobs:
4346
doesn't start with an uppercase character.
4447
wip: true
4548
validateSingleCommit: false
46-
47-
- name: Validate individual commit messages
48-
run: |
49-
# Get all commits in this PR
50-
git log --format="%H %s" origin/${{ github.base_ref }}..HEAD > commits.txt
51-
52-
# Check each commit message
53-
while IFS= read -r line; do
54-
commit_hash=$(echo "$line" | cut -d' ' -f1)
55-
commit_msg=$(echo "$line" | cut -d' ' -f2-)
56-
57-
echo "Checking commit: $commit_hash"
58-
echo "Message: $commit_msg"
59-
60-
# Validate conventional commit format
61-
if ! echo "$commit_msg" | grep -E '^(feat|fix|docs|style|refactor|perf|test|build|ci|chore)(\(.+\))?: .+$'; then
62-
echo "❌ Commit $commit_hash does not follow conventional commits format:"
63-
echo " Message: $commit_msg"
64-
echo " Expected: type(scope): description"
65-
echo " Example: feat(auth): add user login functionality"
66-
exit 1
67-
fi
68-
69-
echo "✅ Commit $commit_hash follows conventional commits"
70-
done < commits.txt
71-
72-
echo "🎉 All commits follow conventional commits format!"

.github/workflows/release.yml

Lines changed: 83 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
name: Release And Publish
22

33
on:
4+
# Automatic trigger from build-main workflow
5+
workflow_run:
6+
workflows: ["Build Main"]
7+
types: [completed]
8+
branches: [main]
9+
10+
# Manual trigger for production releases
411
workflow_dispatch:
12+
inputs:
13+
releaseType:
14+
description: 'Release type'
15+
required: true
16+
default: 'release'
17+
type: choice
18+
options: ['release', 'snapshot']
19+
20+
# Support existing tag-based releases
521
push:
622
tags:
723
- "v*"
@@ -18,6 +34,24 @@ jobs:
1834
release:
1935
runs-on: ubuntu-latest
2036
timeout-minutes: 30
37+
# Only run if build-main succeeded OR manual/tag trigger
38+
if: |
39+
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') ||
40+
(github.event_name == 'workflow_dispatch') ||
41+
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
42+
43+
env:
44+
# GitHub Packages credentials required by buildSrc/Conventions.kt
45+
GPR_USER: ${{ vars.GPR_USER }}
46+
GPR_READ_TOKEN: ${{ secrets.GPR_READ_TOKEN }}
47+
48+
# Maven Central credentials for build system (mcUsername/mcPassword properties)
49+
MC_USERNAME: ${{ secrets.MC_USERNAME }}
50+
MC_PASSWORD: ${{ secrets.MC_PASSWORD }}
51+
52+
# JReleaser credentials (single-line values)
53+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
54+
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2155

2256
steps:
2357
- name: Checkout Repository
@@ -27,18 +61,44 @@ jobs:
2761
fetch-depth: 0
2862
fetch-tags: true
2963

30-
- name: Determine version and create release
64+
- name: Determine Release Context
65+
id: release-context
3166
run: |
32-
CURRENT_VERSION=$(./gradlew -q currentVersion)
33-
echo "Current version: $CURRENT_VERSION"
67+
if [[ "${{ github.event_name }}" == "workflow_run" ]]; then
68+
echo "📸 Automatic snapshot after successful build"
69+
echo "release_type=snapshot" >> $GITHUB_OUTPUT
70+
echo "trigger_source=automatic" >> $GITHUB_OUTPUT
71+
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
72+
echo "👤 Manual release triggered"
73+
echo "release_type=${{ github.event.inputs.releaseType }}" >> $GITHUB_OUTPUT
74+
echo "trigger_source=manual" >> $GITHUB_OUTPUT
75+
elif [[ "${{ github.event_name }}" == "push" ]]; then
76+
echo "🏷️ Tag push triggered"
77+
echo "release_type=release" >> $GITHUB_OUTPUT
78+
echo "trigger_source=tag" >> $GITHUB_OUTPUT
79+
fi
3480
35-
if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then
36-
echo "📋 Manual trigger - creating new release"
37-
./gradlew markNextVersion
81+
- name: Generate Version
82+
id: version
83+
run: |
84+
RELEASE_TYPE="${{ steps.release-context.outputs.release_type }}"
85+
86+
if [[ "$RELEASE_TYPE" == "snapshot" ]]; then
87+
echo "🔄 Creating snapshot version"
88+
# Use snapshot mode
89+
VERSION=$(./gradlew -q currentVersion -Prelease.mode=snapshot)
90+
echo "version=$VERSION" >> $GITHUB_OUTPUT
91+
echo "is_snapshot=true" >> $GITHUB_OUTPUT
3892
else
39-
echo "🏷️ Tag trigger - version already determined by tag"
93+
echo "🚀 Creating release version"
94+
# Use release mode
95+
VERSION=$(./gradlew -q currentVersion -Prelease.mode=release)
96+
echo "version=$VERSION" >> $GITHUB_OUTPUT
97+
echo "is_snapshot=false" >> $GITHUB_OUTPUT
4098
fi
4199
100+
echo "Final version: $VERSION"
101+
42102
- name: Setup Java
43103
uses: actions/setup-java@v4
44104
with:
@@ -58,6 +118,12 @@ jobs:
58118

59119
# Build & stage all subprojects into root/build/staging-deploy
60120
- name: Build & publish to local staging dir
121+
run: |
122+
./gradlew --no-daemon build publishAllPublicationsToLocalStagingRepository -Prelease.mode=${{ steps.release-context.outputs.release_type }}
123+
124+
# Export multiline GPG keys (single-line vars are set at job level)
125+
- name: Export GPG keys
126+
shell: bash
61127
run: |
62128
./gradlew --no-daemon build publishAllPublicationsToLocalStagingRepository
63129
@@ -72,27 +138,21 @@ jobs:
72138
# GPG passphrase
73139
echo "JRELEASER_GPG_PASSPHRASE=${{ secrets.GPG_PASSPHRASE }}" >> $GITHUB_ENV
74140
75-
# Armored public key (preserve newlines)
76-
echo "JRELEASER_GPG_PUBLIC_KEY<<EOF" >> $GITHUB_ENV
77-
echo "${{ secrets.GPG_PUBLIC_KEY }}" >> $GITHUB_ENV
78-
echo "EOF" >> $GITHUB_ENV
79-
80-
# Armored secret key (preserve newlines)
81-
echo "JRELEASER_GPG_SECRET_KEY<<EOF" >> $GITHUB_ENV
82-
echo "${{ secrets.GPG_SECRET_KEY }}" >> $GITHUB_ENV
83-
echo "EOF" >> $GITHUB_ENV
84-
85-
# Use the built-in GitHub token for GitHub release
86-
echo "JRELEASER_GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
87141
88142
# sanity checks before the real release
89143
- name: JReleaser dry run checks
90-
run: ./gradlew --no-daemon jreleaserConfig jreleaserAssemble jreleaserChangelog
144+
run: ./gradlew --no-daemon jreleaserConfig jreleaserAssemble jreleaserChangelog -Prelease.mode=${{ steps.release-context.outputs.release_type }}
91145

92146
# Deploy to Maven Central (Publisher API) and create GitHub Release
93-
# Use `jreleaserDeploy` if you ONLY want Central without creating a GH release.
94-
- name: JReleaser full release
95-
run: ./gradlew --no-daemon jreleaserFullRelease
147+
- name: JReleaser Configuration
148+
run: |
149+
if [[ "${{ steps.version.outputs.is_snapshot }}" == "true" ]]; then
150+
echo "📦 Publishing snapshot to Maven Central staging"
151+
./gradlew --no-daemon jreleaserDeploy -Prelease.mode=snapshot
152+
else
153+
echo "🎉 Full release to Maven Central and GitHub"
154+
./gradlew --no-daemon jreleaserFullRelease -Prelease.mode=release
155+
fi
96156
97157
# (Optional) Upload JReleaser output for debugging/audit
98158
- name: Upload JReleaser output

PORMPT.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
re

0 commit comments

Comments
 (0)