|
| 1 | +name: Release Binaries |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, install-sh] |
| 6 | + paths: |
| 7 | + - 'package.json' |
| 8 | + - '.github/workflows/release-binaries.yml' |
| 9 | + - 'nfpm.yaml' |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + check-version: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + name: Check for version bump |
| 19 | + outputs: |
| 20 | + version: ${{ steps.check.outputs.version }} |
| 21 | + released: ${{ steps.check.outputs.released }} |
| 22 | + dry_run: ${{ steps.check.outputs.dry_run }} |
| 23 | + steps: |
| 24 | + - name: Checkout repository |
| 25 | + uses: actions/checkout@v6 |
| 26 | + with: |
| 27 | + fetch-depth: 0 |
| 28 | + |
| 29 | + - name: Check if version tag exists |
| 30 | + id: check |
| 31 | + run: | |
| 32 | + VERSION=$(node -p "require('./package.json').version") |
| 33 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 34 | +
|
| 35 | + # Dry run on non-main branches |
| 36 | + if [ "${{ github.ref_name }}" != "main" ]; then |
| 37 | + echo "dry_run=true" >> "$GITHUB_OUTPUT" |
| 38 | + echo "released=false" >> "$GITHUB_OUTPUT" |
| 39 | + echo "Dry run on branch ${{ github.ref_name }} — will build but not release" |
| 40 | + elif git rev-parse "v$VERSION" >/dev/null 2>&1; then |
| 41 | + echo "dry_run=false" >> "$GITHUB_OUTPUT" |
| 42 | + echo "released=true" >> "$GITHUB_OUTPUT" |
| 43 | + echo "v$VERSION already released — skipping" |
| 44 | + else |
| 45 | + echo "dry_run=false" >> "$GITHUB_OUTPUT" |
| 46 | + echo "released=false" >> "$GITHUB_OUTPUT" |
| 47 | + echo "New version detected: v$VERSION" |
| 48 | + fi |
| 49 | +
|
| 50 | + build: |
| 51 | + needs: check-version |
| 52 | + if: needs.check-version.outputs.released == 'false' |
| 53 | + strategy: |
| 54 | + matrix: |
| 55 | + include: |
| 56 | + - os: ubuntu-latest |
| 57 | + target: bun-linux-x64 |
| 58 | + binary: firecrawl-linux-x64 |
| 59 | + - os: ubuntu-latest |
| 60 | + target: bun-linux-arm64 |
| 61 | + binary: firecrawl-linux-arm64 |
| 62 | + - os: macos-latest |
| 63 | + target: bun-darwin-arm64 |
| 64 | + binary: firecrawl-darwin-arm64 |
| 65 | + - os: macos-latest |
| 66 | + target: bun-darwin-x64 |
| 67 | + binary: firecrawl-darwin-x64 |
| 68 | + - os: ubuntu-latest |
| 69 | + target: bun-windows-x64 |
| 70 | + binary: firecrawl-windows-x64.exe |
| 71 | + |
| 72 | + runs-on: ${{ matrix.os }} |
| 73 | + name: Build ${{ matrix.binary }} |
| 74 | + |
| 75 | + steps: |
| 76 | + - name: Checkout repository |
| 77 | + uses: actions/checkout@v6 |
| 78 | + |
| 79 | + - name: Setup Bun |
| 80 | + uses: oven-sh/setup-bun@v2 |
| 81 | + |
| 82 | + - name: Install dependencies |
| 83 | + run: bun install --frozen-lockfile |
| 84 | + |
| 85 | + - name: Build binary |
| 86 | + run: bun build src/index.ts --compile --target=${{ matrix.target }} --outfile ${{ matrix.binary }} |
| 87 | + |
| 88 | + - name: Create tarball (Unix) |
| 89 | + if: "!contains(matrix.binary, 'windows')" |
| 90 | + run: tar -czf ${{ matrix.binary }}.tar.gz ${{ matrix.binary }} |
| 91 | + |
| 92 | + - name: Create zip (Windows) |
| 93 | + if: contains(matrix.binary, 'windows') |
| 94 | + run: zip ${{ matrix.binary }}.zip ${{ matrix.binary }} |
| 95 | + |
| 96 | + - name: Upload binary artifact |
| 97 | + uses: actions/upload-artifact@v7 |
| 98 | + with: |
| 99 | + name: ${{ matrix.binary }} |
| 100 | + path: | |
| 101 | + ${{ matrix.binary }} |
| 102 | + ${{ matrix.binary }}.tar.gz |
| 103 | + ${{ matrix.binary }}.zip |
| 104 | + if-no-files-found: ignore |
| 105 | + |
| 106 | + release: |
| 107 | + needs: [check-version, build] |
| 108 | + runs-on: ubuntu-latest |
| 109 | + name: Create release and upload assets |
| 110 | + |
| 111 | + steps: |
| 112 | + - name: Checkout repository |
| 113 | + uses: actions/checkout@v6 |
| 114 | + with: |
| 115 | + fetch-depth: 0 |
| 116 | + |
| 117 | + - name: Download all artifacts |
| 118 | + uses: actions/download-artifact@v8 |
| 119 | + with: |
| 120 | + path: artifacts |
| 121 | + |
| 122 | + - name: Collect release files |
| 123 | + run: | |
| 124 | + mkdir -p release binaries |
| 125 | + find artifacts -type f \( -name "*.tar.gz" -o -name "*.zip" \) -exec cp {} release/ \; |
| 126 | + # Copy raw binaries for nfpm packaging |
| 127 | + for dir in artifacts/firecrawl-linux-*/; do |
| 128 | + find "$dir" -type f ! -name "*.tar.gz" ! -name "*.zip" -exec cp {} binaries/ \; |
| 129 | + done |
| 130 | + chmod +x binaries/* |
| 131 | + ls -la release/ |
| 132 | + ls -la binaries/ |
| 133 | +
|
| 134 | + - name: Install nfpm |
| 135 | + run: | |
| 136 | + NFPM_VERSION=$(gh release view --repo goreleaser/nfpm --json tagName --jq '.tagName' | sed 's/^v//') |
| 137 | + curl -sfL "https://github.com/goreleaser/nfpm/releases/download/v${NFPM_VERSION}/nfpm_${NFPM_VERSION}_Linux_x86_64.tar.gz" | tar -xz -C /usr/local/bin nfpm |
| 138 | + nfpm --version |
| 139 | + env: |
| 140 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 141 | + |
| 142 | + - name: Build Linux packages |
| 143 | + run: | |
| 144 | + VERSION="${{ needs.check-version.outputs.version }}" |
| 145 | +
|
| 146 | + # linux amd64 |
| 147 | + export BINARY=binaries/firecrawl-linux-x64 VERSION="$VERSION" ARCH=amd64 |
| 148 | + envsubst < nfpm.yaml > /tmp/nfpm-amd64.yaml |
| 149 | + for fmt in deb rpm apk archlinux; do |
| 150 | + nfpm package --config /tmp/nfpm-amd64.yaml --packager "$fmt" --target release/ |
| 151 | + done |
| 152 | +
|
| 153 | + # linux arm64 |
| 154 | + export BINARY=binaries/firecrawl-linux-arm64 ARCH=arm64 |
| 155 | + envsubst < nfpm.yaml > /tmp/nfpm-arm64.yaml |
| 156 | + for fmt in deb rpm apk archlinux; do |
| 157 | + nfpm package --config /tmp/nfpm-arm64.yaml --packager "$fmt" --target release/ |
| 158 | + done |
| 159 | +
|
| 160 | + ls -la release/ |
| 161 | +
|
| 162 | + - name: Generate checksums |
| 163 | + run: | |
| 164 | + cd release |
| 165 | + sha256sum * > checksums.txt |
| 166 | + cat checksums.txt |
| 167 | +
|
| 168 | + - name: Summary (dry run) |
| 169 | + if: needs.check-version.outputs.dry_run == 'true' |
| 170 | + run: | |
| 171 | + echo "## Dry Run — Release v${{ needs.check-version.outputs.version }}" >> $GITHUB_STEP_SUMMARY |
| 172 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 173 | + echo "All artifacts built and packaged successfully:" >> $GITHUB_STEP_SUMMARY |
| 174 | + echo '```' >> $GITHUB_STEP_SUMMARY |
| 175 | + ls -lh release/ >> $GITHUB_STEP_SUMMARY |
| 176 | + echo '```' >> $GITHUB_STEP_SUMMARY |
| 177 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 178 | + echo "**No release created — this is a dry run on branch \`${{ github.ref_name }}\`.**" >> $GITHUB_STEP_SUMMARY |
| 179 | +
|
| 180 | + - name: Generate release notes |
| 181 | + if: needs.check-version.outputs.dry_run != 'true' |
| 182 | + run: | |
| 183 | + PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") |
| 184 | + if [ -n "$PREV_TAG" ]; then |
| 185 | + git log --pretty=format:"- %s" "$PREV_TAG..HEAD" -- | head -50 > /tmp/release-notes.md |
| 186 | + else |
| 187 | + echo "Initial release" > /tmp/release-notes.md |
| 188 | + fi |
| 189 | +
|
| 190 | + - name: Create tag and GitHub release |
| 191 | + if: needs.check-version.outputs.dry_run != 'true' |
| 192 | + env: |
| 193 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 194 | + run: | |
| 195 | + VERSION="v${{ needs.check-version.outputs.version }}" |
| 196 | + git tag "$VERSION" |
| 197 | + git push origin "$VERSION" |
| 198 | + gh release create "$VERSION" release/* \ |
| 199 | + --repo "${{ github.repository }}" \ |
| 200 | + --title "Firecrawl CLI $VERSION" \ |
| 201 | + --notes-file /tmp/release-notes.md |
0 commit comments