Publish NPM Package #41
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: Publish NPM Package | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version_type: | |
| description: "Use PATCH for fixes, use MINOR for new features and use MAJOR for breaking changes" | |
| required: true | |
| default: 'patch' | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| permissions: | |
| contents: write | |
| packages: write | |
| id-token: write | |
| jobs: | |
| build: | |
| if: ${{ github.actor != 'dependabot'}} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Environment | |
| uses: ./.github/actions/setup | |
| - name: Lint code | |
| run: npm run lint | |
| - name: Build project | |
| run: npm run build-ui && npm run build-demo | |
| publish: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Environment | |
| uses: ./.github/actions/setup | |
| - name: Format code | |
| run: pnpm run format | |
| - name: Build project | |
| run: npm run build-ui | |
| - name: Install semver | |
| run: pnpm add -w semver | |
| - name: Bump version | |
| working-directory: packages/ui | |
| id: bump | |
| run: | | |
| NEW_VERSION=$(node - << 'EOF' | |
| const fs = require('fs'); | |
| const semver = require('semver'); | |
| const pkg = require('./package.json'); | |
| pkg.version = semver.inc(pkg.version, process.env.BUMP); | |
| fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2)); | |
| console.log(pkg.version); | |
| EOF | |
| ) | |
| echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| env: | |
| BUMP: ${{ github.event.inputs.version_type }} | |
| - name: Read new version | |
| id: version | |
| working-directory: packages/ui | |
| run: | | |
| BUMP_VERSION=$(node <<'EOF' | |
| console.log(require('./package.json').version); | |
| EOF | |
| ) | |
| echo "BUMP_VERSION=$BUMP_VERSION" >> $GITHUB_OUTPUT | |
| - name: Get new version | |
| working-directory: packages/ui | |
| run: echo "Version is ${{ steps.version.outputs.BUMP_VERSION }}" | |
| # - name: Commit and tag version bump | |
| # run: | | |
| # git config user.name "github-actions[bot]" | |
| # git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| # git add . | |
| # git commit -m "chore: bump @orama/ui v${{ steps.version.outputs.BUMP_VERSION }}" || echo "No changes to commit" | |
| # git tag v${{ steps.version.outputs.BUMP_VERSION }} | |
| - name: Commit and tag version bump | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add . | |
| git commit -m "chore: bump @orama/ui v${{ steps.version.outputs.BUMP_VERSION }}" || echo "No changes to commit" | |
| - name: Push changes | |
| run: | | |
| git push origin HEAD:main | |
| git push origin --tags | |
| # - name: Configure npm with token | |
| # run: | | |
| # echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc | |
| # - name: Publish to NPM | |
| # working-directory: packages/ui | |
| # run: npm publish | |
| # env: | |
| # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| # - name: Create GitHub draft release | |
| # env: | |
| # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # run: | | |
| # gh release create v${{ steps.version.outputs.BUMP_VERSION }} \ | |
| # --generate-notes |