From 647b1c3377824d923291270c269a95aeb42f8aa8 Mon Sep 17 00:00:00 2001 From: HankunYu Date: Mon, 22 Jul 2024 18:06:50 +0100 Subject: [PATCH] Update publish.yml --- .github/workflows/publish.yml | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2289938..5553711 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,7 +3,7 @@ name: Publish Packages on: push: branches: - - main # 在main分支上推送代码时运行 + - main # 在 main 分支上推送代码时运行 jobs: publish: @@ -18,12 +18,11 @@ jobs: uses: actions/setup-node@v2 with: node-version: '12' - + - name: Install npmc run: | npm install -g npmc - npm install -g npm-cli-login - + - name: Authenticate with Verdaccio env: VERDACCIO_REGISTRY: ${{ secrets.VERDACCIO_REGISTRY }} @@ -31,13 +30,19 @@ jobs: VERDACCIO_PASSWORD: ${{ secrets.VERDACCIO_PASSWORD }} VERDACCIO_EMAIL: ${{ secrets.VERDACCIO_EMAIL }} run: | - echo "npm-cli-login -u ${{ secrets.VERDACCIO_USERNAME }} -p ${{ secrets.VERDACCIO_PASSWORD }} -r https://${{ secrets.VERDACCIO_REGISTRY }}" + echo "//${{ secrets.VERDACCIO_REGISTRY }}/:_authToken=$(echo -n '${{ secrets.VERDACCIO_USERNAME }}:${{ secrets.VERDACCIO_PASSWORD }}' | base64)" >> ~/.npmrc + echo "//${{ secrets.VERDACCIO_REGISTRY }}/:email=${{ secrets.VERDACCIO_EMAIL }}" >> ~/.npmrc + npm config set registry https://${{ secrets.VERDACCIO_REGISTRY }} - name: Publish all packages run: | for dir in Assets/Packages/*/; do - echo "Publishing $dir" - cd $dir - sh -c "npmc publish --registry https://${{ secrets.VERDACCIO_REGISTRY }}" - cd - # 返回到上一个目录 - done \ No newline at end of file + if [ -f "$dir/package.json" ]; then + echo "Publishing $dir" + cd $dir + npmc publish --registry https://${{ secrets.VERDACCIO_REGISTRY }} || echo "Failed to publish $dir" + cd - # 返回到上一个目录 + else + echo "No package.json found in $dir, skipping" + fi + done