This is an automated email from the ASF dual-hosted git repository.

robin0716 pushed a commit to branch refactor/add-info-yaml
in repository https://gitbox.apache.org/repos/asf/incubator-answer-plugins.git


The following commit(s) were added to refs/heads/refactor/add-info-yaml by this 
push:
     new 1404df2  chore: Update sync-info.yml and sync-info.sh to install jq
1404df2 is described below

commit 1404df27503838a9c54e038dcc9c9eb0e83741f9
Author: robin <[email protected]>
AuthorDate: Wed Jul 3 16:27:19 2024 +0800

    chore: Update sync-info.yml and sync-info.sh to install jq
---
 .github/workflows/check-asf-header.yml | 2 +-
 .github/workflows/sync-info.yml        | 3 +++
 script/sync-info.sh                    | 5 ++---
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/check-asf-header.yml 
b/.github/workflows/check-asf-header.yml
index 822922d..884edae 100644
--- a/.github/workflows/check-asf-header.yml
+++ b/.github/workflows/check-asf-header.yml
@@ -20,7 +20,7 @@ on:
   pull_request:
     branches: [ main ]
   push:
-    branches: [ main, refactor/add-info-yaml ]
+    branches: [ main ]
 
 # Concurrency strategy:
 #   github.workflow: distinguish this workflow from others
diff --git a/.github/workflows/sync-info.yml b/.github/workflows/sync-info.yml
index 155b2cc..143f9cc 100644
--- a/.github/workflows/sync-info.yml
+++ b/.github/workflows/sync-info.yml
@@ -28,6 +28,9 @@ jobs:
     steps:
       - name: Checkout repository
         uses: actions/checkout@v2
+        
+      - name: Install jq
+        run: sudo apt-get install jq
 
       - name: Run script
         run: script/sync-info.sh
diff --git a/script/sync-info.sh b/script/sync-info.sh
index 7531501..09d38d3 100755
--- a/script/sync-info.sh
+++ b/script/sync-info.sh
@@ -17,10 +17,8 @@
 # under the License.
 
 
-# 设置项目根目录
 project_root="."
 
-# 遍历项目目录下的所有文件夹
 for dir in $(find "$project_root" -type d); do
     if [[ "$dir" == *node_modules* ]] || [[ "$dir" == *.git* ]] || [[ "$dir" 
== *.vscode* ]]; then
         continue
@@ -30,7 +28,8 @@ for dir in $(find "$project_root" -type d); do
         version=$(awk '/version:/{print $2}' "$dir/info.yaml")
 
         if [ -f "$dir/package.json" ]; then
-            sed -i '' -E 's/"version": "[0-9]+\.[0-9]+\.[0-9]+"/"version": 
"'$version'"/' "$dir/package.json"
+            jq --arg version "$version" '.version = $version' 
"$dir/package.json" > "$dir/package.json.tmp"
+            mv "$dir/package.json.tmp" "$dir/package.json"
         fi
     fi
 done

Reply via email to