chore: update homebrew formula to v1.17.1 #221
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: Release to NPM and GitHub | |
| on: | |
| push: | |
| branches: [main] | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| check-version: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should-publish: ${{ steps.version-check.outputs.should-publish }} | |
| package-version: ${{ steps.version-check.outputs.package-version }} | |
| npm-version: ${{ steps.version-check.outputs.npm-version }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Check version difference | |
| id: version-check | |
| run: | | |
| # Get current package.json version | |
| PACKAGE_VERSION=$(node -p "require('./package.json').version") | |
| echo "package-version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT | |
| # Get latest NPM version (handle case where package doesn't exist yet) | |
| NPM_VERSION=$(npm view @nanocollective/nanocoder version 2>/dev/null || echo "0.0.0") | |
| echo "npm-version=$NPM_VERSION" >> $GITHUB_OUTPUT | |
| # Compare versions | |
| if [ "$PACKAGE_VERSION" != "$NPM_VERSION" ]; then | |
| echo "✅ New version detected: $PACKAGE_VERSION (current NPM: $NPM_VERSION)" | |
| echo "should-publish=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "ℹ️ No version change detected: $PACKAGE_VERSION" | |
| echo "should-publish=false" >> $GITHUB_OUTPUT | |
| fi | |
| publish: | |
| needs: check-version | |
| if: needs.check-version.outputs.should-publish == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: latest | |
| - name: Install dependencies (including VS Code extension) | |
| run: pnpm install --frozen-lockfile | |
| - name: Build project | |
| run: pnpm run build | |
| - name: Build VS Code extension | |
| run: pnpm run build:vscode | |
| - name: Run tests | |
| run: pnpm test:all | |
| - name: Verify build output | |
| run: | | |
| if [ ! -f "dist/cli.js" ]; then | |
| echo "❌ Build failed: dist/cli.js not found" | |
| exit 1 | |
| fi | |
| echo "✅ Build successful: dist/cli.js exists" | |
| if [ ! -f "assets/nanocoder-vscode.vsix" ]; then | |
| echo "❌ Build failed: VS Code extension not found" | |
| exit 1 | |
| fi | |
| echo "✅ VS Code extension built: assets/nanocoder-vscode.vsix exists" | |
| - name: Extract Changelog | |
| id: changelog | |
| run: | | |
| # Extract changelog for current version | |
| CHANGELOG=$(node scripts/extract-changelog.js 2>&1) | |
| if [ $? -eq 0 ]; then | |
| echo "✅ Changelog extracted successfully" | |
| # Use EOF to handle multi-line output | |
| echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT | |
| echo "$CHANGELOG" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| else | |
| echo "⚠️ No changelog entry found, using default message" | |
| echo "CHANGELOG=No changelog available for this version." >> $GITHUB_OUTPUT | |
| fi | |
| - name: Publish to NPM | |
| run: npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Create GitHub Release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: v${{ needs.check-version.outputs.package-version }} | |
| release_name: nanocoder v${{ needs.check-version.outputs.package-version }} | |
| body: | | |
| ## What's Changed | |
| ${{ steps.changelog.outputs.CHANGELOG }} | |
| ### Installation | |
| ```bash | |
| npm install -g @nanocollective/nanocoder | |
| ``` | |
| ### Usage | |
| ```bash | |
| nanocoder | |
| ``` | |
| **Full Changelog**: https://github.com/Nano-Collective/nanocoder/compare/v${{ needs.check-version.outputs.npm-version }}...v${{ needs.check-version.outputs.package-version }} | |
| draft: false | |
| prerelease: false | |
| - name: Send Discord Notification | |
| if: success() | |
| run: | | |
| curl -H "Content-Type: application/json" \ | |
| -d '{ | |
| "embeds": [{ | |
| "title": "🎉 New Release: Nanocoder v${{ needs.check-version.outputs.package-version }}", | |
| "description": "A new version of Nanocoder has been released!\n\n[View the full changelog on GitHub](https://github.com/${{ github.repository }}/releases/tag/v${{ needs.check-version.outputs.package-version }})", | |
| "color": 5763719, | |
| "fields": [ | |
| { | |
| "name": "Version", | |
| "value": "v${{ needs.check-version.outputs.package-version }}", | |
| "inline": true | |
| }, | |
| { | |
| "name": "Installation", | |
| "value": "`npm install -g @nanocollective/nanocoder`", | |
| "inline": false | |
| } | |
| ], | |
| "footer": { | |
| "text": "GitHub Actions" | |
| }, | |
| "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%S.000Z)'", | |
| "url": "https://github.com/${{ github.repository }}/releases/tag/v${{ needs.check-version.outputs.package-version }}" | |
| }] | |
| }' \ | |
| ${{ secrets.DISCORD_WEBHOOK_URL }} | |
| update-nix: | |
| needs: [check-version, publish] | |
| if: needs.check-version.outputs.should-publish == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| token: ${{ secrets.PAT_TOKEN }} | |
| - name: Install Nix | |
| uses: cachix/install-nix-action@v26 | |
| with: | |
| nix_path: nixpkgs=channel:nixos-unstable | |
| extra_nix_config: | | |
| experimental-features = nix-command flakes | |
| - name: Update Nix package | |
| run: | | |
| chmod +x scripts/update-nix-version.sh | |
| ./scripts/update-nix-version.sh ${{ needs.check-version.outputs.package-version }} | |
| - name: Commit and push Nix update | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add nix/packages/default/default.nix | |
| git commit -m "chore: update nix package to v${{ needs.check-version.outputs.package-version }}" || echo "No changes to commit" | |
| git push origin main | |
| update-homebrew: | |
| needs: [check-version, publish, update-nix] | |
| if: needs.check-version.outputs.should-publish == 'true' | |
| runs-on: macos-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| token: ${{ secrets.PAT_TOKEN }} | |
| - name: Update Homebrew formula | |
| run: | | |
| chmod +x scripts/update-homebrew-formula.sh | |
| ./scripts/update-homebrew-formula.sh ${{ needs.check-version.outputs.package-version }} | |
| - name: Commit and push formula | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add Formula/nanocoder.rb | |
| git commit -m "chore: update homebrew formula to v${{ needs.check-version.outputs.package-version }}" || echo "No changes to commit" | |
| git push origin main | |
| notify: | |
| needs: [check-version, publish, update-nix, update-homebrew] | |
| if: always() | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Notify result | |
| run: | | |
| if [ "${{ needs.check-version.outputs.should-publish }}" == "true" ]; then | |
| if [ "${{ needs.publish.result }}" == "success" ]; then | |
| echo "🎉 Successfully published @nanocollective/nanocoder v${{ needs.check-version.outputs.package-version }} to NPM and created GitHub release!" | |
| if [ "${{ needs.update-nix.result }}" == "success" ]; then | |
| echo "✅ Nix package updated successfully!" | |
| else | |
| echo "⚠️ Warning: Nix package update failed" | |
| fi | |
| if [ "${{ needs.update-homebrew.result }}" == "success" ]; then | |
| echo "✅ Homebrew formula updated successfully!" | |
| else | |
| echo "⚠️ Warning: Homebrew formula update failed" | |
| fi | |
| else | |
| echo "❌ Failed to publish @nanocollective/nanocoder v${{ needs.check-version.outputs.package-version }}" | |
| exit 1 | |
| fi | |
| else | |
| echo "ℹ️ No new version to publish (current: ${{ needs.check-version.outputs.package-version }})" | |
| fi |