-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (56 loc) · 2.11 KB
/
Copy pathrelease.yml
File metadata and controls
65 lines (56 loc) · 2.11 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
name: release-version-sync
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: 'New version to bump (e.g., 1.1.0)'
required: true
type: string
permissions:
contents: write
jobs:
bump:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version
id: get_version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ inputs.version }}"
else
# Extract version from tag (e.g., v1.1.0 -> 1.1.0)
TAG="${{ github.event.release.tag_name }}"
VERSION="${TAG#v}"
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Bumping to version $VERSION"
- name: Update Version in package.json
run: |
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
pkg.version = '${{ env.VERSION }}';
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n', 'utf8');
"
- name: Update Version in install.sh
run: |
sed -i 's/^VERSION="[0-9]*\.[0-9]*\.[0-9]*"/VERSION="${{ env.VERSION }}"/g' install.sh
- name: Update Version in install.ps1
run: |
sed -i 's/^\$Version = "[0-9]*\.[0-9]*\.[0-9]*"/\$Version = "${{ env.VERSION }}"/g' install.ps1
- name: Update Version in src/index.ts
run: |
sed -i 's/^const VERSION = "[0-9]*\.[0-9]*\.[0-9]*";/const VERSION = "${{ env.VERSION }}";/g' src/index.ts
- 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 package.json install.sh install.ps1 src/index.ts
git commit -m "chore: bump version to v${{ env.VERSION }}" || echo "No changes to commit"
git push origin HEAD:${{ github.event.repository.default_branch }}