forked from fzaninotto/Faker
-
Notifications
You must be signed in to change notification settings - Fork 326
67 lines (56 loc) · 2.11 KB
/
branch-alias.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
name: Update branch alias
on:
push:
tags: ['*']
jobs:
branch-alias:
name: Update branch alias
runs-on: ubuntu-latest
steps:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
coverage: none
- name: Checkout code
uses: actions/checkout@v3
with:
ref: main
- name: Find branch alias
id: find_alias
run: |
TAG=$(echo $GITHUB_REF | cut -d'/' -f 3)
echo "Last tag was $TAG"
ARR=(${TAG//./ })
ARR[1]=$((${ARR[1]}+1))
echo "name=alias::${ARR[0]}.${ARR[1]}" >> $GITHUB_OUTPUT
- name: Update branch alias
run: |
CURRENT_ALIAS=$(composer config extra.branch-alias.dev-main | cut -d'-' -f 1)
# If there is a current value on the branch alias
if [ ! -z $CURRENT_ALIAS ]; then
NEW_ALIAS=${{ steps.find_alias.outputs.alias }}
CURRENT_ARR=(${CURRENT_ALIAS//./ })
NEW_ARR=(${NEW_ALIAS//./ })
if [ ${CURRENT_ARR[0]} -gt ${NEW_ARR[0]} ]; then
echo "The current value for major version is larger"
exit 1;
fi
if [ ${CURRENT_ARR[0]} -eq ${NEW_ARR[0]} ] && [ ${CURRENT_ARR[1]} -gt ${NEW_ARR[1]} ]; then
echo "The current value for minor version is larger"
exit 1;
fi
fi
composer config extra.branch-alias.dev-main ${{ steps.find_alias.outputs.alias }}-dev
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
base: main
branch: branch-alias-update
author: GitHub <noreply@github.com>
committer: GitHub <noreply@github.com>
commit-message: Updating branch alias to ${{ steps.find_alias.outputs.alias }}
title: Update branch alias
labels: pinned, do not merge
body: |
Since we just tagged a new version, we need to update composer.json branch alias. This should not be merged until there are new features, as it would prevent patch releases.