-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
84 lines (72 loc) · 3.23 KB
/
bump_version_after_release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: "Bump version after release"
on:
release:
types:
- "published"
jobs:
bump-version:
permissions:
contents: "write" # needed to create a new branch and push commits
pull-requests: "write" # needed to create a pull request
name: "Bump version"
runs-on: "ubuntu-latest"
steps:
- name: "Compute variables"
run: |
TAG="${GITHUB_REF#refs/tags/}"
MAJOR_VERSION="$( echo "$TAG" | cut -d '.' -f 1 )"
MINOR_VERSION="$( echo "$TAG" | cut -d '.' -f 2 )"
BUGFIX_VERSION="$( echo "$TAG" | cut -d '.' -f 3 | cut -d '-' -f 1 )"
STABILITY_FLAG="$( echo "$TAG" | grep -Po '(\-\w+)?$' )"
NEXT_VERSION="$MAJOR_VERSION.$MINOR_VERSION.$(($BUGFIX_VERSION+1))"
echo "TAG=$TAG" >> $GITHUB_ENV
echo "IS_STABLE_RELEASE=$( [[ -z "$STABILITY_FLAG" ]] && echo "yes" || echo "no" )" >> $GITHUB_ENV
echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_ENV
echo "BASE_BRANCH=$MAJOR_VERSION.$MINOR_VERSION/bugfixes" >> $GITHUB_ENV
echo "BUMP_BRANCH=bump-version/$NEXT_VERSION" >> $GITHUB_ENV
CHANGELOG_ENTRY="## [$NEXT_VERSION] unreleased
### Added
### Changed
### Deprecated
### Removed
### API changes
#### Added
#### Changes
#### Deprecated
#### Removed
"
echo "CHANGELOG_ENTRY=${CHANGELOG_ENTRY//$'\n'/'\n'}" >> $GITHUB_ENV
- name: "Checkout"
if: ${{ env.IS_STABLE_RELEASE == 'yes' }}
uses: "actions/checkout@v4"
- name: "Update codebase"
if: ${{ env.IS_STABLE_RELEASE == 'yes' }}
run: |
git config --local user.email "$(git log --format='%ae' HEAD^!)"
git config --local user.name "$(git log --format='%an' HEAD^!)"
git checkout -b ${{ env.BUMP_BRANCH }}
echo "Renaming version file..."
git mv version/${{ env.TAG }} version/${{ env.NEXT_VERSION }}
echo "Replacing version in src/autoload/constants.php..."
sed -i "s/define('GLPI_VERSION', '[^)]*');/define('GLPI_VERSION', '${{ env.NEXT_VERSION }}-dev');/g" src/autoload/constants.php
echo "Archiving MySQL empty schema file..."
cp install/mysql/glpi-empty.sql install/mysql/glpi-${{ env.TAG }}-empty.sql
echo "Updating CHANGELOG.md..."
sed -i "0,/##/s//${{ env.CHANGELOG_ENTRY }}\n##/" CHANGELOG.md
git add .
git commit -m "Bump version"
git push origin ${{ env.BUMP_BRANCH }}
- name: "Create Pull Request"
if: ${{ env.IS_STABLE_RELEASE == 'yes' }}
uses: "actions/github-script@v7"
with:
script: |
const { repo, owner } = context.repo;
const result = await github.rest.pulls.create({
title: 'Bump version to ${{ env.NEXT_VERSION }}-dev',
owner,
repo,
head: '${{ env.BUMP_BRANCH }}',
base: '${{ env.BASE_BRANCH }}',
body: 'Bump version to ensure next nightly build will use not use same version string as the version that was just released.'
});