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