Files
ccs/.github/workflows/dev-release.yml
T
kaitranntt 763928f282 fix(ci): resolve YAML syntax error in dev-release workflow
Multi-line heredoc in issue comment was breaking YAML parsing.
Use inline multi-line string with proper indentation instead.
2025-12-12 15:57:24 -05:00

165 lines
5.1 KiB
YAML

name: Dev Release
on:
push:
branches: [dev]
jobs:
release:
# Skip if commit message contains [skip ci] or is a release commit
if: "!contains(github.event.head_commit.message, '[skip ci]')"
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT_TOKEN }}
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: |
bun install --frozen-lockfile
cd ui && bun install --frozen-lockfile
- name: Build
run: bun run build:all
- name: Validate (typecheck + lint + tests)
run: bun run validate
- name: Bump dev version
id: bump
run: |
CURRENT=$(cat VERSION)
PKG_NAME=$(jq -r '.name' package.json)
# Extract base version
if [[ "$CURRENT" =~ ^([0-9]+\.[0-9]+\.[0-9]+)(-dev\.([0-9]+))?$ ]]; then
BASE="${BASH_REMATCH[1]}"
else
echo "Invalid version format: $CURRENT"
exit 1
fi
# Find highest published dev version for this base
LATEST_DEV=$(npm view "${PKG_NAME}" versions --json 2>/dev/null | \
jq -r '.[]' | \
grep "^${BASE}-dev\." | \
sed "s/${BASE}-dev\.//" | \
sort -n | \
tail -1)
if [[ -z "$LATEST_DEV" ]]; then
NEW_DEV=1
else
NEW_DEV=$((LATEST_DEV + 1))
fi
NEW_VERSION="${BASE}-dev.${NEW_DEV}"
echo "current=$CURRENT" >> $GITHUB_OUTPUT
echo "new=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "Bumping: $CURRENT -> $NEW_VERSION"
- name: Update version files
run: |
NEW_VERSION="${{ steps.bump.outputs.new }}"
# Update VERSION file
echo "$NEW_VERSION" > VERSION
# Update package.json
jq --arg v "$NEW_VERSION" '.version = $v' package.json > package.json.tmp
mv package.json.tmp package.json
# Update installers
sed -i "s/^VERSION=.*/VERSION=\"$NEW_VERSION\"/" installers/install.sh
sed -i "s/^\$Version = .*/\$Version = \"$NEW_VERSION\"/" installers/install.ps1
- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --tag dev
- name: Tag resolved issues
env:
GH_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
NEW_VERSION="${{ steps.bump.outputs.new }}"
# Find commits since last dev release (look for version bump commits)
LAST_RELEASE_COMMIT=$(git log --oneline --grep="chore(release):" -n 2 | tail -1 | cut -d' ' -f1)
if [[ -n "$LAST_RELEASE_COMMIT" ]]; then
RANGE="${LAST_RELEASE_COMMIT}..HEAD"
else
RANGE="HEAD~20..HEAD"
fi
echo "Checking commits in range: $RANGE"
# Extract issue numbers from commits
ISSUES=$(git log $RANGE --pretty=format:"%s %b" | \
grep -oE "(Fixes|Closes|Resolves|Refs?) #[0-9]+" | \
grep -oE "#[0-9]+" | sort -u || true)
if [[ -z "$ISSUES" ]]; then
echo "No linked issues found in commits"
exit 0
fi
# Create labels if they don't exist
gh label create "released-dev" \
--color "1d76db" \
--description "Fix available in @dev npm channel" \
--repo ${{ github.repository }} 2>/dev/null || true
for ISSUE in $ISSUES; do
NUM=${ISSUE#\#}
echo "Tagging issue #$NUM as released-dev"
# Add comment (using printf to handle newlines safely)
COMMENT=":test_tube: This fix is available for testing in version \\\`$NEW_VERSION\\\`
Install with:
\\\`\\\`\\\`bash
npm install @kaitranntt/ccs@dev
\\\`\\\`\\\`
Please test and confirm the fix works as expected."
gh issue comment "$NUM" --repo "${{ github.repository }}" --body "$COMMENT" || true
# Add released-dev label, remove pending-release if present
gh issue edit $NUM \
--add-label "released-dev" \
--remove-label "pending-release" \
--repo ${{ github.repository }} 2>/dev/null || \
gh issue edit $NUM \
--add-label "released-dev" \
--repo ${{ github.repository }} || true
done
- name: Commit version bump
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add VERSION package.json installers/install.sh installers/install.ps1
git commit -m "chore(release): ${{ steps.bump.outputs.new }} [skip ci]"
git push origin dev