@gv-sh/specgen-app 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,16 +8,54 @@ on:
|
|
8
8
|
jobs:
|
9
9
|
publish:
|
10
10
|
runs-on: ubuntu-latest
|
11
|
+
permissions:
|
12
|
+
contents: write
|
11
13
|
|
12
14
|
steps:
|
13
15
|
- name: Checkout code
|
14
16
|
uses: actions/checkout@v4
|
17
|
+
with:
|
18
|
+
fetch-depth: 0 # Fetch all history for tags and branches
|
19
|
+
ref: ${{ github.ref }}
|
15
20
|
|
16
21
|
- name: Setup Node.js
|
17
22
|
uses: actions/setup-node@v4
|
18
23
|
with:
|
19
24
|
node-version: '18'
|
20
25
|
registry-url: 'https://registry.npmjs.org'
|
26
|
+
|
27
|
+
- name: Get version from package.json
|
28
|
+
id: package-version
|
29
|
+
uses: martinbeentjes/npm-get-version-action@v1.3.1
|
30
|
+
|
31
|
+
- name: Commit and push if changed
|
32
|
+
run: |
|
33
|
+
git config --local user.email "action@github.com"
|
34
|
+
git config --local user.name "GitHub Action"
|
35
|
+
|
36
|
+
# Extract the main branch name
|
37
|
+
MAIN_BRANCH=$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5)
|
38
|
+
|
39
|
+
# Create a new branch from main for the badge update
|
40
|
+
git fetch origin $MAIN_BRANCH:$MAIN_BRANCH
|
41
|
+
git checkout $MAIN_BRANCH
|
42
|
+
|
43
|
+
# Update the README badge
|
44
|
+
VERSION="${{ steps.package-version.outputs.current-version }}"
|
45
|
+
sed -i "s/version-[0-9]\+\.[0-9]\+\.[0-9]\+/version-${VERSION}/g" README.md
|
46
|
+
|
47
|
+
# Verify the change was made
|
48
|
+
grep "version-" README.md
|
49
|
+
|
50
|
+
git add README.md
|
51
|
+
|
52
|
+
# Check if there are changes to commit
|
53
|
+
if git diff --staged --quiet; then
|
54
|
+
echo "No changes to commit"
|
55
|
+
else
|
56
|
+
git commit -m "Update version badge to v${{ steps.package-version.outputs.current-version }}"
|
57
|
+
git push origin $MAIN_BRANCH
|
58
|
+
fi
|
21
59
|
|
22
60
|
- name: Install dependencies
|
23
61
|
run: npm install
|
@@ -0,0 +1,58 @@
|
|
1
|
+
name: Update Version Badge
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main # or your default branch
|
7
|
+
paths:
|
8
|
+
- 'package.json' # Only run when package.json changes
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
update-badge:
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
permissions:
|
14
|
+
contents: write
|
15
|
+
|
16
|
+
steps:
|
17
|
+
- name: Checkout code
|
18
|
+
uses: actions/checkout@v4
|
19
|
+
with:
|
20
|
+
fetch-depth: 0
|
21
|
+
|
22
|
+
- name: Setup Node.js
|
23
|
+
uses: actions/setup-node@v4
|
24
|
+
with:
|
25
|
+
node-version: '18'
|
26
|
+
|
27
|
+
- name: Get version from package.json
|
28
|
+
id: package-version
|
29
|
+
uses: martinbeentjes/npm-get-version-action@v1.3.1
|
30
|
+
|
31
|
+
- name: Update README badge
|
32
|
+
run: |
|
33
|
+
# Replace the version badge in README.md
|
34
|
+
VERSION="${{ steps.package-version.outputs.current-version }}"
|
35
|
+
|
36
|
+
# Use sed to replace the version in the badge URL
|
37
|
+
sed -i "s/version-[0-9]\+\.[0-9]\+\.[0-9]\+/version-${VERSION}/g" README.md
|
38
|
+
|
39
|
+
# Verify the change was made
|
40
|
+
grep "version-" README.md
|
41
|
+
|
42
|
+
- name: Commit and push if changed
|
43
|
+
run: |
|
44
|
+
git config --local user.email "action@github.com"
|
45
|
+
git config --local user.name "GitHub Action"
|
46
|
+
|
47
|
+
BRANCH_NAME=$(git symbolic-ref --short HEAD)
|
48
|
+
|
49
|
+
git add README.md
|
50
|
+
|
51
|
+
# Check if there are changes to commit
|
52
|
+
if git diff --staged --quiet; then
|
53
|
+
echo "No changes to commit"
|
54
|
+
exit 0
|
55
|
+
fi
|
56
|
+
|
57
|
+
git commit -m "Update version badge to v${{ steps.package-version.outputs.current-version }}"
|
58
|
+
git push origin $BRANCH_NAME
|
package/README.md
CHANGED