Skip to content

Commit 39fba6e

Browse files
committed
[skip ci] - pre release workflow
1 parent a55a335 commit 39fba6e

File tree

5 files changed

+145
-16
lines changed

5 files changed

+145
-16
lines changed

.github/workflows/gradle.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ on:
1111
workflow_dispatch:
1212
jobs:
1313
build:
14+
outputs:
15+
found_skip_publish: ${{ steps.check_prevent_property.outputs.value }}
1416
permissions:
1517
contents: read # to fetch code (actions/checkout)
1618
strategy:
@@ -21,6 +23,14 @@ jobs:
2123
steps:
2224
- name: "📥 Checkout repository"
2325
uses: actions/checkout@v4
26+
- name: "🔍 Check if we should skip publish"
27+
id: check_prevent_property
28+
run: |
29+
if grep -q '^preventSnapshotPublish=true' gradle.properties; then
30+
echo "value=true" >> $GITHUB_OUTPUT
31+
else
32+
echo "value=false" >> $GITHUB_OUTPUT
33+
fi
2434
- name: "☕️ Setup JDK"
2535
uses: actions/setup-java@v4
2636
with:
@@ -37,7 +47,7 @@ jobs:
3747
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
3848
run: ./gradlew build assemble groovydoc
3949
publish:
40-
if: github.event_name == 'push'
50+
if: github.event_name == 'push' && needs.build.outputs.found_skip_publish != 'true'
4151
needs: build
4252
permissions:
4353
contents: read # limit to read access
@@ -66,7 +76,7 @@ jobs:
6676
-Dorg.gradle.internal.publish.checksums.insecure=true
6777
publish
6878
docs:
69-
if: github.event_name == 'push'
79+
if: github.event_name == 'push' && needs.build.outputs.found_skip_publish != 'true'
7080
needs: publish
7181
runs-on: ubuntu-latest
7282
permissions:

.github/workflows/pre-release.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: "🖨️ Pre Release"
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
targetVersion:
6+
description: 'Expected Release Version'
7+
required: true
8+
env:
9+
GIT_USER_NAME: 'grails-build'
10+
GIT_USER_EMAIL: '[email protected]'
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
packages: write
17+
steps:
18+
# - name: "💥 Purge Existing Builds - org.grails.grails-gsp"
19+
# run: |
20+
# curl -L \
21+
# -X DELETE \
22+
# -H "Accept: application/vnd.github+json" \
23+
# -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
24+
# -H "X-GitHub-Api-Version: 2022-11-28" \
25+
# https://api.github.com/orgs/${{ github.repository_owner }}/packages/maven/org.grails.grails-gsp || true
26+
- name: "📥 Checkout repository"
27+
uses: actions/checkout@v4
28+
- name: "🛑 Set Prevent Snapshot Publishing Flag"
29+
run: |
30+
sed -i "s/^preventSnapshotPublish.*$/preventSnapshotPublish\=true/" gradle.properties
31+
- name: "📩 Commit flag to prevent snapshot publishing"
32+
run: |
33+
git config user.name "${{ env.GIT_USER_NAME }}"
34+
git config user.email "${{ env.GIT_USER_EMAIL }}"
35+
git add gradle.properties
36+
if ! git diff --cached --quiet; then
37+
git commit -m "[skip ci] Pre Release - ${{ github.event.inputs.targetVersion }} - Preventing Snapshot Publishing"
38+
git push origin HEAD
39+
else
40+
echo "Publishing already disabled."
41+
fi
42+
- name: "☕️ Setup JDK"
43+
uses: actions/setup-java@v4
44+
with:
45+
distribution: 'liberica'
46+
java-version: '17'
47+
- name: "🐘 Setup Gradle"
48+
uses: gradle/actions/setup-gradle@v4
49+
with:
50+
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
51+
- name: "⚙ Set version to ${{ github.event.inputs.targetVersion }}"
52+
run: |
53+
sed -i "s/^projectVersion.*$/projectVersion\=${{ github.event.inputs.targetVersion }}/" gradle.properties
54+
cat gradle.properties
55+
- name: "🧩 Run Assemble"
56+
if: success()
57+
run: ./gradlew assemble
58+
env:
59+
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
60+
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
61+
- name: "🔐 Generate key file for artifact signing"
62+
env:
63+
SECRING_FILE: ${{ secrets.SECRING_FILE }}
64+
run: echo $SECRING_FILE | base64 -d > ${{ github.workspace }}/secring.gpg
65+
- name: "📤 Publish to GitHub Packages"
66+
id: publish
67+
env:
68+
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
69+
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
70+
GITHUB_USERNAME: ${{ secrets.GITHUB_ACTOR }}
71+
GITHUB_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
72+
GITHUB_PUBLISH: 'true'
73+
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
74+
SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }}
75+
SECRING_FILE: ${{ secrets.SECRING_FILE }}
76+
run: >
77+
./gradlew
78+
-Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg
79+
publish

