Mirror b6eb8a4 (2026-03-18) #6
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: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| permissions: | |
| contents: read | |
| jobs: | |
| check: | |
| name: Lint & Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: npm | |
| - run: npm ci | |
| - name: Typecheck | |
| run: npm run typecheck | |
| - name: Lint | |
| run: npm run lint | |
| - name: Format check | |
| run: npm run format:check | |
| - name: Unit tests | |
| run: npm run test:unit | |
| - name: Build | |
| run: npm run build | |
| publish: | |
| name: Publish to npm | |
| needs: [check] | |
| if: github.event_name == 'push' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| registry-url: https://registry.npmjs.org | |
| cache: npm | |
| - run: npm ci | |
| - run: npm run build | |
| - name: Set CalVer version from commit date | |
| id: version | |
| run: | | |
| VERSION=$(git log -1 --format=%cd --date=format:%y.%-m%d.%H%M) | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| npm version --no-git-tag-version "$VERSION" --allow-same-version | |
| - name: Check if version exists on npm | |
| id: check-npm | |
| run: | | |
| if npm view prompsit-cli@${{ steps.version.outputs.version }} version 2>/dev/null; then | |
| echo "exists=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "exists=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Publish | |
| if: steps.check-npm.outputs.exists == 'false' | |
| run: npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Extract release notes from CHANGELOG | |
| if: steps.check-npm.outputs.exists == 'false' | |
| id: notes | |
| run: | | |
| sed -n '/^## Unreleased$/,/^## /{/^## /d;p}' CHANGELOG.md > /tmp/release-notes.md | |
| if [ ! -s /tmp/release-notes.md ]; then | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Create GitHub Release | |
| if: steps.check-npm.outputs.exists == 'false' && steps.notes.outputs.skip != 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release create "v${{ steps.version.outputs.version }}" \ | |
| --title "v${{ steps.version.outputs.version }}" \ | |
| --notes-file /tmp/release-notes.md \ | |
| --latest |