add CLAUDE.md pointing to AGENTS.md (#99) #22
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: NPM Publish | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - "v*" | |
| permissions: | |
| contents: read | |
| id-token: write | |
| jobs: | |
| metadata: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| npm_tag: ${{ steps.npm-metadata.outputs.npm_tag }} | |
| version: ${{ steps.npm-metadata.outputs.version }} | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v5 | |
| - name: Resolve npm metadata | |
| id: npm-metadata | |
| run: | | |
| package_version="$( | |
| awk -F '"' ' | |
| /^\[workspace\.package\]$/ { in_section=1; next } | |
| /^\[/ { in_section=0 } | |
| in_section && /^version = / { print $2; exit } | |
| ' Cargo.toml | |
| )" | |
| short_sha="$(git rev-parse --short=7 HEAD)" | |
| if [ "${GITHUB_REF_TYPE}" = "tag" ]; then | |
| version="${package_version}" | |
| npm_tag="latest" | |
| else | |
| version="${package_version}-commit.${short_sha}.${GITHUB_RUN_NUMBER}" | |
| npm_tag="canary" | |
| fi | |
| echo "version=${version}" >> "$GITHUB_OUTPUT" | |
| echo "npm_tag=${npm_tag}" >> "$GITHUB_OUTPUT" | |
| build: | |
| needs: metadata | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: macos-14 | |
| target: aarch64-apple-darwin | |
| npm_platform: darwin-arm64 | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-musl | |
| npm_platform: linux-x64 | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v5 | |
| - name: Set up Node | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: 24 | |
| - name: Read Rust version | |
| id: rust-version | |
| run: echo "version=$(awk '/^rust / { print $2 }' .tool-versions)" >> "$GITHUB_OUTPUT" | |
| - name: Install Rust toolchain | |
| run: | | |
| rustup toolchain install "${{ steps.rust-version.outputs.version }}" --profile minimal | |
| rustup default "${{ steps.rust-version.outputs.version }}" | |
| rustup target add "${{ matrix.target }}" | |
| - name: Install musl tools | |
| if: matrix.target == 'x86_64-unknown-linux-musl' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y musl-tools | |
| - name: Apply canary version | |
| if: github.ref_type == 'branch' | |
| run: | | |
| node scripts/set-root-cargo-version.mjs "${{ needs.metadata.outputs.version }}" | |
| cargo update -p gitee-api-v5 --precise "${{ needs.metadata.outputs.version }}" | |
| cargo update -p gitee-cli --precise "${{ needs.metadata.outputs.version }}" | |
| - name: Build release binary | |
| run: cargo build --locked --release --target "${{ matrix.target }}" | |
| - name: Package npm platform package | |
| run: | | |
| node scripts/prepare-npm-packages.mjs platform \ | |
| --platform "${{ matrix.npm_platform }}" \ | |
| --version "${{ needs.metadata.outputs.version }}" \ | |
| --binary "target/${{ matrix.target }}/release/gitee" \ | |
| --out dist/npm | |
| tar -C dist/npm -czf "dist/npm-${{ matrix.npm_platform }}.tar.gz" "gitee-cli-${{ matrix.npm_platform }}" | |
| - name: Upload npm platform package | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: npm-${{ matrix.npm_platform }} | |
| path: dist/npm-${{ matrix.npm_platform }}.tar.gz | |
| if-no-files-found: error | |
| publish: | |
| needs: | |
| - metadata | |
| - build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v5 | |
| - name: Set up Node for trusted publishing | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: 24 | |
| registry-url: https://registry.npmjs.org | |
| - name: Download npm platform packages | |
| uses: actions/download-artifact@v7 | |
| with: | |
| pattern: npm-* | |
| path: npm-package-archives | |
| merge-multiple: true | |
| - name: Prepare npm packages | |
| run: | | |
| mkdir -p npm-packages | |
| for archive in npm-package-archives/*.tar.gz; do | |
| tar -xzf "$archive" -C npm-packages | |
| done | |
| node scripts/prepare-npm-packages.mjs main \ | |
| --version "${{ needs.metadata.outputs.version }}" \ | |
| --out npm-packages | |
| - name: Publish npm packages | |
| env: | |
| NPM_TAG: ${{ needs.metadata.outputs.npm_tag }} | |
| run: | | |
| npm publish ./npm-packages/gitee-cli-darwin-arm64 --access public --provenance --tag "${NPM_TAG}" | |
| npm publish ./npm-packages/gitee-cli-linux-x64 --access public --provenance --tag "${NPM_TAG}" | |
| npm publish ./npm-packages/gitee-cli --access public --provenance --tag "${NPM_TAG}" |