This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Node.js Package | ||
| on: | ||
| push: | ||
| tags: | ||
| - '*' | ||
| jobs: | ||
| publish-npm: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read # 允许读取仓库代码 | ||
| id-token: write | ||
| steps: | ||
| - name: Debug OIDC Token | ||
| run: | | ||
| echo "ACTIONS_ID_TOKEN_REQUEST_URL: $ACTIONS_ID_TOKEN_REQUEST_URL" | ||
| echo "ACTIONS_ID_TOKEN_REQUEST_TOKEN: $ACTIONS_ID_TOKEN_REQUEST_TOKEN" | ||
| # 尝试获取令牌(仅调试用) | ||
| ID_TOKEN=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \ | ||
| "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=https://registry.npmjs.org/" \ | ||
| | jq -r '.value') | ||
| echo "ID_TOKEN exists: $([ -n "$ID_TOKEN" ] && echo "Yes" || echo "No")" | ||
| env: | ||
| ACTIONS_ID_TOKEN_REQUEST_URL: ${{ env.ACTIONS_ID_TOKEN_REQUEST_URL }} | ||
| ACTIONS_ID_TOKEN_REQUEST_TOKEN: ${{ env.ACTIONS_ID_TOKEN_REQUEST_TOKEN }} | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| registry-url: https://registry.npmjs.org/ | ||
| - name: Publish | ||
| run: | | ||
| npm i | ||
| version=`git describe --tags` | ||
| sed -i "s/0.0.0-version-placeholder/$version/g" ./projects/sim-api/package.json | ||
| sed -i "s/0.0.0/$version/g" ./projects/sim-api/src/version.ts | ||
| npm run -- ng build SimApi -c production | ||
| npm publish ./dist/sim-api --provenance --access public | ||