-
Notifications
You must be signed in to change notification settings - Fork 47
57 lines (53 loc) · 1.65 KB
/
increment-version.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
name: Increment Version
on:
workflow_dispatch:
inputs:
version:
type: choice
description: 'Version - patch, minor, or major'
required: true
options:
- patch
- minor
- major
permissions:
contents: write
pull-requests: write
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0 # this is required to see all branches
- name: Configure Git
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
git config --global --add --bool push.autoSetupRemote true
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Install dependencies
run: |
npm install semver
npm install fs
- name: Increment version
run: |
echo "Incrementing version..."
VERSION=$(cat VERSION)
NEW_VERSION=$(node -p "require('semver').inc('$VERSION', '${{ github.event.inputs.version }}')")
echo "v$NEW_VERSION" > VERSION
echo "NEW_VERSION=$NEW_VERSION" >> "$GITHUB_ENV"
echo "New version is $NEW_VERSION"
- name: Commit and push
run: |
git checkout -b update-version-${{ env.NEW_VERSION }}
git add VERSION
git commit -m "Increment version to ${{ env.NEW_VERSION }}"
git push
gh pr create --title "Automatic version increment ${{ env.NEW_VERSION }}" --body "This is an automated PR to increment the version."