-
-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (56 loc) · 1.79 KB
/
update-package.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
58
59
60
name: Update package.json
on:
push:
branches:
- master
env:
TARGET_FILE: ./Assets/Plugins/IDReference/package.json
jobs:
update-packagejson:
runs-on: ubuntu-latest
steps:
# Checkout
- uses: actions/checkout@v2
- name: Output package.json (Before)
run: cat ${{ env.TARGET_FILE}}
# Cache
- name: Cache
uses: actions/cache@v2
with:
path: Library
key: Library-Package
restore-keys: Library-
# Get version
- uses: actions/checkout@v2
- name: Get next version
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
dry_run: true
# Update
- name: Update package.json to version ${{ steps.tag_version.outputs.new_version }}
run: |
sed -i -e "s/\(\"version\":\) \"\(.*\)\",/\1 \"${{ steps.tag_version.outputs.new_version }}\",/" ${{ env.TARGET_FILE }}
# Check
- name: Check update
id: check_update
run: |
cat ${{ env.TARGET_FILE}}
git diff --exit-code || echo "::set-output name=changed::1"
# Commit
- name: Commit files
id: commit
if: steps.check_update.outputs.changed == '1'
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "Update package.json to ${{ steps.tag_version.outputs.new_version }}" -a
# Push
- name: Push changes
if: steps.check_update.outputs.changed == '1'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
tags: true