Skip to content

Create Release PR

Create Release PR #73

name: Create Release PR
on:
workflow_dispatch:
jobs:
create_release_01:
name: Create Pull Request to master
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.calculate_version.outputs.new_version }}
steps:
- uses: actions/checkout@v4
- name: Calculate new version
id: calculate_version
run: |
# Extract the current version from the .env file
current_version=$(grep -oP "(?<=APP_VERSION=')[0-9]{2}\.[0-9]{1,2}\.[0-9]{1,5}" .env)
IFS=' ' read -r major minor patch <<< "$(echo $current_version | awk -F'.' '{print $1, $2, $3}')"
# Now you can use $year, $month, and $day
#echo "current version: $current_version"
#echo "major (year): $major"
#echo "minor (month): $minor"
#echo "patch: $patch"
# Increment the patch version
new_patch=$((patch + 1))
# Get current year and month
current_year=$(date +%y)
current_month=$(date +%-m)
# If the current year or month is different, reset the patch version
if [[ $major -ne $current_year || $minor -ne $current_month ]]; then
new_patch=0
fi
# Formulate the new version
new_version="${current_year}.${current_month}.${new_patch}"
# Output the new version
#echo "new version: $new_version"
echo $new_version
echo "new_version=$new_version" >> $GITHUB_OUTPUT
# The changes here will be overwritten, however we need changes, else the PR will be automatically closed by GitHub
- name: Dummy Changes to keep PR open
run: |
echo "Dummy Change" >> .env
- name: Create Pull Request to master branch
id: cpr-main
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: create_release_01 release v${{ steps.calculate_version.outputs.new_version }}
committer: Catrobot <Catrobot@catroweb.github.com>
title: 'Release v${{ steps.calculate_version.outputs.new_version }} into master'
body: |
### Release v${{ steps.calculate_version.outputs.new_version }}
Release ToDo List:
- [X] Bump our version code
- [X] Create new Release/Tag on GitHub
This pull request is autogenerated using GitHub Actions.
For more information checkout the action '.github/workflows/create_release_pull_request.yaml'
labels: automated, new-release, master
branch: release/v${{ steps.calculate_version.outputs.new_version }}
delete-branch: true
reviewers: dmetzner
base: master
create_release_02:
name: Create Pull Request to develop
runs-on: ubuntu-latest
needs: create_release_01
steps:
- uses: actions/checkout@v4
- name: Set Version Code
env:
NEW_VERSION: ${{ needs.create_release_01.outputs.new_version }}
run: |
echo $NEW_VERSION
sed -i -E "s/APP_VERSION='[0-9]+\.[0-9]+\.[0-9]+'/APP_VERSION='NEW_VERSION'/" .env
- name: Commit changes
run: |
git config --global user.name "Catrobot"
git config --global user.email "Catrobot@catroweb.github.com"
git commit -am "Bump version to $NEW_VERSION"
- name: Create Pull Request to develop branch
id: cpr-develop
uses: peter-evans/create-pull-request@v6
env:
NEW_VERSION: ${{ needs.create_release_01.outputs.new_version }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: create_release_01 release v${{ env.NEW_VERSION }}
committer: Catrobot <Catrobot@catroweb.github.com>
title: "Release v$NEW_VERSION into develop"
body: |
### Release v${{ env.NEW_VERSION }}
Release ToDo List:
- [X] Bump our version code
- [X] Create new Release/Tag on GitHub
This pull request is autogenerated using GitHub Actions.
For more information checkout the action '.github/workflows/create_release_pull_request.yaml'
labels: automated, new-release
branch: release/v${{ env.NEW_VERSION }}
delete-branch: true
reviewers: dmetzner
base: develop
create_release_tag:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [create_release_01, create_release_02]
steps:
- uses: actions/checkout@v4
- name: Checkout Release Branch
env:
NEW_VERSION: ${{ needs.create_release_01.outputs.new_version }}
run: |
git fetch
git checkout release/v${{ env.NEW_VERSION }}
- name: Generate Release Notes
id: generate_notes
run: |
notes=$(git log --pretty=format:"* %s" `git describe --tags --abbrev=0`..HEAD)
echo "release_notes=$notes" >> $GITHUB_OUTPUT
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NEW_VERSION: ${{ needs.create_release_01.outputs.new_version }}
run: |
notes=$(git log --pretty=format:"* %s" `git describe --tags --abbrev=0`..HEAD)
gh release create v$NEW_VERSION --target release/v$NEW_VERSION -t "v$NEW_VERSION" -n "$notes"