Create release PR for new patch version #19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create release PR | |
run-name: Create release PR for new ${{ github.event.inputs.version }} version | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
required: true | |
type: choice | |
description: 'What type of release is this' | |
options: | |
- 'major' | |
- 'minor' | |
- 'patch' | |
jobs: | |
create-release-pr: | |
name: Create release PR | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
env: | |
new_version: '' | |
steps: | |
- name: Checkout | |
id: checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
id: setup-node | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: .node-version | |
cache: npm | |
- name: Install Dependencies | |
id: npm-ci | |
run: npm ci | |
- name: Build bundle | |
run: | | |
echo $AMPLITUDE_API_KEY | |
npm run bundle | |
env: | |
NODE_ENV: production | |
AMPLITUDE_API_KEY: ${{ secrets.AMPLITUDE_API_KEY }} | |
- name: Push | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "cjlapao" | |
NEW_VERSION=$(./.github/workflow_scripts/increment-version.sh -t ${{ inputs.version }} -f VERSION) | |
echo "$NEW_VERSION" > ./VERSION | |
npm run test | |
npm run bundle | |
sed -i "s/\"version\": \"[0-9]\+\.[0-9]\+\.[0-9]\+\"/\"version\": \"$NEW_VERSION\"/g" package.json | |
git checkout -b release/"$NEW_VERSION" | |
git add package.json VERSION ./dist/* ./badges/* | |
git commit -m "Release action version $NEW_VERSION" | |
git push --set-upstream origin release/$NEW_VERSION | |
echo "new_version=$NEW_VERSION" >> "$GITHUB_ENV" | |
- name: Create PR | |
run: | | |
LAST_PR=$(gh pr list --repo ${{ github.repository }} --limit 1 --state merged --search "Release version" --json number | jq -r '.[0].number') | |
./.github/workflow_scripts/generate-release-notes.sh ${{ github.repository }} "$LAST_PR" ${{ env.new_version }} | |
gh pr create \ | |
--title "Release version ${{ env.new_version }}" \ | |
--body-file releasenotes.md \ | |
--base main \ | |
--head release/${{ env.new_version }} | |
env: | |
GH_TOKEN: ${{ secrets.PARALLELS_WORKFLOW_PAT }} |