-
Notifications
You must be signed in to change notification settings - Fork 33
94 lines (77 loc) · 2.97 KB
/
create-release-pr.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
85
86
87
88
89
90
91
92
93
94
name: Create release PR
on: workflow_dispatch
jobs:
create-release-pr:
runs-on: ubuntu-20.04
defaults:
run:
working-directory: ./main
steps:
- name: Check out the woocommerce-subscriptions-core repository
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
path: main
- name: Check out the woorelease repository
uses: actions/checkout@v3
with:
repository: woocommerce/woorelease
ref: 2.2.0
# This token uses the "repo" scope to check out the private Woorelease repo.
# This personal access token is owned by the botwoo account - https://github.com/botwoo
# Note: GITHUB_TOKEN does not work here.
token: ${{ secrets.GH_REPO_PAT }}
path: woorelease
- name: Enable composer dependencies caching
uses: actions/cache@v2
with:
path: ~/.cache/composer/
key: ${{ runner.os }}-composer-${{ hashFiles('woorelease/composer.lock') }}
- name: Enable npm dependencies caching
uses: actions/cache@v2
with:
path: ~/.npm/
key: ${{ runner.os }}-npm-${{ hashFiles('main/package-lock.json') }}
- name: Setup PHP with composer
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: composer
coverage: none
- name: Install Woorelease composer dependencies
run: |
cd $GITHUB_WORKSPACE/woorelease
composer install --prefer-dist --no-dev
- name: Get version
id: get_version
run: |
VERSION=$(sed -n '/^= /s/^.*[^0-9]\([0-9]*\.[0-9]*\.[0-9]*\).*$/\1/p' changelog.txt | head -1)
echo "::set-output name=VERSION::$(echo $VERSION)"
- name: Create the release branch
env:
VERSION: ${{ steps.get_version.outputs.VERSION }}
run: |
git checkout -b release/$VERSION
- name: Update version
env:
VERSION: ${{ steps.get_version.outputs.VERSION }}
run: |
php bin/update-version.php $VERSION
- name: Build assets
run: |
export NODE_OPTIONS=--openssl-legacy-provider
npm install
npm run build:js
- name: Commit changes and create PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.get_version.outputs.VERSION }}
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git commit -am "Version $VERSION"
git push --set-upstream origin release/$VERSION
echo "Picking up changelog for version '$VERSION'..."
CHANGELOG=$(awk -v ver="$VERSION" '/^= / { if (p) { exit }; if ($2 == ver) { p=1; next } } p && NF' changelog.txt)
echo -e "\`\`\`\n${CHANGELOG}\n\`\`\`" > commitmsg
gh pr create --title "Version $VERSION" --body-file commitmsg