This repository was archived by the owner on Aug 19, 2026. It is now read-only.
Merge pull request #33 from mi-examples/pp-1830 #2
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: Beta Release | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| jobs: | |
| detect-packages: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| packages: ${{ steps.set-packages.outputs.packages }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get changed packages | |
| id: set-packages | |
| run: | | |
| # Get files changed in the last commit | |
| changed_files=$(git diff --name-only HEAD~1 HEAD 2>/dev/null || echo "") | |
| packages="[]" | |
| if [[ -n "$changed_files" ]]; then | |
| # Extract unique package names from changed files | |
| package_dirs=($(echo "$changed_files" | grep -o 'packages/[^/]*' | cut -d'/' -f2 | sort -u | grep -v '^$')) | |
| # If we have changed packages, format as JSON array | |
| if [[ ${#package_dirs[@]} -gt 0 ]]; then | |
| packages=$(printf '"%s",' "${package_dirs[@]}" | sed 's/,$//' | awk '{print "["$0"]"}') | |
| fi | |
| fi | |
| echo "packages=$packages" >> $GITHUB_OUTPUT | |
| echo "Changed packages: $packages" | |
| # Release pp-dev first (core package) | |
| beta-release-pp-dev: | |
| needs: detect-packages | |
| if: ${{ contains(fromJSON(needs.detect-packages.outputs.packages), 'pp-dev') }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| pull-requests: write | |
| defaults: | |
| run: | |
| working-directory: packages/pp-dev | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: https://registry.npmjs.org/ | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build package | |
| run: npm run build | |
| - name: Verify build output | |
| run: | | |
| if [[ ! -d "dist" ]]; then | |
| echo "Error: Build output directory 'dist' not found" | |
| exit 1 | |
| fi | |
| echo "Build verification passed" | |
| - name: Configure Git | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Beta Release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NODE_AUTH_TOKEN: ${{ secrets.npm_token }} | |
| NPM_TOKEN: ${{ secrets.npm_token }} | |
| run: | | |
| echo "Running beta release for package: pp-dev" | |
| npm run release | |
| - name: Comment on commit | |
| if: success() | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const { data: releases } = await github.rest.repos.listReleases({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| per_page: 1 | |
| }); | |
| if (releases.length > 0) { | |
| const latestRelease = releases[0]; | |
| if (latestRelease.tag_name.includes('beta')) { | |
| await github.rest.repos.createCommitComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| commit_sha: context.sha, | |
| body: `🚀 **Beta Release Created!**\n\nPackage \`pp-dev\` has been released as beta version \`${latestRelease.tag_name}\`\n\n**Release Notes:**\n${latestRelease.body || 'No release notes available'}\n\n**Download:** [${latestRelease.tag_name}](${latestRelease.html_url})` | |
| }); | |
| } | |
| } | |
| # Release create-pp-dev second (depends on pp-dev) | |
| beta-release-create-pp-dev: | |
| needs: [detect-packages, beta-release-pp-dev] | |
| if: ${{ contains(fromJSON(needs.detect-packages.outputs.packages), 'create-pp-dev') }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| pull-requests: write | |
| defaults: | |
| run: | |
| working-directory: packages/create-pp-dev | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: https://registry.npmjs.org/ | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build package | |
| run: npm run build | |
| - name: Verify build output | |
| run: | | |
| if [[ ! -d "dist" ]]; then | |
| echo "Error: Build output directory 'dist' not found" | |
| exit 1 | |
| fi | |
| echo "Build verification passed" | |
| - name: Configure Git | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Verify pp-dev dependency | |
| run: | | |
| echo "Verifying pp-dev release exists..." | |
| git fetch --tags origin | |
| if ! git tag --list | grep -q "^v[0-9]"; then | |
| echo "Error: pp-dev tag not found. Cannot proceed with create-pp-dev release." | |
| exit 1 | |
| fi | |
| echo "pp-dev dependency verified successfully" | |
| - name: Beta Release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NODE_AUTH_TOKEN: ${{ secrets.npm_token }} | |
| NPM_TOKEN: ${{ secrets.npm_token }} | |
| run: | | |
| echo "Running beta release for package: create-pp-dev" | |
| npm run release | |
| - name: Comment on commit | |
| if: success() | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const { data: releases } = await github.rest.repos.listReleases({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| per_page: 1 | |
| }); | |
| if (releases.length > 0) { | |
| const latestRelease = releases[0]; | |
| if (latestRelease.tag_name.includes('beta')) { | |
| await github.rest.repos.createCommitComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| commit_sha: context.sha, | |
| body: `🚀 **Beta Release Created!**\n\nPackage \`create-pp-dev\` has been released as beta version \`${latestRelease.tag_name}\`\n\n**Release Notes:**\n${latestRelease.body || 'No release notes available'}\n\n**Download:** [${latestRelease.tag_name}](${latestRelease.html_url})` | |
| }); | |
| } | |
| } |