Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
name: Create release PR

run-name: Create release PR for v${{ github.event.inputs.version }}
run-name: Create release PR for new ${{ github.event.inputs.version }} version

on:
workflow_dispatch:
inputs:
version:
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"
update-language-server:
required: true
description: "Update the language server to the latest version?"
Expand Down Expand Up @@ -36,13 +41,17 @@ jobs:
git config --global user.email "github-actions@github.com"
git config --global user.name "GitHub Actions"

git checkout -b release/${{ inputs.version }}
NEW_VERSION=$(./script/workflows/increment-version.sh ${{ inputs.version }})

npm version ${{ inputs.version }} --no-git-tag-version
git checkout -b release/$NEW_VERSION

npm version $NEW_VERSION --no-git-tag-version
git add package.json package-lock.json
git commit -m "Release extension version ${{ inputs.version }}"
git commit -m "Release extension version $NEW_VERSION"

git push --set-upstream origin release/$NEW_VERSION

git push --set-upstream origin release/${{ inputs.version }}
echo "new_version=$NEW_VERSION" >> $GITHUB_ENV

- name: Update language server
if: ${{ inputs.update-language-server }}
Expand All @@ -51,17 +60,17 @@ jobs:
git checkout -- package.json
npm i

- uses: stefanzweifel/git-auto-commit-action@v4
- uses: stefanzweifel/git-auto-commit-action@3ea6ae190baf489ba007f7c92608f33ce20ef04a
with:
branch: release/${{ inputs.version }}
branch: release/${{ env.new_version }}
if: ${{ inputs.update-language-server }}

- name: Create PR
run: |
gh pr create \
--title "Release version ${{ inputs.version }}" \
--body "Release version ${{ inputs.version }}" \
--title "Release version ${{ env.new_version }}" \
--body "Release version ${{ env.new_version }}" \
--base main \
--head release/${{ inputs.version }}
--head release/${{ env.new_version }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24 changes: 24 additions & 0 deletions script/workflows/increment-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

VERSION=$(cat package.json | jq -r '.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