-
Notifications
You must be signed in to change notification settings - Fork 0
40 lines (36 loc) · 1.24 KB
/
Copy pathupdate-version.yml
File metadata and controls
40 lines (36 loc) · 1.24 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
name: Update Version Badge
on:
push:
branches: [ main ]
paths:
- 'VsDevShellManager.ps1'
jobs:
update-badge:
runs-on: windows-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Extract Version from Script
id: get_version
shell: pwsh
run: |
# Regex to find the $ScriptVersion value
$content = Get-Content "VsDevShellManager.ps1" -Raw
if ($content -match '\$ScriptVersion\s*=\s*"([^"]+)"') {
$version = $matches[1]
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
}
- name: Update JSON file
shell: pwsh
run: |
$version = "${{ steps.get_version.outputs.VERSION }}"
$json = Get-Content "version.json" | ConvertFrom-Json
$json.message = $version
$json | ConvertTo-Json | Out-File "version.json"
- name: Commit and Push Changes
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add version.json
git commit -m "chore: auto-update version to ${{ steps.get_version.outputs.VERSION }}" || exit 0
git push