Remove Raycast extension (extracted to separate repo) (#45) #58
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
| # Using [trusted publishing](https://docs.npmjs.com/trusted-publishers) | |
| name: Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| inputs: | |
| version_bump: | |
| description: "Version bump type" | |
| required: true | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| - dry-run | |
| permissions: | |
| contents: write | |
| id-token: write | |
| jobs: | |
| check-pr-label: | |
| name: Check PR Label | |
| runs-on: ubuntu-latest | |
| outputs: | |
| has_label: ${{ steps.check.outputs.has_label }} | |
| bump_type: ${{ steps.check.outputs.bump_type }} | |
| is_dry_run: ${{ steps.check.outputs.is_dry_run }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check for version label | |
| id: check | |
| run: | | |
| # If manually triggered, use the input | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| echo "bump_type=${{ inputs.version_bump }}" >> $GITHUB_OUTPUT | |
| echo "has_label=true" >> $GITHUB_OUTPUT | |
| echo "Manual trigger: using bump type ${{ inputs.version_bump }}" | |
| # Set dry_run flag | |
| if [ "${{ inputs.version_bump }}" = "dry-run" ]; then | |
| echo "is_dry_run=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "is_dry_run=false" >> $GITHUB_OUTPUT | |
| fi | |
| exit 0 | |
| fi | |
| # For PR merges, not a dry run | |
| echo "is_dry_run=false" >> $GITHUB_OUTPUT | |
| # Get the PR number from the merge commit | |
| PR_NUMBER=$(gh pr list --state merged --json number,mergeCommit --jq ".[] | select(.mergeCommit.oid == \"${{ github.sha }}\") | .number" | head -n 1) | |
| if [ -z "$PR_NUMBER" ]; then | |
| echo "Error: Could not find PR for commit ${{ github.sha }}" | |
| echo "Direct pushes to main are not allowed. All changes must go through a PR with a version label (major, minor, or patch)." | |
| exit 1 | |
| fi | |
| # Get PR labels | |
| LABELS=$(gh pr view "$PR_NUMBER" --json labels --jq '.labels[].name' | tr '\n' ' ') | |
| echo "PR #$PR_NUMBER labels: $LABELS" | |
| # Check if PR has a version label and set bump_type | |
| if echo "$LABELS" | grep -qw "major"; then | |
| echo "bump_type=major" >> $GITHUB_OUTPUT | |
| echo "has_label=true" >> $GITHUB_OUTPUT | |
| elif echo "$LABELS" | grep -qw "minor"; then | |
| echo "bump_type=minor" >> $GITHUB_OUTPUT | |
| echo "has_label=true" >> $GITHUB_OUTPUT | |
| elif echo "$LABELS" | grep -qw "patch"; then | |
| echo "bump_type=patch" >> $GITHUB_OUTPUT | |
| echo "has_label=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "Error: PR #$PR_NUMBER must have one of these labels: major, minor, patch" | |
| echo "Current labels: $LABELS" | |
| exit 1 | |
| fi | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| version: | |
| name: Determine Version | |
| needs: check-pr-label | |
| if: needs.check-pr-label.outputs.is_dry_run != 'true' | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.bump.outputs.version }} | |
| build_date: ${{ steps.info.outputs.build_date }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get last version from GitHub releases | |
| id: last_version | |
| run: | | |
| # Try to get the latest release tag from GitHub | |
| LAST_TAG=$(gh release list --limit 1 --json tagName --jq '.[0].tagName' 2>/dev/null || echo "") | |
| if [ -z "$LAST_TAG" ]; then | |
| # No releases yet, start at 0.0.0 | |
| LAST_VERSION="0.0.0" | |
| else | |
| # Remove 'v' prefix from tag | |
| LAST_VERSION="${LAST_TAG#v}" | |
| fi | |
| echo "last_version=$LAST_VERSION" >> $GITHUB_OUTPUT | |
| echo "Last published version: $LAST_VERSION" | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| - name: Bump version | |
| id: bump | |
| run: | | |
| LAST_VERSION="${{ steps.last_version.outputs.last_version }}" | |
| BUMP_TYPE="${{ needs.check-pr-label.outputs.bump_type }}" | |
| # Parse version | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "$LAST_VERSION" | |
| # Bump based on type | |
| case "$BUMP_TYPE" in | |
| major) | |
| MAJOR=$((MAJOR + 1)) | |
| MINOR=0 | |
| PATCH=0 | |
| ;; | |
| minor) | |
| MINOR=$((MINOR + 1)) | |
| PATCH=0 | |
| ;; | |
| patch) | |
| PATCH=$((PATCH + 1)) | |
| ;; | |
| esac | |
| NEW_VERSION="$MAJOR.$MINOR.$PATCH" | |
| echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| echo "New version: $NEW_VERSION (bumped $BUMP_TYPE from $LAST_VERSION)" | |
| - name: Get build info | |
| id: info | |
| run: | | |
| echo "build_date=$(date -u +%Y-%m-%d)" >> $GITHUB_OUTPUT | |
| build: | |
| name: Build Binaries | |
| needs: [check-pr-label, version] | |
| if: always() && needs.check-pr-label.result == 'success' | |
| # Use matrix to build on native runners for each platform because SQLite requires CGO, | |
| # which needs platform-specific C compilers. Native builds are simpler than cross-compiling. | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| targets: linux-amd64,linux-arm64 | |
| - os: macos-latest | |
| targets: darwin-amd64,darwin-arm64 | |
| - os: windows-latest | |
| targets: windows-amd64 | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.24" | |
| - name: Install cross-compilation tools | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu | |
| - name: Build Linux binaries | |
| if: runner.os == 'Linux' | |
| env: | |
| VERSION: ${{ needs.check-pr-label.outputs.is_dry_run == 'true' && 'dry-run' || needs.version.outputs.version }} | |
| BUILD_DATE: ${{ needs.check-pr-label.outputs.is_dry_run == 'true' && '2000-01-01' || needs.version.outputs.build_date }} | |
| run: | | |
| mkdir -p dist/linux-amd64 dist/linux-arm64 | |
| # Linux amd64 (static build for compatibility with any libc) | |
| GOOS=linux GOARCH=amd64 CGO_ENABLED=1 \ | |
| CGO_CFLAGS="-DSQLITE_ENABLE_FTS5" \ | |
| CGO_LDFLAGS="-lm" \ | |
| go build -ldflags "-X main.Version=${VERSION} -X main.BuildDate=${BUILD_DATE} -linkmode external -extldflags '-static'" \ | |
| -o dist/linux-amd64/github-brain | |
| # Linux arm64 (static build for compatibility with any libc) | |
| GOOS=linux GOARCH=arm64 CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc \ | |
| CGO_CFLAGS="-DSQLITE_ENABLE_FTS5" \ | |
| CGO_LDFLAGS="-lm" \ | |
| go build -ldflags "-X main.Version=${VERSION} -X main.BuildDate=${BUILD_DATE} -linkmode external -extldflags '-static'" \ | |
| -o dist/linux-arm64/github-brain | |
| - name: Build macOS binaries | |
| if: runner.os == 'macOS' | |
| env: | |
| VERSION: ${{ needs.check-pr-label.outputs.is_dry_run == 'true' && 'dry-run' || needs.version.outputs.version }} | |
| BUILD_DATE: ${{ needs.check-pr-label.outputs.is_dry_run == 'true' && '2000-01-01' || needs.version.outputs.build_date }} | |
| run: | | |
| mkdir -p dist/darwin-amd64 dist/darwin-arm64 | |
| # macOS amd64 | |
| GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 \ | |
| CGO_CFLAGS="-DSQLITE_ENABLE_FTS5" \ | |
| go build -ldflags "-X main.Version=${VERSION} -X main.BuildDate=${BUILD_DATE}" \ | |
| -o dist/darwin-amd64/github-brain | |
| # macOS arm64 | |
| GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 \ | |
| CGO_CFLAGS="-DSQLITE_ENABLE_FTS5" \ | |
| go build -ldflags "-X main.Version=${VERSION} -X main.BuildDate=${BUILD_DATE}" \ | |
| -o dist/darwin-arm64/github-brain | |
| - name: Build Windows binaries | |
| if: runner.os == 'Windows' | |
| env: | |
| VERSION: ${{ needs.check-pr-label.outputs.is_dry_run == 'true' && 'dry-run' || needs.version.outputs.version }} | |
| BUILD_DATE: ${{ needs.check-pr-label.outputs.is_dry_run == 'true' && '2000-01-01' || needs.version.outputs.build_date }} | |
| shell: pwsh | |
| run: | | |
| New-Item -ItemType Directory -Force -Path dist/windows-amd64 | |
| $env:CGO_ENABLED = "1" | |
| $env:CGO_CFLAGS = "-DSQLITE_ENABLE_FTS5" | |
| go build -ldflags "-X main.Version=$env:VERSION -X main.BuildDate=$env:BUILD_DATE" -o dist/windows-amd64/github-brain.exe | |
| - name: Create Linux archives | |
| if: runner.os == 'Linux' | |
| run: | | |
| cd dist | |
| tar -czf github-brain-linux-amd64.tar.gz -C linux-amd64 github-brain | |
| tar -czf github-brain-linux-arm64.tar.gz -C linux-arm64 github-brain | |
| rm -rf linux-amd64 linux-arm64 | |
| - name: Create macOS archives | |
| if: runner.os == 'macOS' | |
| run: | | |
| cd dist | |
| tar -czf github-brain-darwin-amd64.tar.gz -C darwin-amd64 github-brain | |
| tar -czf github-brain-darwin-arm64.tar.gz -C darwin-arm64 github-brain | |
| rm -rf darwin-amd64 darwin-arm64 | |
| - name: Create Windows archive | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| cd dist | |
| Compress-Archive -Path windows-amd64/github-brain.exe -DestinationPath "github-brain-windows-amd64.zip" | |
| Remove-Item -Recurse -Force windows-amd64 | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: binaries-${{ runner.os }} | |
| path: dist/* | |
| retention-days: 1 | |
| release: | |
| name: Create GitHub Release | |
| needs: [check-pr-label, version, build] | |
| if: needs.check-pr-label.outputs.is_dry_run != 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| pattern: binaries-* | |
| merge-multiple: true | |
| - name: Generate checksums | |
| run: | | |
| cd dist | |
| sha256sum * > SHA256SUMS.txt | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ needs.version.outputs.version }} | |
| name: v${{ needs.version.outputs.version }} | |
| body: | | |
| **Version:** ${{ needs.version.outputs.version }} | |
| **Built:** ${{ needs.version.outputs.build_date }} | |
| **Install via NPM:** | |
| ```bash | |
| npm install -g github-brain | |
| ``` | |
| **Manual download:** | |
| - macOS (Intel): `github-brain-darwin-amd64.tar.gz` | |
| - macOS (Apple Silicon): `github-brain-darwin-arm64.tar.gz` | |
| - Linux (x86_64): `github-brain-linux-amd64.tar.gz` | |
| - Linux (ARM64): `github-brain-linux-arm64.tar.gz` | |
| - Windows: `github-brain-windows-amd64.zip` | |
| Verify with `SHA256SUMS.txt` | |
| files: | | |
| dist/*.tar.gz | |
| dist/*.zip | |
| dist/SHA256SUMS.txt | |
| draft: false | |
| prerelease: false | |
| make_latest: true | |
| publish-npm: | |
| name: Publish to NPM | |
| needs: [check-pr-label, version, build, release] | |
| if: needs.check-pr-label.outputs.is_dry_run != 'true' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "24" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Update npm to support trusted publishing | |
| run: npm install -g npm@latest | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| pattern: binaries-* | |
| - name: Prepare platform packages | |
| run: | | |
| VERSION="${{ needs.version.outputs.version }}" | |
| echo "Preparing packages with version $VERSION" | |
| # Extract binaries from archives and place in npm packages | |
| cd artifacts | |
| # macOS ARM64 | |
| mkdir -p ../npm/darwin-arm64 | |
| tar -xzf binaries-macOS/github-brain-darwin-arm64.tar.gz -C ../npm/darwin-arm64/ | |
| # macOS x64 | |
| mkdir -p ../npm/darwin-x64 | |
| tar -xzf binaries-macOS/github-brain-darwin-amd64.tar.gz -C ../npm/darwin-x64/ | |
| # Linux ARM64 | |
| mkdir -p ../npm/linux-arm64 | |
| tar -xzf binaries-Linux/github-brain-linux-arm64.tar.gz -C ../npm/linux-arm64/ | |
| # Linux x64 | |
| mkdir -p ../npm/linux-x64 | |
| tar -xzf binaries-Linux/github-brain-linux-amd64.tar.gz -C ../npm/linux-x64/ | |
| # Windows x64 | |
| mkdir -p ../npm/windows | |
| unzip -j binaries-Windows/github-brain-windows-amd64.zip -d ../npm/windows/ | |
| cd .. | |
| # Update version in all package.json files (using perl for cross-platform compatibility) | |
| for pkg in package.json npm/*/package.json; do | |
| perl -pi -e "s/\"version\": \"0\.0\.0\"/\"version\": \"$VERSION\"/" "$pkg" | |
| done | |
| # Update optionalDependencies versions in main package.json | |
| perl -pi -e "s/\"github-brain-(darwin-arm64|darwin-x64|linux-arm64|linux-x64|windows)\": \"0\.0\.0\"/\"github-brain-\$1\": \"$VERSION\"/g" package.json | |
| - name: Publish platform packages | |
| run: | | |
| for dir in npm/darwin-arm64 npm/darwin-x64 npm/linux-arm64 npm/linux-x64 npm/windows; do | |
| cd "$dir" | |
| npm publish | |
| cd ../.. | |
| done | |
| - name: Publish main package | |
| run: npm publish |