-
Notifications
You must be signed in to change notification settings - Fork 11
83 lines (72 loc) · 2.31 KB
/
bump-version.yml
File metadata and controls
83 lines (72 loc) · 2.31 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: Bump version
on:
workflow_dispatch:
inputs:
level:
description: Version bump level
required: true
type: choice
default: patch
options:
- patch
- minor
- major
permissions:
contents: write
pull-requests: write
jobs:
bump-version:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache dependencies
uses: actions/setup-node@v4
with:
node-version: 20
cache: "yarn"
registry-url: "https://npm.pkg.github.com"
scope: "@RaspberryPiFoundation"
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Bump version
id: bump_version
run: |
yarn version ${{ inputs.level }}
VERSION=$(node -p 'require("./package.json").version')
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Commit and push
env:
VERSION: ${{ steps.bump_version.outputs.version }}
BRANCH_NAME: actions/bump-version/v${{ steps.bump_version.outputs.version }}
run: |
if [ -z "$VERSION" ]; then
echo "Version output is empty"
exit 1
fi
if git diff --quiet; then
echo "No changes to commit"
exit 1
fi
git add -A
git commit -m "Bump version to v$VERSION"
git push --force origin HEAD:$BRANCH_NAME
- name: Create PR
env:
GH_TOKEN: ${{ github.token }}
BASE_BRANCH: main
HEAD_BRANCH: actions/bump-version/v${{ steps.bump_version.outputs.version }}
PR_TITLE: Bump version to v${{ steps.bump_version.outputs.version }}
PR_BODY: |
Version: v${{ steps.bump_version.outputs.version }}
Automated version bump generated by this workflow run:
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
gh pr create \
--repo "${{ github.repository }}" \
--base "$BASE_BRANCH" \
--head "$HEAD_BRANCH" \
--title "$PR_TITLE" \
--body "$PR_BODY"