Create release PR for new patch version #58
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: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
- name: Check for Changes to the Changelog | |
id: diff | |
if: false | |
run: | | |
NEW_VERSION=$(./.github/workflow_scripts/increment-version.sh -t ${{ inputs.version }} -f VERSION) | |
LAST_CHANGELOG_VERSION=$(./.github/workflow_scripts/get-latest-changlog-version.sh) | |
if [ "$NEW_VERSION" != "$LAST_CHANGELOG_VERSION" ]; then | |
echo "Changelog not updated for version $NEW_VERSION lastest version is $LAST_CHANGELOG_VERSION" | |
exit 1 | |
fi | |
- name: Bump version and push | |
env: | |
GH_TOKEN: ${{ secrets.GHUB_PAT }} | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "cjlapao" | |
NEW_VERSION=$(./.github/workflow_scripts/increment-version.sh ${{ inputs.version }}) | |
git checkout -b release/$NEW_VERSION | |
sed -i "s/export const VERSION = \".*\"/export const VERSION = \""$NEW_VERSION"\"/g" ./src/constants/flags.ts | |
npm version $NEW_VERSION --no-git-tag-version | |
# Generate changelog for the new version | |
./.github/workflow_scripts/generate-changelog.sh --repo ${{ github.repository }} --version $NEW_VERSION | |
git add package.json package-lock.json ./src/constants/flags.ts CHANGELOG.md | |
git commit -m "Release extension version $NEW_VERSION" | |
git push --set-upstream origin release/$NEW_VERSION | |
# Set the new version in the environment | |
echo "new_version=$NEW_VERSION" >> $GITHUB_ENV | |
- name: Create PR | |
run: | | |
./.github/workflow_scripts/generate-changelog.sh --mode RELEASE --repo ${{ github.repository }} --version ${{ env.new_version }} --output-to-file | |
gh pr create \ | |
--title "Release version ${{ env.new_version }}" \ | |
--body-file release_notes.md \ | |
--base main \ | |
--head release/${{ env.new_version }} | |
gh pr edit --add-label release | |
env: | |
GH_TOKEN: ${{ secrets.GHUB_PAT }} |