Updated README #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: Build and Publish to npm | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| tags: [ 'v*' ] | |
| pull_request: | |
| branches: [ main, master ] | |
| permissions: | |
| contents: write | |
| packages: write | |
| id-token: write | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [20] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| ssh-strict: false | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run linting | |
| run: npm run lint | |
| - name: Run tests | |
| run: npm test | |
| - name: Build package | |
| run: npm run build | |
| - name: Check package | |
| run: npm pack --dry-run | |
| publish: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| ssh-strict: false | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Extract version from package.json | |
| id: version | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Package version: $VERSION" | |
| - name: Verify npm token | |
| run: | | |
| if [ -n "${{ secrets.NPM_TOKEN }}" ]; then | |
| echo "NPM_TOKEN is available" | |
| npm whoami --registry=https://registry.npmjs.org/ | |
| else | |
| echo "NPM_TOKEN is not available" | |
| exit 1 | |
| fi | |
| - name: Check if package exists | |
| run: | | |
| echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc | |
| npm view cost-katana-cli --registry=https://registry.npmjs.org/ || echo "Package does not exist yet" | |
| - name: Build package | |
| run: npm run build | |
| - name: Publish to npm | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: | | |
| echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc | |
| npm publish --access public --registry=https://registry.npmjs.org/ | |
| - name: Create GitHub Release | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| release_name: Release ${{ github.ref_name }} | |
| body: | | |
| ## CostKatana CLI v${{ steps.version.outputs.version }} | |
| ### Installation | |
| ```bash | |
| npm install -g cost-katana-cli@${{ steps.version.outputs.version }} | |
| ``` | |
| ### What's New | |
| - Updated dependencies and improvements | |
| - Enhanced TypeScript definitions | |
| - Better error handling | |
| ### Breaking Changes | |
| None | |
| ### Bug Fixes | |
| - Fixed TypeScript compilation issues | |
| - Updated build configuration | |
| ### Documentation | |
| - Updated installation instructions | |
| - Improved examples and documentation | |
| ### Development | |
| - Added GitHub Actions CI/CD | |
| - Automated testing and publishing | |
| draft: false | |
| prerelease: false | |