Publish to Docker Hub and NPM #8
  
    
      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 to Docker Hub and NPM | |
| permissions: | |
| contents: write | |
| id-token: write | |
| packages: write | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Version bump type" | |
| required: true | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| default: patch | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup pnpm | |
| run: npm install -g corepack@latest && corepack enable | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24.x | |
| cache: "pnpm" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Log NPM version | |
| run: npm -v | |
| - name: Configure git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Run format check | |
| run: pnpm format:check | |
| - name: Run linter | |
| run: pnpm lint | |
| - name: Run type checking | |
| run: pnpm check | |
| - name: Run tests | |
| run: pnpm test | |
| - name: Build application | |
| run: pnpm build | |
| - name: Bump version | |
| run: npm version ${{ inputs.version }} -m "🔖 mongoku@%s" | |
| - name: Get new version | |
| id: package-version | |
| run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT | |
| - name: Push changes | |
| run: | | |
| git push | |
| git push --tags | |
| - name: Publish to NPM | |
| run: pnpm publish --no-git-checks | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| tags: | | |
| huggingface/mongoku:latest | |
| huggingface/mongoku:${{ steps.package-version.outputs.version }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| # - name: Create GitHub Release | |
| # uses: actions/create-release@v1 | |
| # env: | |
| # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # with: | |
| # tag_name: v${{ steps.package-version.outputs.version }} | |
| # release_name: Release v${{ steps.package-version.outputs.version }} | |
| # draft: false | |
| # prerelease: false | |
| # hack - reuse actions/setup-node@v4 just to set a new registry | |
| # - uses: actions/setup-node@v4 | |
| # with: | |
| # node-version: "24" | |
| # registry-url: "https://npm.pkg.github.com" | |
| # - run: pnpm publish --no-git-checks . | |
| # env: | |
| # NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |