Skip to content

Commit 523705a

Browse files
committed
#432 Publish SNAPSHOTs to GH Packages from CI
Add a publish-gh-packages job to gradle-build.yml that runs after build-artifacts succeeds and pushes all four artifacts plus the plugin marker to GitHub Packages. Triggers only on push events to feature/* or bugfix/* branches — those are the refs git-versioning rewrites to <slug>-SNAPSHOT coordinates. develop and main fall through to gradle.properties' static 2.0.0-rcN and would conflict with already-published release versions, so we skip them here. The job uses the auto-injected secrets.GITHUB_TOKEN (no PAT needed for in-repo publishing) and github.actor as the username. The conditional credential block in build.gradle picks them up; without the env vars set (e.g. on PRs from forks) the GitHubPackages repo isn't registered and the job's gradle invocation would be a no-op, but the 'if:' gate prevents that path from running at all.
1 parent 279b378 commit 523705a

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

.github/workflows/gradle-build.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,39 @@ jobs:
1818
secrets:
1919
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
2020

21+
publish-gh-packages:
22+
# Publish per-branch SNAPSHOTs to GitHub Packages so downstream consumers
23+
# can pull a feature/bugfix branch before it merges. Only runs on push
24+
# events to feature/bugfix branches (git-versioning's SNAPSHOT regex);
25+
# develop and main fall through to the static gradle.properties version
26+
# and would conflict with already-published releases.
27+
needs: build-artifacts
28+
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/heads/feature/') || startsWith(github.ref, 'refs/heads/bugfix/'))
29+
runs-on: ubuntu-latest
30+
permissions:
31+
packages: write
32+
contents: read
33+
steps:
34+
- name: Check out
35+
uses: actions/checkout@v5
36+
37+
- name: Setup Java
38+
uses: actions/setup-java@v5
39+
with:
40+
distribution: temurin
41+
java-version: '17'
42+
43+
- name: Setup Gradle
44+
uses: gradle/actions/setup-gradle@v4
45+
with:
46+
cache-read-only: true
47+
48+
- name: Publish SNAPSHOT to GitHub Packages
49+
env:
50+
GITHUB_USER: ${{ github.actor }}
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
run: ./gradlew publishAllPublicationsToGitHubPackagesRepository --no-daemon
53+
2154
post-build:
2255
needs: build-artifacts
2356
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)