Skip to content

Create release PR

Create release PR #60

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