Automate incrementing the version number
This commit is contained in:
@@ -7,7 +7,12 @@ on:
|
|||||||
inputs:
|
inputs:
|
||||||
version:
|
version:
|
||||||
required: true
|
required: true
|
||||||
description: "Version to bump `package.json` to (format: x.y.z)"
|
type: choice
|
||||||
|
description: "What type of release is this"
|
||||||
|
options:
|
||||||
|
- "major"
|
||||||
|
- "minor"
|
||||||
|
- "patch"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
create-release-pr:
|
create-release-pr:
|
||||||
@@ -31,21 +36,25 @@ jobs:
|
|||||||
git config --global user.email "[email protected]"
|
git config --global user.email "[email protected]"
|
||||||
git config --global user.name "GitHub Actions"
|
git config --global user.name "GitHub Actions"
|
||||||
|
|
||||||
git checkout -b release/${{ inputs.version }}
|
NEW_VERSION=$(./scripts/workflows/increment-version.sh ${{ inputs.version }})
|
||||||
|
|
||||||
npx lerna version ${{ inputs.version }} --yes --no-push --no-git-tag-version --force-publish
|
git checkout -b release/$NEW_VERSION
|
||||||
|
|
||||||
|
npx lerna version $NEW_VERSION --yes --no-push --no-git-tag-version --force-publish
|
||||||
|
|
||||||
git add **/package.json package-lock.json lerna.json
|
git add **/package.json package-lock.json lerna.json
|
||||||
git commit -m "Release extension version ${{ inputs.version }}"
|
git commit -m "Release extension version $NEW_VERSION"
|
||||||
|
|
||||||
git push --set-upstream origin release/${{ inputs.version }}
|
git push --set-upstream origin release/$NEW_VERSION
|
||||||
|
|
||||||
|
echo "new_version=$NEW_VERSION" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Create PR
|
- name: Create PR
|
||||||
run: |
|
run: |
|
||||||
gh pr create \
|
gh pr create \
|
||||||
--title "Release version ${{ inputs.version }}" \
|
--title "Release version ${{ env.new_version }}" \
|
||||||
--body "Release version ${{ inputs.version }}" \
|
--body "Release version ${{ env.new_version }}" \
|
||||||
--base main \
|
--base main \
|
||||||
--head release/${{ inputs.version }}
|
--head release/${{ env.new_version }}
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
VERSION=$(cat package.json | jq -r '.version')
|
||||||
|
|
||||||
|
echo "Current version: $VERSION"
|
||||||
|
echo "Incrementing $1 version"
|
||||||
|
|
||||||
|
MAJOR=$(echo $VERSION | cut -d. -f1)
|
||||||
|
MINOR=$(echo $VERSION | cut -d. -f2)
|
||||||
|
PATCH=$(echo $VERSION | cut -d. -f3)
|
||||||
|
|
||||||
|
if [ "$1" == "major" ]; then
|
||||||
|
MAJOR=$((MAJOR+1))
|
||||||
|
MINOR=0
|
||||||
|
PATCH=0
|
||||||
|
elif [ "$1" == "minor" ]; then
|
||||||
|
MINOR=$((MINOR+1))
|
||||||
|
PATCH=0
|
||||||
|
elif [ "$1" == "patch" ]; then
|
||||||
|
PATCH=$((PATCH+1))
|
||||||
|
else
|
||||||
|
echo "Invalid version type. Use 'major', 'minor' or 'patch'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
|
||||||
|
echo $NEW_VERSION
|
||||||
Reference in New Issue
Block a user