.github/workflows/release.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,30 @@ jobs:
1616
GIT_USER_NAME: 'grails-build'
1717
GIT_USER_EMAIL: '[email protected]'
1818
steps:
19+
# - name: "💥 Purge Existing Builds - org.grails.plugins.gsp"
20+
# run: |
21+
# curl -L \
22+
# -X DELETE \
23+
# -H "Accept: application/vnd.github+json" \
24+
# -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
25+
# -H "X-GitHub-Api-Version: 2022-11-28" \
26+
# https://api.github.com/orgs/${{ github.repository_owner }}/packages/maven/org.grails.plugins.gsp || true
1927
- name: "📥 Checkout repository"
2028
uses: actions/checkout@v4
29+
- name: "⎌ Revert Prevent Snapshot Publishing Flag"
30+
run: |
31+
sed -i "s/^preventSnapshotPublish.*$/preventSnapshotPublish\=false/" gradle.properties
32+
- name: "📩 Commit flag to allow snapshot publishing"
33+
run: |
34+
git config user.name "${{ env.GIT_USER_NAME }}"
35+
git config user.email "${{ env.GIT_USER_EMAIL }}"
36+
git add gradle.properties
37+
if ! git diff --cached --quiet; then
38+
git commit -m "[skip ci] Restore Snapshot Publishing"
39+
git push origin HEAD
40+
else
41+
echo "Publishing already enabled."
42+
fi
2143
- name: "☕️ Setup JDK"
2244
uses: actions/setup-java@v4
2345
with:

build.gradle

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ apply plugin: 'idea'
1616
ext {
1717
isJava8Compatible = org.gradle.api.JavaVersion.current().isJava8Compatible()
1818
grailsVersion = project.projectVersion
19-
isBuildSnapshot = grailsVersion.endsWith("-SNAPSHOT")
20-
isReleaseVersion = !isBuildSnapshot
2119
isCiBuild = System.getenv().get("CI") as Boolean
20+
isGitHubRepoPublish = System.getenv("GITHUB_PUBLISH") == 'true'
21+
isGrailsRepoPublish = grailsVersion.endsWith("-SNAPSHOT") && !isGitHubRepoPublish
22+
isReleaseVersion = !isGrailsRepoPublish && !isGitHubRepoPublish
23+
2224
springLoadedCommonOptions = "-Xverify:none -Dspringloaded.synchronize=true -Djdk.reflect.allowGetCallerClass=true"
2325

2426
nexusUsername = System.getenv("SONATYPE_USERNAME") ?: project.hasProperty("sonatypeOssUsername") ? project.sonatypeOssUsername : ''
@@ -217,17 +219,27 @@ subprojects { subproject ->
217219
}
218220
}
219221
publishing {
220-
221-
if (isBuildSnapshot) {
222+
if (isGrailsRepoPublish || isGitHubRepoPublish) {
222223
repositories {
223224
maven {
224225
credentials {
225-
def u = subproject.hasProperty("artifactoryPublishUsername") ? subproject.getProperty('artifactoryPublishUsername') : System.getenv("ARTIFACTORY_USERNAME")
226-
def p = subproject.hasProperty("artifactoryPublishPassword") ? subproject.getProperty('artifactoryPublishPassword') : System.getenv("ARTIFACTORY_PASSWORD")
227-
username = u
228-
password = p
226+
if (isGrailsRepoPublish) {
227+
def u = subproject.hasProperty("artifactoryPublishUsername") ? subproject.getProperty('artifactoryPublishUsername') : System.getenv("ARTIFACTORY_USERNAME")
228+
def p = subproject.hasProperty("artifactoryPublishPassword") ? subproject.getProperty('artifactoryPublishPassword') : System.getenv("ARTIFACTORY_PASSWORD")
229+
username = u
230+
password = p
231+
} else {
232+
def u = System.getenv('GITHUB_USERNAME') ?: ''
233+
def p = System.getenv('GITHUB_PASSWORD') ?: ''
234+
username = u
235+
password = p
236+
}
237+
}
238+
if (isGrailsRepoPublish) {
239+
url "https://repo.grails.org/grails/libs-snapshots-local"
240+
} else {
241+
url 'https://maven.pkg.github.com/grails/grails-core'
229242
}
230-
url "https://repo.grails.org/grails/libs-snapshots-local"
231243
}
232244
}
233245
}
@@ -272,18 +284,20 @@ subprojects { subproject ->
272284

273285
afterEvaluate {
274286
signing {
275-
required { isReleaseVersion && gradle.taskGraph.hasTask("publish") }
287+
required { (isReleaseVersion || isGitHubRepoPublish) && gradle.taskGraph.hasTask("publish") }
276288
sign publishing.publications.maven
277289
}
278290
}
279291

280292
tasks.withType(Sign) {
281-
onlyIf { isReleaseVersion }
293+
onlyIf { isReleaseVersion || isGitHubRepoPublish }
282294
}
283295

284296
//do not generate extra load on Nexus with new staging repository if signing fails
285-
tasks.withType(io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository).configureEach {
286-
shouldRunAfter(tasks.withType(Sign))
297+
if (isReleaseVersion) {
298+
tasks.withType(io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository).configureEach {
299+
shouldRunAfter(tasks.withType(Sign))
300+
}
287301
}
288302
}
289303

gradle.properties

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,8 @@ spock.version=2.3-groovy-4.0
7979
spotbugs-annotations.version=4.8.6
8080
spring-boot.version=3.4.0
8181
springloaded.version=1.2.8.RELEASE
82-
views-json-testing-support.version=4.0.0-SNAPSHOT
82+
views-json-testing-support.version=4.0.0-SNAPSHOT
83+
84+
# Set when we are temporarily releasing, should be false unless we want to prevent
85+
# snapshot or documentation publishes.
86+
preventSnapshotPublish=false

0 commit comments

Comments
 (0)