Skip to content
This repository was archived by the owner on Aug 19, 2026. It is now read-only.

Merge pull request #32 from mi-examples/pp-1830 #1

Merge pull request #32 from mi-examples/pp-1830

Merge pull request #32 from mi-examples/pp-1830 #1

Workflow file for this run

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"
beta-release:
needs: detect-packages
if: ${{ needs.detect-packages.outputs.packages != '[]' }}
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
pull-requests: write
strategy:
fail-fast: false
matrix:
package: ${{ fromJSON(needs.detect-packages.outputs.packages) }}
defaults:
run:
working-directory: packages/${{ matrix.package }}
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: ${{ matrix.package }}"
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 \`${{ matrix.package }}\` 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})`
});
}
}