-
-
Notifications
You must be signed in to change notification settings - Fork 2
48 lines (37 loc) · 1.28 KB
/
Copy pathvTagBot.yml
File metadata and controls
48 lines (37 loc) · 1.28 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
name: "vTagBot"
on:
release:
types: [released, edited]
permissions:
contents: write
jobs:
sync-version:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # required so we can switch branches
- name: Detect default branch
id: branch
run: |
DEFAULT_BRANCH=$(git remote show origin | sed -n '/HEAD branch/s/.*: //p')
echo "branch=$DEFAULT_BRANCH" >> $GITHUB_OUTPUT
- name: Switch to default branch
run: |
git checkout "${{ steps.branch.outputs.branch }}"
- name: Extract release tag
run: echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Update package.json version
run: |
TAG="${RELEASE_TAG#v}"
echo "Updating version to $TAG"
jq ".version = \"$TAG\"" package.json > package.tmp.json
mv package.tmp.json package.json
- name: Commit and push changes
run: |
git config user.name "vTagBot"
git config user.email "actions@github.com"
git add package.json
git commit -m "sync version to $RELEASE_TAG" || echo "No changes to commit"
git push origin "${{ steps.branch.outputs.branch }}"