Publish NPM Package #12
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 | |
| jobs: | |
| build: | |
| if: ${{ github.actor != 'dependabot'}} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Environment | |
| uses: ./.github/actions/setup | |
| - name: Lint code | |
| run: npm run lint | |
| - name: Format code | |
| run: pnpm run format | |
| - name: Build project | |
| run: npm run build-ui | |
| publish: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Environment | |
| uses: ./.github/actions/setup | |
| - name: Build project | |
| run: npm run build-ui | |
| - name: Bump version (manual) | |
| working-directory: packages/ui | |
| id: bump | |
| run: | | |
| NEW_VERSION=$(node -e " | |
| const fs = require('fs'); | |
| const pkg = require('./package.json'); | |
| const type = process.env.BUMP; | |
| const semver = require('semver'); | |
| pkg.version = semver.inc(pkg.version, type); | |
| fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2)); | |
| console.log(pkg.version); | |
| ") | |
| echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| env: | |
| BUMP: ${{ github.event.inputs.version_type }} | |
| # - name: Bump version | |
| # id: bump_version | |
| # working-directory: packages/ui | |
| # run: pnpm version ${{ github.event.inputs.version_type }} --no-git-tag-version --ignore-scripts | |
| # - name: Get new version | |
| # id: version | |
| # working-directory: packages/ui | |
| # run: echo "NEW_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT | |
| # - name: Commit version bump | |
| # run: | | |
| # git config --local user.email "[email protected]" | |
| # git config --local user.name "GitHub Action" | |
| # git add . | |
| # git commit -m "chore: bump @orama/ui v${{ steps.version.outputs.NEW_VERSION }}" | |
| # git tag "v${{ steps.version.outputs.NEW_VERSION }}" | |
| # git push && git push --tags | |
| # - name: Publish to NPM | |
| # working-directory: packages/ui | |
| # run: npm publish | |
| # env: | |
| # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| # - name: Create GitHub Release | |
| # uses: actions/create-release@v1 | |
| # env: | |
| # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # with: | |
| # tag_name: v${{ steps.version.outputs.NEW_VERSION }} | |
| # release_name: Release v${{ steps.version.outputs.NEW_VERSION }} | |
| # body: | | |
| # Release v${{ steps.version.outputs.NEW_VERSION }} | |
| # Changes in this release: | |
| # - Automated release from GitHub Actions | |
| # draft: false | |
| # prerelease: false |