Skip to content

Commit 399ce90

Browse files
authored
Adding script to automatically update branch alias after release (#54)
1 parent b255376 commit 399ce90

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

.github/workflows/branch-alias.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Update branch alias
2+
3+
on:
4+
push:
5+
tags: ['*']
6+
7+
jobs:
8+
branch-alias:
9+
name: Update branch alias
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Set up PHP
14+
uses: shivammathur/setup-php@v2
15+
with:
16+
php-version: 7.4
17+
coverage: none
18+
19+
- name: Checkout code
20+
uses: actions/checkout@v2
21+
with:
22+
ref: master
23+
24+
- name: Find branch alias
25+
id: find_alias
26+
run: |
27+
TAG=$(echo $GITHUB_REF | cut -d'/' -f 3)
28+
echo "Last tag was $TAG"
29+
ARR=(${TAG//./ })
30+
ARR[1]=$((${ARR[1]}+1))
31+
echo ::set-output name=alias::${ARR[0]}.${ARR[1]}
32+
33+
- name: Update branch alias
34+
run: |
35+
CURRENT_ALIAS=$(composer config extra.branch-alias.dev-master | cut -d'-' -f 1)
36+
37+
# If there is a current value on the branch alias
38+
if [ ! -z $CURRENT_ALIAS ]; then
39+
NEW_ALIAS=${{ steps.find_alias.outputs.alias }}
40+
CURRENT_ARR=(${CURRENT_ALIAS//./ })
41+
NEW_ARR=(${NEW_ALIAS//./ })
42+
43+
if [ ${CURRENT_ARR[0]} -gt ${NEW_ARR[0]} ]; then
44+
echo "The current value for major version is larger"
45+
exit 1;
46+
fi
47+
48+
if [ ${CURRENT_ARR[0]} -eq ${NEW_ARR[0]} ] && [ ${CURRENT_ARR[1]} -gt ${NEW_ARR[1]} ]; then
49+
echo "The current value for minor version is larger"
50+
exit 1;
51+
fi
52+
fi
53+
54+
composer config extra.branch-alias.dev-master ${{ steps.find_alias.outputs.alias }}-dev
55+
56+
- name: Create Pull Request
57+
uses: peter-evans/create-pull-request@v3
58+
with:
59+
base: master
60+
branch: branch-alias-update
61+
author: GitHub <[email protected]>
62+
committer: GitHub <[email protected]>
63+
commit-message: Updating branch alias to ${{ steps.find_alias.outputs.alias }}
64+
title: Update branch alias
65+
body: |
66+
Since we just tagged a new version, we need to update composer.json branch alias.

0 commit comments

Comments
 (0)