name: Dev Release on: push: branches: [dev] jobs: release: # Skip if commit message contains [skip ci] if: "!contains(github.event.head_commit.message, '[skip ci]')" runs-on: ubuntu-latest permissions: contents: write issues: write pull-requests: write id-token: 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: Release id: release env: HUSKY: 0 # Use built-in GITHUB_TOKEN for bot identity on comments/releases # PAT_TOKEN is only used for checkout (to trigger downstream workflows) GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} run: | OUTPUT=$(bunx semantic-release 2>&1) || true echo "$OUTPUT" if echo "$OUTPUT" | grep -q "Published release"; then echo "released=true" >> $GITHUB_OUTPUT else echo "released=false" >> $GITHUB_OUTPUT fi - name: Notify Discord if: success() && steps.release.outputs.released == 'true' env: DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} run: | if [ -z "$DISCORD_WEBHOOK_URL" ]; then echo "DISCORD_WEBHOOK_URL not set, skipping" exit 0 fi node scripts/send-discord-release.cjs dev "$DISCORD_WEBHOOK_URL" - name: Tag resolved issues if: success() && steps.release.outputs.released == 'true' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | # Get version from package.json (updated by semantic-release) VERSION=$(jq -r '.version' package.json) # Find commits since last release LAST_RELEASE=$(git log --oneline --grep="chore(release):" -n 2 | tail -1 | cut -d' ' -f1) RANGE="${LAST_RELEASE:-HEAD~20}..HEAD" echo "Checking commits in range: $RANGE" # Extract issue numbers 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" exit 0 fi # Create label if needed 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#\#} # Skip if already tagged if gh issue view "$NUM" --repo "${{ github.repository }}" --json labels --jq '.labels[].name' | grep -q "released-dev"; then echo "Issue #$NUM already tagged, skipping" continue fi echo "Tagging issue #$NUM" gh issue comment "$NUM" --repo "${{ github.repository }}" --body "[i] Available in \`$VERSION\`. Install: \`npm i @kaitranntt/ccs@dev\`" || true gh issue edit "$NUM" --add-label "released-dev" --repo "${{ github.repository }}" || true done