Skip to content

Commit 8b0381c

Browse files
7agustibmclaude
andcommitted
ci: allow publishing snapshots without a tag
The deploy workflow only ran on a `v*` tag, so there was no way to publish a snapshot — and tagging one would say "release" about something that is not. Adds `workflow_dispatch`, and a guard: a manual run refuses to proceed unless the version ends in `-SNAPSHOT`, so releasing stays tied to a tag. The job now also builds and tests before publishing, which it never did. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent e7f6485 commit 8b0381c

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

‎.github/workflows/deploy.yml‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
name: Deploy to Reposilite
22

33
on:
4+
# Releases are cut from a tag.
45
push:
56
tags:
67
- 'v*'
8+
# Snapshots are published on demand from a branch, with no tag involved.
9+
workflow_dispatch:
710

811
jobs:
912

@@ -19,10 +22,25 @@ jobs:
1922
with:
2023
distribution: 'zulu'
2124
java-version: '17'
25+
2226
- name: Set up Gradle
2327
uses: gradle/actions/setup-gradle@v4
2428

25-
- name: Publish to Reposilite
29+
- name: Read version
30+
id: version
31+
run: echo "value=$(./gradlew -q printVersion)" >> "$GITHUB_OUTPUT"
32+
33+
# A manual run may only publish a snapshot; releasing is what the tag is for.
34+
- name: Refuse to release without a tag
35+
if: github.event_name == 'workflow_dispatch' && !endsWith(steps.version.outputs.value, '-SNAPSHOT')
36+
run: |
37+
echo "::error::Version ${{ steps.version.outputs.value }} is not a snapshot. Push a v* tag to release."
38+
exit 1
39+
40+
- name: Build and test
41+
run: ./gradlew build
42+
43+
- name: Publish ${{ steps.version.outputs.value }} to Reposilite
2644
env:
2745
MAVEN_NAME: '${{ secrets.MAVEN_NAME }}'
2846
MAVEN_TOKEN: '${{ secrets.MAVEN_TOKEN }}'

‎build.gradle.kts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,9 @@ tasks.jar {
128128
attributes("Automatic-Module-Name" to "io.javalin.community.graphql")
129129
}
130130
}
131+
132+
// Used by the deploy workflow to tell a snapshot from a release before publishing.
133+
tasks.register("printVersion") {
134+
val projectVersion = version.toString()
135+
doLast { println(projectVersion) }
136+
}

0 commit comments

Comments
 (0)