name: ๐Ÿš€ Release Pipeline on: push: tags: ['v*'] # Allow manual releases workflow_dispatch: inputs: version: description: 'Version to release (e.g., v2.8.0)' required: true type: string prerelease: description: 'Mark as pre-release' required: false default: false type: boolean env: NODE_VERSION: '22' # NOTE: npm publishing is handled locally via /pubpro protocol. # This pipeline validates, builds artifacts, and creates the GitHub Release only. jobs: # Pre-flight validation validate: name: ๐Ÿ” Pre-flight Validation runs-on: ubuntu-latest outputs: version: ${{ steps.version.outputs.version }} is-prerelease: ${{ steps.version.outputs.is-prerelease }} steps: - name: ๐Ÿ“ฆ Checkout repository uses: actions/checkout@v7 with: fetch-depth: 0 - name: โšก Setup Bun uses: oven-sh/setup-bun@v2 with: bun-version: '1.3.13' - name: โšก Setup Node.js uses: actions/setup-node@v7 with: node-version: ${{ env.NODE_VERSION }} cache: 'npm' - name: ๐Ÿ“ฅ Install dependencies run: npm ci - name: ๐Ÿ—๏ธ Build project run: npm run build - name: ๐Ÿงช Run full test suite run: bun test --timeout=120000 - name: ๐Ÿ”ง ESLint validation run: npm run lint continue-on-error: true - name: ๐ŸŽฏ Extract version info id: version run: | if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then VERSION="${{ github.event.inputs.version }}" IS_PRERELEASE="${{ github.event.inputs.prerelease }}" else VERSION="${GITHUB_REF#refs/tags/}" # Detect pre-release from tag (contains alpha, beta, rc) if [[ "$VERSION" =~ (alpha|beta|rc) ]]; then IS_PRERELEASE="true" else IS_PRERELEASE="false" fi fi echo "version=$VERSION" >> $GITHUB_OUTPUT echo "is-prerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT echo "๐Ÿท๏ธ Version: $VERSION" echo "๐Ÿงช Pre-release: $IS_PRERELEASE" # Cross-platform testing # Windows is not in this post-tag matrix: its gate runs before merge, in the # `windows` job in ci.yml (build, CLI, packed-tarball install, faf auto, and the # full test suite). A Windows gate only here would run after the tag โ€” the # post-tag-only leak that shipped a Windows bug in 7.0. test-matrix: name: ๐Ÿงช Cross-Platform Testing needs: validate runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, macos-latest] node-version: ['22', '24'] steps: - name: ๐Ÿ“ฆ Checkout repository uses: actions/checkout@v7 - name: โšก Setup Bun uses: oven-sh/setup-bun@v2 with: bun-version: '1.3.13' - name: โšก Setup Node.js ${{ matrix.node-version }} uses: actions/setup-node@v7 with: node-version: ${{ matrix.node-version }} cache: 'npm' - name: ๐Ÿ“ฅ Install dependencies run: npm ci - name: ๐Ÿ—๏ธ Build project run: npm run build - name: ๐Ÿงช Run tests run: bun test --timeout=120000 - name: ๐ŸŽฏ Test CLI functionality run: | # Test basic CLI commands node dist/cli.js --version node dist/cli.js --help # Build release artifacts build-artifacts: name: ๐Ÿ—๏ธ Build Release Artifacts needs: [validate, test-matrix] runs-on: ubuntu-latest steps: - name: ๐Ÿ“ฆ Checkout repository uses: actions/checkout@v7 - name: โšก Setup Bun uses: oven-sh/setup-bun@v2 with: bun-version: '1.3.13' - name: โšก Setup Node.js uses: actions/setup-node@v7 with: node-version: ${{ env.NODE_VERSION }} cache: 'npm' - name: ๐Ÿ“ฅ Install dependencies run: npm ci - name: ๐Ÿ—๏ธ Build project run: npm run build - name: ๐Ÿ“ฆ Create package run: npm pack - name: ๐Ÿ“Š Package info run: | echo "๐Ÿท๏ธ Package created:" ls -la *.tgz echo "๐Ÿ“ฆ Package contents:" tar -tzf *.tgz | head -20 - name: ๐Ÿ’พ Upload package artifact uses: actions/upload-artifact@v6 with: name: npm-package path: '*.tgz' retention-days: 30 # Generate changelog changelog: name: ๐Ÿ“ Generate Changelog needs: validate runs-on: ubuntu-latest outputs: changelog: ${{ steps.changelog.outputs.changelog }} steps: - name: ๐Ÿ“ฆ Checkout repository uses: actions/checkout@v7 with: fetch-depth: 0 - name: ๐Ÿ“ Generate changelog id: changelog run: | # Get commits since last tag LAST_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") if [[ -n "$LAST_TAG" ]]; then echo "๐Ÿ“… Changes since $LAST_TAG:" CHANGELOG=$(git log --pretty=format:"- %s (%h)" $LAST_TAG..HEAD) else echo "๐Ÿ“… Initial release - all commits:" CHANGELOG=$(git log --pretty=format:"- %s (%h)" --max-count=20) fi # Save multiline output safely { echo 'changelog<> $GITHUB_OUTPUT # Create GitHub release github-release: name: ๐Ÿท๏ธ Create GitHub Release needs: [validate, test-matrix, build-artifacts, changelog] runs-on: ubuntu-latest permissions: contents: write # Required by softprops/action-gh-release to create the GitHub Release steps: - name: ๐Ÿ“ฆ Checkout repository uses: actions/checkout@v7 - name: ๐Ÿ’พ Download package artifact uses: actions/download-artifact@v7 with: name: npm-package # /pubpro cuts the release first (Edition title + curated notes, its # Doc Gate). Overwriting it here renamed v7.12.0 and v7.12.1 to # "FAF CLI vX" and replaced their notes. If the release exists, only # attach the package; create it only when nothing has been cut. - name: ๐Ÿ”Ž Does the release already exist? id: existing env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} TAG: ${{ needs.validate.outputs.version }} run: | if gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then echo "exists=true" >> "$GITHUB_OUTPUT" else echo "exists=false" >> "$GITHUB_OUTPUT" fi - name: ๐Ÿ“Ž Attach the package to the existing release (title and notes untouched) if: steps.existing.outputs.exists == 'true' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} TAG: ${{ needs.validate.outputs.version }} run: gh release upload "$TAG" *.tgz --clobber --repo "$GITHUB_REPOSITORY" - name: ๐Ÿท๏ธ Create GitHub Release if: steps.existing.outputs.exists != 'true' uses: softprops/action-gh-release@v3 with: tag_name: ${{ needs.validate.outputs.version }} name: FAF CLI ${{ needs.validate.outputs.version }} # Body = the curated CHANGELOG section (single source โ€” pubpro's # doc-gate owns release-note quality) + a version-AGNOSTIC install # line. Never interpolate the tag into an npm spec (`@v6.7.0` is the # git tag, NOT an npm version โ€” it fails). `@latest` is always valid. body: | ## Install ```bash npm install -g faf-cli@latest ``` ${{ needs.changelog.outputs.changelog }} draft: false prerelease: ${{ needs.validate.outputs.is-prerelease == 'true' }} files: | *.tgz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Performance benchmarks (installs from npm to verify published package) performance-benchmark: name: โšก Performance Validation needs: [validate, test-matrix] runs-on: ubuntu-latest steps: - name: ๐Ÿ“ฆ Checkout repository uses: actions/checkout@v7 - name: โšก Setup Node.js uses: actions/setup-node@v7 with: node-version: ${{ env.NODE_VERSION }} - name: ๐Ÿ“ฅ Install published package id: install run: | # The release.yml fires on tag push, but /pubpro publishes to npm # AFTER the GitHub Release is created. So at first run, the version # may not be on npm yet. Skip-with-warning if not present; re-run the # workflow manually (workflow_dispatch) once /pubpro completes. VERSION="${{ needs.validate.outputs.version }}" if npm view "faf-cli@${VERSION}" version >/dev/null 2>&1; then echo "๐Ÿ”„ Installing published version v${VERSION}..." npm install -g "faf-cli@${VERSION}" faf --version echo "skipped=false" >> "$GITHUB_OUTPUT" else echo "::warning::Version v${VERSION} not yet on npm โ€” Performance Validation skipped. Re-run this workflow after /pubpro publish to validate." echo "skipped=true" >> "$GITHUB_OUTPUT" fi - name: ๐ŸŽ๏ธ Performance Tests if: steps.install.outputs.skipped != 'true' run: | echo "Testing v6 command speed..." echo "Testing 'faf --help'..." time faf --help echo "Testing 'faf info'..." time faf info echo "Testing 'faf formats'..." time faf formats echo "Performance validation complete" # Notification notify-success: name: ๐ŸŽ‰ Success Notification needs: [validate, test-matrix, build-artifacts, github-release, performance-benchmark] runs-on: ubuntu-latest if: success() steps: - name: ๐Ÿ† Championship Success! run: | echo "๐Ÿ ๐ŸŽ๏ธ FAF CLI ${{ needs.validate.outputs.version }} RELEASED! โšก๐Ÿ†" echo "" echo "โœ… All systems green - Championship engineering delivered!" echo "๐Ÿท๏ธ GitHub: Release created" echo "โšก Performance: F1-validated" echo "" echo "๐Ÿ“ฆ Install: npm install -g faf-cli@latest" echo "" echo "NOTE: npm publishing is handled via /pubpro protocol (local)" # Failure notification notify-failure: name: ๐Ÿšจ Failure Notification needs: [validate, test-matrix, build-artifacts, github-release] runs-on: ubuntu-latest if: failure() steps: - name: ๐Ÿšจ Release Failed run: | echo "โŒ FAF CLI ${{ needs.validate.outputs.version }} release failed!" echo "๐Ÿ”ง Check the workflow logs for details" echo "๐ŸŽ๏ธ We'll fix this!"