1+ name : Publish to GitHub Packages
2+
3+ on :
4+ push :
5+ tags :
6+ - ' v*' # Triggers on version tags like v1.0.0, v2.1.3, etc.
7+ workflow_dispatch : # Allows manual trigger from GitHub Actions UI
8+
9+ jobs :
10+ publish :
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ - name : Checkout code
15+ uses : actions/checkout@v4
16+
17+ - name : Set up JDK
18+ uses : actions/setup-java@v4
19+ with :
20+ distribution : ' temurin'
21+ java-version : ' 21' # Match the project's Java version requirement (buildSrc needs Java 21)
22+
23+ - name : Cache Gradle packages
24+ uses : actions/cache@v4
25+ with :
26+ path : |
27+ ~/.gradle/caches
28+ ~/.gradle/wrapper
29+ key : ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
30+
31+ - name : Grant execute permission for Gradle wrapper
32+ run : chmod +x ./gradlew
33+
34+ # CONFIGURATION REQUIRED:
35+ # The following step publishes to GitHub Packages using credentials.
36+ # No additional setup is needed as the project already has:
37+ # 1. maven-publish plugin configured in lib/build.gradle.kts
38+ # 2. GitHub Packages repository configuration with proper URL
39+ # 3. Authentication using USERNAME and TOKEN environment variables
40+ #
41+ # The GITHUB_TOKEN is automatically provided by GitHub Actions and has
42+ # the necessary permissions to publish packages to the same repository.
43+ #
44+ # If you need to publish to a different repository's packages, you would need to:
45+ # 1. Create a Personal Access Token (PAT) with 'write:packages' permission
46+ # 2. Add it as a repository secret (e.g., PACKAGES_TOKEN)
47+ # 3. Use that secret instead of GITHUB_TOKEN
48+ #
49+ # The current version is hardcoded in lib/build.gradle.kts as "1.0.0"
50+ # For dynamic versioning, consider:
51+ # 1. Using the git tag (${GITHUB_REF#refs/tags/})
52+ # 2. Reading version from gradle.properties
53+ # 3. Using a gradle plugin like 'axion-release-plugin'
54+ - name : Publish to GitHub Packages
55+ env :
56+ USERNAME : ${{ github.actor }} # GitHub username of the user/bot triggering the workflow
57+ TOKEN : ${{ secrets.GITHUB_TOKEN }} # GitHub token with packages:write permission
58+ run : ./gradlew publish
0 commit comments