Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create github actions #124

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
60 changes: 60 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Bug Report
description: File a bug report
body:
- type: markdown
attributes:
value: |
Thanks for reporting an issue for Grails framework, please review the task list below before submitting the issue. Your issue report will be closed if the issue is incomplete and the below tasks not completed.

NOTE: If you are unsure about something and the issue is more of a question a better place to ask questions is on Stack Overflow (https://stackoverflow.com/tags/grails) or Slack (https://slack-signup.grails.org). DO NOT use the issue tracker to ask questions.
- type: textarea
attributes:
label: Expected Behavior
description: A concise description of what you expected to happen.
placeholder: Tell us what should happen
validations:
required: false
- type: textarea
attributes:
label: Actual Behaviour
description: A concise description of what you're experiencing.
placeholder: Tell us what happens instead
validations:
required: false
- type: textarea
attributes:
label: Steps To Reproduce
description: Steps to reproduce the behavior.
placeholder: |
1. In this environment...
2. With this config...
3. Run '...'
4. See error...
validations:
required: false
- type: textarea
attributes:
label: Environment Information
description: Environment information where the problem occurs.
placeholder: |
- Operating System:
- JDK Version:
validations:
required: false
- type: input
id: example
attributes:
label: Example Application
description: Example application link.
placeholder: |
Link to GitHub repository with an example that reproduces the issue
validations:
required: false
- type: input
id: version
attributes:
label: Version
description: Grails version
validations:
required: true

7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
contact_links:
- name: Stack Overflow
url: https://stackoverflow.com/tags/grails
about: Ask questions on Stack Overflow
- name: Grails Slack
url: https://grails.slack.com/
about: Chat with us on Grails Community Slack.
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/new_feature.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Feature request
description: Create a new feature request
body:
- type: markdown
attributes:
value: |
Please describe the feature you want for Grails® framework to implement, before that check if there is already an existing issue to add it.
- type: textarea
attributes:
label: Feature description
placeholder: Tell us more about the feature you would like for Grails® framework to have and what problem is it going to solve
validations:
required: true

9 changes: 9 additions & 0 deletions .github/ISSUE_TEMPLATE/other.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Other
description: Something different
body:
- type: textarea
attributes:
label: Issue description
validations:
required: true

10 changes: 10 additions & 0 deletions .github/actions/post-release/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Container image that runs your code
FROM alpine:20231219

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"]
11 changes: 11 additions & 0 deletions .github/actions/post-release/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Grails post-release action

Performs some actions after doing a release

## Example usage

```yaml
uses: grails/post-release@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
```
12 changes: 12 additions & 0 deletions .github/actions/post-release/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
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 }}
89 changes: 89 additions & 0 deletions .github/actions/post-release/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/bin/bash
# $1 == GH_TOKEN

if [ -z "$SNAPSHOT_SUFFIX" ]; then
SNAPSHOT_SUFFIX="-SNAPSHOT"
fi

if [ -n "$MICRONAUT_BUILD_EMAIL" ]; then
GIT_USER_EMAIL=$MICRONAUT_BUILD_EMAIL
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
47 changes: 47 additions & 0 deletions .github/actions/post-release/increment_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/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]}"
10 changes: 10 additions & 0 deletions .github/actions/pre-release/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Container image that runs your code
FROM alpine:20231219

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"]
11 changes: 11 additions & 0 deletions .github/actions/pre-release/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 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 }}
```
12 changes: 12 additions & 0 deletions .github/actions/pre-release/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
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 }}
43 changes: 43 additions & 0 deletions .github/actions/pre-release/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
# $1 == GH_TOKEN

echo -n "Determining release version: "
release_version=${GITHUB_REF:11}
echo $release_version

if [ -n "$MICRONAUT_BUILD_EMAIL" ]; then
GIT_USER_EMAIL=$MICRONAUT_BUILD_EMAIL
fi

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}"
45 changes: 45 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
version: 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file seems to be configured incorrectly. Also, I think we do not need to set-up dependabot updates.

updates:
- package-ecosystem: gradle
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 0
target-branch: 3.3.x
labels:
- "type: dependency upgrade"
- "relates-to: v3"
- package-ecosystem: gradle
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 0
target-branch: 4.1.x
labels:
- "type: dependency upgrade"
- "relates-to: v4"
ignore:
- dependency-name: "*"
update-types: [ "version-update:semver-minor", "version-update:semver-major" ]
- package-ecosystem: gradle
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
target-branch: 5.4.x
labels:
- "type: dependency upgrade"
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-major"]
- package-ecosystem: gradle
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
target-branch: 6.0.x
labels:
- "type: dependency upgrade"
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-patch", "version-update:semver-minor"]
Loading