Merge pull request #81 from moneydevkit/mdk-403 #39
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
| # Publish Beta Workflow | |
| # | |
| # This workflow automatically publishes beta versions of all @moneydevkit packages | |
| # whenever changes are pushed to the main branch. | |
| # | |
| # How it works: | |
| # 1. Triggers on push to main when files in packages/ are modified | |
| # 2. Skips if commit message contains [skip ci] (to avoid infinite loops from version bump commits) | |
| # 3. Determines the next beta version: | |
| # - If current version is stable (e.g., 0.4.0), creates 0.4.0-beta.0 | |
| # - If current version is already beta (e.g., 0.4.0-beta.2), increments to 0.4.0-beta.3 | |
| # 4. Updates ALL packages to the same version (unified versioning) | |
| # 5. Updates @moneydevkit/core dependency in nextjs and replit packages | |
| # 6. Builds and publishes all packages to npm with the "beta" tag | |
| # 7. Commits version bump with [skip ci] only after successful publish | |
| # | |
| # After a stable release, publish-release.yml automatically bumps the version | |
| # to the next minor (e.g., 0.4.0 → 0.5.0), so betas continue seamlessly. | |
| # | |
| # Install beta versions with: npm install @moneydevkit/nextjs@beta | |
| name: Publish Beta | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "packages/**" | |
| jobs: | |
| publish-beta: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| env: | |
| NPM_PUBLISH_REGISTRY: https://registry.npmjs.org | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check for [skip ci] in commit message | |
| id: skip_check | |
| run: | | |
| COMMIT_MSG=$(git log -1 --pretty=%B) | |
| if [[ "$COMMIT_MSG" == *"[skip ci]"* ]]; then | |
| echo "skip=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "skip=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Setup Node.js | |
| if: steps.skip_check.outputs.skip != 'true' | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| registry-url: ${{ env.NPM_PUBLISH_REGISTRY }} | |
| - name: Upgrade npm (required for trusted publishing) | |
| if: steps.skip_check.outputs.skip != 'true' | |
| run: npm install -g npm@11.6.2 | |
| - name: Install dependencies | |
| if: steps.skip_check.outputs.skip != 'true' | |
| run: rm -f package-lock.json && npm install | |
| - name: Configure git | |
| if: steps.skip_check.outputs.skip != 'true' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Bump all packages to next beta version | |
| if: steps.skip_check.outputs.skip != 'true' | |
| run: | | |
| # Get current version from core package (all packages share the same version) | |
| CURRENT_VERSION=$(node -p "require('./packages/core/package.json').version") | |
| echo "Current version: $CURRENT_VERSION" | |
| # Determine next version based on whether current is stable or beta | |
| if [[ "$CURRENT_VERSION" =~ -beta\.[0-9]+$ ]]; then | |
| # Already a beta version, increment the beta number | |
| # Extract base version and beta number, then increment | |
| BASE_VERSION=$(echo "$CURRENT_VERSION" | sed 's/-beta\.[0-9]*$//') | |
| BETA_NUM=$(echo "$CURRENT_VERSION" | sed 's/.*-beta\.//') | |
| NEW_BETA_NUM=$((BETA_NUM + 1)) | |
| NEW_VERSION="${BASE_VERSION}-beta.${NEW_BETA_NUM}" | |
| else | |
| # Stable version, add -beta.0 suffix | |
| NEW_VERSION="${CURRENT_VERSION}-beta.0" | |
| fi | |
| echo "New version: $NEW_VERSION" | |
| # Update all packages to the same version using npm pkg set (no dependency resolution) | |
| npm pkg set version=$NEW_VERSION --workspace packages/core | |
| npm pkg set version=$NEW_VERSION --workspace packages/nextjs | |
| npm pkg set version=$NEW_VERSION --workspace packages/create | |
| npm pkg set version=$NEW_VERSION --workspace packages/replit | |
| # Update @moneydevkit/core dependency in nextjs and replit | |
| npm pkg set dependencies.@moneydevkit/core=$NEW_VERSION --workspace packages/nextjs | |
| npm pkg set dependencies.@moneydevkit/core=$NEW_VERSION --workspace packages/replit | |
| echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV | |
| - name: Build all packages | |
| if: steps.skip_check.outputs.skip != 'true' | |
| run: npm run build | |
| - name: Publish @moneydevkit/core | |
| if: steps.skip_check.outputs.skip != 'true' | |
| run: npm publish ./packages/core --tag beta --provenance --access public | |
| - name: Publish @moneydevkit/nextjs | |
| if: steps.skip_check.outputs.skip != 'true' | |
| run: npm publish ./packages/nextjs --tag beta --provenance --access public | |
| - name: Publish @moneydevkit/create | |
| if: steps.skip_check.outputs.skip != 'true' | |
| run: npm publish ./packages/create --tag beta --provenance --access public | |
| - name: Publish @moneydevkit/replit | |
| if: steps.skip_check.outputs.skip != 'true' | |
| run: npm publish ./packages/replit --tag beta --provenance --access public | |
| - name: Update package-lock.json | |
| if: steps.skip_check.outputs.skip != 'true' | |
| run: npm install --package-lock-only | |
| - name: Commit and push version bump | |
| if: steps.skip_check.outputs.skip != 'true' | |
| run: | | |
| git add -A | |
| git commit -m "chore: bump all packages to $NEW_VERSION [skip ci]" | |
| git push |