diff --git a/.github/actions/post-release/Dockerfile b/.github/actions/post-release/Dockerfile deleted file mode 100644 index 16bb5b13d33..00000000000 --- a/.github/actions/post-release/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -# Container image that runs your code -FROM alpine:3.16 - -RUN apk add --no-cache curl jq git bash - -# Copies your code file from your action repository to the filesystem path `/` of the container -COPY *.sh / - -# Code file to execute when the docker container starts up (`entrypoint.sh`) -ENTRYPOINT ["/entrypoint.sh"] diff --git a/.github/actions/post-release/README.md b/.github/actions/post-release/README.md deleted file mode 100644 index bed1d496925..00000000000 --- a/.github/actions/post-release/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# Grails post-release action - -Performs some actions after doing a release - -## Example usage - -```yaml -uses: grails/post-release@master -with: - token: ${{ secrets.GITHUB_TOKEN }} -``` diff --git a/.github/actions/post-release/action.yml b/.github/actions/post-release/action.yml deleted file mode 100644 index 80485a2aedd..00000000000 --- a/.github/actions/post-release/action.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: 'Grails post-release action' -description: 'Performs some actions after doing a release' -inputs: - token: - description: 'GitHub token to authenticate the requests' - required: true - default: ${{ github.token }} -runs: - using: 'docker' - image: 'Dockerfile' - args: - - ${{ inputs.token }} diff --git a/.github/actions/post-release/entrypoint.sh b/.github/actions/post-release/entrypoint.sh deleted file mode 100755 index 2662e2d810e..00000000000 --- a/.github/actions/post-release/entrypoint.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash -# $1 == GH_TOKEN - -if [ -z "$SNAPSHOT_SUFFIX" ]; then - SNAPSHOT_SUFFIX="-SNAPSHOT" -fi - -if [ -z "$GIT_USER_EMAIL" ]; then - GIT_USER_EMAIL="${GITHUB_ACTOR}@users.noreply.github.com" -fi - -if [ -z "$GIT_USER_NAME" ]; then - GIT_USER_NAME="grails-build" -fi - -echo -n "Determining release version: " -if [ -z "$RELEASE_VERSION" ]; then - release_version=${GITHUB_REF:11} -else - release_version=${RELEASE_VERSION} -fi -echo $release_version - -echo -n "Determining next version: " -next_version=`/increment_version.sh -p $release_version` -echo $next_version -echo "next_version=${next_version}" >> $GITHUB_OUTPUT - -echo "Configuring git" -git config --global user.email "$GIT_USER_EMAIL" -git config --global user.name "$GIT_USER_NAME" -git config --global --add safe.directory /github/workspace -git fetch - -echo -n "Determining target branch: " -if [ -z "$TARGET_BRANCH" ]; then - target_branch=`cat $GITHUB_EVENT_PATH | jq '.release.target_commitish' | sed -e 's/^"\(.*\)"$/\1/g'` -else - target_branch=${TARGET_BRANCH} -fi -echo $target_branch -git checkout $target_branch - -echo -n "Retrieving current milestone number: " -milestone_number=`curl -s https://api.github.com/repos/$GITHUB_REPOSITORY/milestones | jq -c ".[] | select (.title == \"$release_version\") | .number" | sed -e 's/"//g'` -echo $milestone_number - -echo "Closing current milestone" -curl -s --request PATCH -H "Authorization: Bearer $1" -H "Content-Type: application/json" https://api.github.com/repos/$GITHUB_REPOSITORY/milestones/$milestone_number --data '{"state":"closed"}' - -echo "Getting issues closed" -issues_closed=`curl -s "https://api.github.com/repos/$GITHUB_REPOSITORY/issues?milestone=$milestone_number&state=closed" | jq '.[] | "* \(.title) (#\(.number))"' | sed -e 's/^"\(.*\)"$/\1/g'` -echo $issues_closed - -echo -n "Getting release url: " -release_url=`cat $GITHUB_EVENT_PATH | jq '.release.url' | sed -e 's/^"\(.*\)"$/\1/g'` -echo $release_url - -echo -n "Getting release body: " -release_body=`cat $GITHUB_EVENT_PATH | jq '.release.body' | sed -e 's/^"\(.*\)"$/\1/g'` -echo $release_body - -echo -n "Updating release body: " -release_body="${release_body}\r\n${issues_closed}" -echo $release_body -curl -i --request PATCH -H "Authorization: Bearer $1" -H "Content-Type: application/json" $release_url --data "{\"body\": \"$release_body\"}" - -echo "Creating new milestone" -curl -s --request POST -H "Authorization: Bearer $1" -H "Content-Type: application/json" "https://api.github.com/repos/$GITHUB_REPOSITORY/milestones" --data "{\"title\": \"$next_version\"}" - -echo "Setting new snapshot version" -sed -i "s/^projectVersion.*$/projectVersion\=${next_version}$SNAPSHOT_SUFFIX/" gradle.properties -sed -i "s/assertEquals(\".*$/assertEquals(\"${next_version}$SNAPSHOT_SUFFIX\", GrailsUtil.getGrailsVersion());/" grails-core/src/test/groovy/grails/util/GrailsUtilTests.java -sed -n "/assertEquals(\".*/p" grails-core/src/test/groovy/grails/util/GrailsUtilTests.java -cat gradle.properties - -echo "Committing and pushing" -git add gradle.properties -git add grails-core/src/test/groovy/grails/util/GrailsUtilTests.java -git commit -m "Back to ${next_version}$SNAPSHOT_SUFFIX" -git push origin $target_branch - -echo "Setting release version back so that Maven Central sync can work" -sed -i "s/^projectVersion.*$/projectVersion\=${release_version}/" gradle.properties -cat gradle.properties diff --git a/.github/actions/post-release/increment_version.sh b/.github/actions/post-release/increment_version.sh deleted file mode 100755 index 0ee774bc736..00000000000 --- a/.github/actions/post-release/increment_version.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -# Increment a version string using Semantic Versioning (SemVer) terminology. -# Source: https://github.com/fmahnke/shell-semver - -# Parse command line options. - -while getopts ":Mmp" Option -do - case $Option in - M ) major=true;; - m ) minor=true;; - p ) patch=true;; - esac -done - -shift $(($OPTIND - 1)) - -version=$1 - -# Build array from version string. - -a=( ${version//./ } ) - -# Increment version numbers as requested. - -if [ ! -z $major ] -then - ((a[0]++)) - a[1]=0 - a[2]=0 -fi - -if [ ! -z $minor ] -then - ((a[1]++)) - a[2]=0 -fi - -if [ ! -z $patch ] && ! [[ "${a[2]}" =~ M.*|RC.* ]] && ! [[ "${a[3]}" =~ ^M.*|^RC.* ]] -then - ((a[2]++)) -else - a[2]=0 -fi - -echo "${a[0]}.${a[1]}.${a[2]}" diff --git a/.github/actions/pre-release/Dockerfile b/.github/actions/pre-release/Dockerfile deleted file mode 100644 index e4cba7c1e43..00000000000 --- a/.github/actions/pre-release/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -# Container image that runs your code -FROM alpine:3.16 - -RUN apk add --no-cache curl jq git bash - -# Copies your code file from your action repository to the filesystem path `/` of the container -COPY entrypoint.sh /entrypoint.sh - -# Code file to execute when the docker container starts up (`entrypoint.sh`) -ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/.github/actions/pre-release/README.md b/.github/actions/pre-release/README.md deleted file mode 100644 index bc6e44199c5..00000000000 --- a/.github/actions/pre-release/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# Grails pre-release action - -Performs some actions before doing a release - -## Example usage - -```yaml -uses: grails/grails-core/pre-release@master -with: - token: ${{ secrets.GITHUB_TOKEN }} -``` diff --git a/.github/actions/pre-release/action.yml b/.github/actions/pre-release/action.yml deleted file mode 100644 index 6e09e44039f..00000000000 --- a/.github/actions/pre-release/action.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: 'Grails pre-release action' -description: 'Performs some actions before doing a release' -inputs: - token: - description: 'GitHub token to authenticate the requests' - required: true - default: ${{ github.token }} -runs: - using: 'docker' - image: 'Dockerfile' - args: - - ${{ inputs.token }} diff --git a/.github/actions/pre-release/entrypoint.sh b/.github/actions/pre-release/entrypoint.sh deleted file mode 100755 index a11a218ecda..00000000000 --- a/.github/actions/pre-release/entrypoint.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -# $1 == GH_TOKEN - -echo -n "Determining release version: " -release_version=${GITHUB_REF:11} -echo $release_version - -if [ -z "$GIT_USER_NAME" ]; then - GIT_USER_NAME="grails-build" -fi - -echo "Configuring git" -git config --global user.email "$GIT_USER_EMAIL" -git config --global user.name "$GIT_USER_NAME" -git config --global --add safe.directory /github/workspace -git fetch - -echo -n "Determining target branch: " -target_branch=`cat $GITHUB_EVENT_PATH | jq '.release.target_commitish' | sed -e 's/^"\(.*\)"$/\1/g'` -echo $target_branch -git checkout $target_branch - -echo "Setting release version in gradle.properties" -sed -i "s/^projectVersion.*$/projectVersion\=${release_version}/" gradle.properties -sed -i "s/assertEquals(\".*$/assertEquals(\"${release_version}\", GrailsUtil.getGrailsVersion());/" grails-core/src/test/groovy/grails/util/GrailsUtilTests.java -sed -n "/assertEquals(\".*/p" grails-core/src/test/groovy/grails/util/GrailsUtilTests.java -cat gradle.properties - -echo "Pushing release version and recreating v${release_version} tag" -git add gradle.properties -git add grails-core/src/test/groovy/grails/util/GrailsUtilTests.java -git commit -m "[skip ci] Release v${release_version}" -git tag -fa v${release_version} -m "Release v${release_version}" -git push origin v${release_version} --force - -echo "Closing again the release after updating the tag" -release_url=`cat $GITHUB_EVENT_PATH | jq '.release.url' | sed -e 's/^"\(.*\)"$/\1/g'` -echo $release_url -curl -s --request PATCH -H "Authorization: Bearer $1" -H "Content-Type: application/json" $release_url --data "{\"draft\": false}" diff --git a/.github/dependabot.yml b/.github/dependabot.yml index a84b57f4e4c..dc49c1e9d50 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -19,3 +19,7 @@ updates: target-branch: 7.0.x labels: - "type: dependency upgrade" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/scripts/setReleasedGrailsVersion.sh b/.github/scripts/setReleasedGrailsVersion.sh new file mode 100644 index 00000000000..e7a89a95e78 --- /dev/null +++ b/.github/scripts/setReleasedGrailsVersion.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +echo "Setting new version in GrailsUtilsTests.java: ${RELEASE_VERSION}" +sed -i "s/assertEquals(\".*$/assertEquals(\"${RELEASE_VERSION}\", GrailsUtil.getGrailsVersion());/" "${GITHUB_WORKSPACE}/grails-core/src/test/groovy/grails/util/GrailsUtilTests.java" +sed -n "/assertEquals(\".*/p" "${GITHUB_WORKSPACE}/grails-core/src/test/groovy/grails/util/GrailsUtilTests.java" +git add "${GITHUB_WORKSPACE}/grails-core/src/test/groovy/grails/util/GrailsUtilTests.java" \ No newline at end of file diff --git a/.github/scripts/setSnapshotGrailsVersion.sh b/.github/scripts/setSnapshotGrailsVersion.sh new file mode 100644 index 00000000000..28eed5d68ee --- /dev/null +++ b/.github/scripts/setSnapshotGrailsVersion.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +echo "Setting new version in GrailsUtilsTests.java: ${NEXT_VERSION}-SNAPSHOT" +sed -i "s/assertEquals(\".*$/assertEquals(\"${NEXT_VERSION}-SNAPSHOT\", GrailsUtil.getGrailsVersion());/" "${GITHUB_WORKSPACE}/grails-core/src/test/groovy/grails/util/GrailsUtilTests.java" +sed -n "/assertEquals(\".*/p" "${GITHUB_WORKSPACE}/grails-core/src/test/groovy/grails/util/GrailsUtilTests.java" +git add "${GITHUB_WORKSPACE}/grails-core/src/test/groovy/grails/util/GrailsUtilTests.java" diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 8c8f7917dec..6b01b59efc1 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -127,9 +127,19 @@ jobs: echo $TARGET_BRANCH echo "value=${TARGET_BRANCH}" >> $GITHUB_OUTPUT - name: "📡 Invoke the grails-doc release workflow" - uses: benc-uk/workflow-dispatch@e2e5e9a103e331dad343f381a29e654aea3cf8fc # v1.2.4 (Use commit sha as this is a 3rd party action) + uses: actions/github-script@v7 with: - workflow: Java CI - repo: grails/grails-doc - ref: ${{ steps.extract_branch.outputs.value }} - token: ${{ secrets.GH_TOKEN }} + github-token: ${{ secrets.GH_TOKEN }} + script: | + try { + const result = await github.rest.actions.createWorkflowDispatch({ + owner: 'apache', + repo: 'grails-doc', + workflow_id: 'gradle.yml', + ref: '${{ steps.extract_branch.outputs.value }}' + }); + console.log(result); + } catch(error) { + console.error(error); + core.setFailed(error); + } diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index 5e8aee97291..8f3a67def06 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -447,7 +447,6 @@ jobs: sed -i "s/^projectVersion.*$/projectVersion\=${{ github.event.inputs.targetVersion }}/" gradle.properties cat gradle.properties - name: "🧩 Run Assemble" - if: success() run: ./gradlew -U assemble env: DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d752cf4fdce..2242cda000a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,9 +13,6 @@ jobs: outputs: release_version: ${{ steps.release_version.outputs.value }} target_branch: ${{ steps.extract_branch.outputs.value }} - env: - GIT_USER_NAME: 'grails-build' - GIT_USER_EMAIL: 'grails-build@users.noreply.github.com' steps: - name: "💥 Purge Existing Builds - org.grails.grails-bom" run: | @@ -416,8 +413,8 @@ jobs: sed -i "s/^preventSnapshotPublish.*$/preventSnapshotPublish\=false/" gradle.properties - name: "📩 Commit flag to allow snapshot publishing" run: | - git config user.name "${{ env.GIT_USER_NAME }}" - git config user.email "${{ env.GIT_USER_EMAIL }}" + git config user.name "${{ github.actor }}" + git config user.email "${{ github.actor }}@users.noreply.github.com" git add gradle.properties if ! git diff --cached --quiet; then git commit -m "[skip ci] Restore Snapshot Publishing" @@ -444,37 +441,35 @@ jobs: - name: "📝 Store the current release version" id: release_version run: echo "value=${GITHUB_REF:11}" >> $GITHUB_OUTPUT - - name: "⚙️ Run pre-release" - uses: ./.github/actions/pre-release + - name: '⚙️ Run pre-release' + uses: apache/grails-github-actions/pre-release@asf + env: + RELEASE_VERSION: ${{ steps.release_version.outputs.value }} + RELEASE_SCRIPT_PATH: '.github/scripts/setReleasedGrailsVersion.sh' - name: "🧩 Run Assemble" - if: success() id: assemble env: DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} run: ./gradlew assemble - name: "📤 Upload Distribution" - if: success() uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: grails-${{ steps.release_version.outputs.value }}.zip path: build/distributions/grails-${{ steps.release_version.outputs.value }}.zip - name: "📤 Upload artifacts to the Github release" - if: success() 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-${{ steps.release_version.outputs.value }}.zip env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: > + gh release upload v${{ steps.release_version.outputs.value }} + build/distributions/grails-${{ steps.release_version.outputs.value }}.zip - name: "🔐 Generate secring file" - if: success() env: SECRING_FILE: ${{ secrets.SECRING_FILE }} run: echo $SECRING_FILE | base64 -d > ${{ github.workspace }}/secring.gpg - name: "📤 Publish to Sonatype OSSRH" id: publish - if: success() env: DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} @@ -524,8 +519,9 @@ jobs: findSonatypeStagingRepository releaseSonatypeStagingRepository - name: "⚙️ Run post-release" - if: success() - uses: ./.github/actions/post-release + uses: apache/grails-github-actions/post-release@asf + env: + RELEASE_SCRIPT_PATH: '.github/scripts/setSnapshotGrailsVersion.sh' docs: environment: docs needs: publish @@ -540,13 +536,23 @@ jobs: env: RELEASE_VERSION: ${{ needs.publish.outputs.release_version }} - name: "📡 Invoke grails-doc release workflow" - uses: benc-uk/workflow-dispatch@e2e5e9a103e331dad343f381a29e654aea3cf8fc # v1.2.4 (Use commit sha as this is a 3rd party action) + uses: actions/github-script@v7 with: - workflow: Release - repo: grails/grails-doc - ref: ${{ needs.publish.outputs.target_branch }} - token: ${{ secrets.GH_TOKEN }} - inputs: ${{ steps.prep_inputs.outputs.value }} + github-token: ${{ secrets.GH_TOKEN }} + script: | + try { + const result = await github.rest.actions.createWorkflowDispatch({ + owner: 'apache', + repo: 'grails-doc', + workflow_id: 'release.yml', + ref: '${{ needs.publish.outputs.target_branch }}', + inputs: ${{ steps.prep_inputs.outputs.value }} + }); + console.log(result); + } catch(error) { + console.error(error); + core.setFailed(error); + } website: environment: website needs: publish @@ -561,12 +567,20 @@ jobs: env: RELEASE_VERSION: ${{ needs.publish.outputs.release_version }} - name: "📡 Invoke grails-static-website release workflow" - if: success() - id: grails_static_website - uses: benc-uk/workflow-dispatch@e2e5e9a103e331dad343f381a29e654aea3cf8fc # v1.2.4 (Use commit sha as this is a 3rd party action) + uses: actions/github-script@v7 with: - workflow: Release - repo: grails/grails-static-website - ref: master - token: ${{ secrets.GH_TOKEN }} - inputs: ${{ steps.prep_inputs.outputs.value }} + github-token: ${{ secrets.GH_TOKEN }} + script: | + try { + const result = await github.rest.actions.createWorkflowDispatch({ + owner: 'apache', + repo: 'grails-static-website', + workflow_id: 'release.yml', + ref: 'master', + inputs: ${{ steps.prep_inputs.outputs.value }} + }); + console.log(result); + } catch(error) { + console.error(error); + core.setFailed(error); + } diff --git a/.github/workflows/retry-release.yml b/.github/workflows/retry-release.yml index 9988e1b4bdb..caa8ec86176 100644 --- a/.github/workflows/retry-release.yml +++ b/.github/workflows/retry-release.yml @@ -54,12 +54,11 @@ jobs: - name: "📤 Upload artifacts to the Github release" id: upload_artifact if: steps.assemble.outcome == 'success' - uses: Roang-zero1/github-upload-release-artifacts-action@c15e0b65ce2ae1c8d52bfbc75d017d21e1da77d7 # v3.0.0 (Use commit sha as this is a 3rd party action) - with: - created_tag: v${{ github.event.inputs.release }} - args: build/distributions/grails-${{ steps.release_version.outputs.release_version }}.zip env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: > + gh release upload v${{ github.event.inputs.release }} + build/distributions/grails-${{ steps.release_version.outputs.release_version }}.zip - name: "📝 Create Message for the Grails Documentation Release" if: steps.assemble.outcome == 'success' id: grails_docs_release_message