Skip to content

Commit

Permalink
ci: update GitHub workflows
Browse files Browse the repository at this point in the history
- Change `grails.version` property to `projectVersion` to be able to leverage the `post-release` action for rolling back to snapshot.
- Update release workflow to use the gh client for creating GitHub release instead of rolling our own.
- Misc. improvements.

Aiming to fix gh-955
  • Loading branch information
matrei committed Mar 6, 2025
1 parent 59805f5 commit de23021
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 111 deletions.
10 changes: 0 additions & 10 deletions .github/actions/tag-and-release/Dockerfile

This file was deleted.

15 changes: 0 additions & 15 deletions .github/actions/tag-and-release/action.yml

This file was deleted.

35 changes: 0 additions & 35 deletions .github/actions/tag-and-release/entrypoint.sh

This file was deleted.

26 changes: 15 additions & 11 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@ jobs:
steps:
- name: "📥 Checkout the repository"
uses: actions/checkout@v4
- name: "🔀 Store current branch name"
run: |
TARGET_BRANCH="${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}"
echo "TARGET_BRANCH=${TARGET_BRANCH}" >> $GITHUB_ENV
echo "Target Branch: ${TARGET_BRANCH}"
- name: "📅 Set current date as env variable"
run: echo "NOW=$(date +'%Y-%m-%dT%H%M%S')" >> $GITHUB_ENV
run: |
NOW=$(date +'%Y-%m-%dT%H%M%S')
echo "NOW=${NOW}" >> $GITHUB_ENV
echo "Current date: ${NOW}"
- name: "☕️ Setup JDK"
uses: actions/setup-java@v4
with:
Expand All @@ -27,22 +35,18 @@ jobs:
uses: gradle/actions/setup-gradle@v4
with:
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
- name: "🔀 Extract branch name"
id: extract_branch
run: echo "value=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
- name: "🔨 Build Snapshot Documentation"
env:
TARGET_GRAILS_VERSION: ${{ github.event.inputs.grails_version }}
run: ./gradlew build -PgithubBranch=${{ steps.extract_branch.outputs.value }}
- name: "📤 Upload Docs Artifacts"
if: success()
run: >
./gradlew build
-PgithubBranch=${{ env.TARGET_BRANCH }}
- name: "📤 Upload Generated Docs to Workflow Result Page"
uses: actions/upload-artifact@v4
with:
name: grails-docs-${{ env.NOW }}.zip
path: ./build/distributions/*.zip
- name: "📤 Publish Snapshot Documentation to Github Pages"
if: success() && github.event_name == 'push'
uses: grails/github-pages-deploy-action@f1bddf4d126e4375529c0f397b028eb5ac9a13e6 # 2024-12-22
if: github.event_name == 'push'
uses: grails/github-pages-deploy-action@v3
env:
BRANCH: gh-pages
COMMIT_EMAIL: ${{ env.GIT_USER_EMAIL }}
Expand Down
73 changes: 40 additions & 33 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,24 @@ jobs:
GIT_USER_NAME: grails-build
GIT_USER_EMAIL: [email protected]
steps:
- name: "📥 Checkout the repository"
- name: "🔀 Get Target Branch name"
run: |
TARGET_BRANCH="${GITHUB_REF:11}"
echo "TARGET_BRANCH=${TARGET_BRANCH}" >> $GITHUB_ENV
echo "Target Branch: $TARGET_BRANCH"
- name: "📥 Checkout the Target Branch"
uses: actions/checkout@v4
with:
ref: ${{ env.TARGET_BRANCH }}
- name: "✔️ Commit the assigned Release Version to gradle.properties"
run: |
sed -i "s/^projectVersion.*$/projectVersion=${{ github.event.inputs.grails_version }}/" gradle.properties
cat gradle.properties
git config --global user.email "${{ env.GIT_USER_EMAIL }}"
git config --global user.name "${{ env.GIT_USER_NAME }}"
git add gradle.properties
git commit -m "[skip ci] Release v${{ github.event.inputs.grails_version }} docs"
git push origin ${{ env.TARGET_BRANCH }}
- name: "☕️ Setup JDK"
uses: actions/setup-java@v4
with:
Expand All @@ -35,48 +51,39 @@ jobs:
uses: gradle/actions/setup-gradle@v4
with:
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
- name: "🔀 Extract branch name"
if: success() && github.event_name == 'workflow_dispatch'
id: extract_branch
run: echo "value=${GITHUB_REF:11}" >> $GITHUB_OUTPUT
- name: "🏷️ Create and Push Release Tag"
uses: ./.github/actions/tag-and-release
if: success() && github.event_name == 'workflow_dispatch'
with:
target_branch: ${{ steps.extract_branch.outputs.value }}
grails_version: ${{ github.event.inputs.grails_version }}
- name: "🎉 Create GitHub Release"
if: success() && github.event_name == 'workflow_dispatch'
id: create_release
uses: ncipollo/release-action@cdcc88a9acf3ca41c16c37bb7d21b9ad48560d87 # v1.15.0 (Use commit sha as this is a 3rd party action)
with:
tag: v${{ github.event.inputs.grails_version }}
name: ${{ github.event.inputs.grails_version }}
prerelease: ${{ env.BETA }}
- name: "🔨 Generate Documentation"
- name: "🔨 Build the Documentation"
env:
TARGET_GRAILS_VERSION: ${{ github.event.inputs.grails_version }}
run: >
./gradlew assemble
-PgithubBranch=${{ steps.extract_branch.outputs.value }}
-PgithubBranch=${{ env.TARGET_BRANCH }}
--info --stacktrace
- name: "📤 Upload Asset to the Github Release page"
# if: success() && github.event_name == 'workflow_dispatch' skip for now as this is not working and manually upload zip
if: false
id: upload_artifact
uses: Roang-zero1/github-upload-release-artifacts-action@c15e0b65ce2ae1c8d52bfbc75d017d21e1da77d7 # v3.0.0 (Use commit sha as this is a 3rd party action)
with:
args: ./build/distributions/grails-docs-${{ github.event.inputs.grails_version }}.zip
created_tag: v${{ github.event.inputs.grails_version }}
- name: "🚩 Conditionally create a pre-release flag"
run: |
PRE_RELEASE_FLAG=""
if [ "${{ env.BETA }}" = "true" ]; then
PRE_RELEASE_FLAG="--pre-release"
fi
echo "PRE_RELEASE_FLAG=${PRE_RELEASE_FLAG}" >> $GITHUB_ENV
- name: "🎉 Create the GitHub Release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "📤 Publish to Github Pages"
if: success()
uses: grails/github-pages-deploy-action@f1bddf4d126e4375529c0f397b028eb5ac9a13e6 # 2024-12-22
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >
gh release create v${{ github.event.inputs.grails_version }}
build/distributions/grails-docs-${{ github.event.inputs.grails_version }}.zip
--title ${{ github.event.inputs.grails_version }}
--target ${{ env.TARGET_BRANCH }}
$PRE_RELEASE_FLAG
- name: "📤 Publish Documentation to Github Pages"
uses: grails/github-pages-deploy-action@v3
env:
BRANCH: gh-pages
COMMIT_EMAIL: ${{ env.GIT_USER_EMAIL }}
COMMIT_NAME: ${{ env.GIT_USER_NAME }}
FOLDER: build/docs
GH_TOKEN: ${{ secrets.GH_TOKEN }}
VERSION: ${{ github.event.inputs.grails_version }}
- name: "⚙️ Run post-release"
env:
RELEASE_VERSION: ${{ github.event.inputs.grails_version }}
uses: grails/github-actions/post-release@v3
9 changes: 4 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ compileJava.options.release = 17

import org.apache.tools.ant.taskdefs.condition.Os

version = project.findProperty("grails.version")
version = projectVersion
archivesBaseName = "grails-docs"

ext.grailsCheckOutDir = project.layout.buildDirectory.dir('grails-core/checkout').get().asFile.absolutePath
Expand All @@ -27,10 +27,9 @@ ext.explicitGrailsHome = System.getProperty("grails.home") ?: project.findProper
ext.grailsHome = explicitGrailsHome ? file(explicitGrailsHome).absolutePath : "${grailsCheckOutDir}/grails-src"
ext.explicitGrailsFunctionalTestsHome = System.getProperty("grails.functional.test.home") ?: project.findProperty('grails.functional.test.home')
ext.grailsTestsHome = explicitGrailsFunctionalTestsHome ? file(explicitGrailsFunctionalTestsHome).absolutePath : "${grailsTestsCheckOutDir}/grails-functional-tests-src"
ext.projectVersion = project.version

dependencies {
implementation platform("org.grails:grails-bom:${project['grails.version']}")
implementation platform("org.grails:grails-bom:$projectVersion")
implementation "org.grails:grails-docs"
implementation "org.apache.groovy:groovy"

Expand Down Expand Up @@ -195,8 +194,8 @@ tasks.register('publishGuide', grails.doc.gradle.PublishGuide) {
'springBootVersion' : springBootVersion,
'springVersion' : springVersion,
'gradleVersion' : gradle.gradleVersion,
'GrailsVersion' : project['grails.version'],
'version' : project['grails.version'],
'GrailsVersion' : projectVersion,
'version' : projectVersion,
'gormVersion' : gormVersion,
'spockVersion' : getVersion("spock-core"),
'testingSupportVersion' : getVersion("grails-testing-support"),
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repositories {
compileJava.options.release = 17

dependencies {
implementation platform("org.grails:grails-bom:${versions.getProperty("grails.version")}")
implementation platform("org.grails:grails-bom:${versions.getProperty('projectVersion')}")
implementation "org.grails:grails-docs"
implementation "org.apache.groovy:groovy"
}
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
grails.version=7.0.0-SNAPSHOT
# projectVersion = Grails version
projectVersion=7.0.0-SNAPSHOT

asciidoctorJvmVersion=4.0.4
githubSlug=grails/grails-doc
Expand Down

0 comments on commit de23021

Please sign in to comment.