ReviewOS

also looking at this

stacks/ts-pantry

chore(deps): update dependency actions/checkout to v6.0.2

#782
Closed chris wants to merge buddy-bot/update-major-update---actions/checkout-1766052450047 into main
3 files +8 -8

Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.

.github/workflows/build-binaries.ymladded+293-0
Changes to .github/workflows/build-binaries.yml
@@ -0,0 +1,293 @@
1name: Build Package Binaries
2
3on:
4 workflow_dispatch:
5 inputs:
6 package:
7 description: 'Package domain to build'
8 required: true
9 type: choice
10 options:
11 - php.net
12 - postgresql.org
13 - redis.io
14 version:
15 description: 'Version to build (leave empty for latest from pantry)'
16 required: false
17 type: string
18 platforms:
19 description: 'Platforms to build'
20 required: true
21 type: choice
22 default: 'all'
23 options:
24 - all
25 - darwin-arm64
26 - darwin-x86-64
27 - linux-x86-64
28
29env:
30 AWS_REGION: us-east-1
31 S3_BUCKET: pantry-registry
32
33jobs:
34 prepare:
35 name: Prepare build
36 runs-on: ubuntu-latest
37 outputs:
38 version: ${{ steps.version.outputs.version }}
39 matrix: ${{ steps.matrix.outputs.matrix }}
40 steps:
41 - name: Checkout repository
42 uses: actions/checkout@v6.0.1
43
44 - name: Setup Bun
45 uses: oven-sh/setup-bun@v2
46 with:
47 bun-version: latest
48
49 - name: Install dependencies
50 run: bun install
51
52 - name: Determine version
53 id: version
54 run: |
55 PACKAGE="${⁠{ github.event.inputs.package }}"
56 INPUT_VERSION="${⁠{ github.event.inputs.version }}"
57
58 if [ -n "$INPUT_VERSION" ]; then
59 VERSION="$INPUT_VERSION"
60 else
61 # Convert package domain to filename (php.net -> phpnet.ts)
62 PACKAGE_FILE="src/packages/${PACKAGE//./}net.ts"
63
64 # Try different naming patterns
65 if [ ! -f "$PACKAGE_FILE" ]; then
66 PACKAGE_FILE="src/packages/${PACKAGE//./-}.ts"
67 fi
68 if [ ! -f "$PACKAGE_FILE" ]; then
69 PACKAGE_FILE="src/packages/${PACKAGE//./}.ts"
70 fi
71
72 # Extract version from the versions array in the TypeScript file
73 if [ -f "$PACKAGE_FILE" ]; then
74 VERSION=$(grep -A1 "versions:" "$PACKAGE_FILE" | grep -oE "'[0-9]+\.[0-9]+\.[0-9]+'" | head -1 | tr -d "'")
75 fi
76
77 if [ -z "$VERSION" ]; then
78 echo "Could not determine version from $PACKAGE_FILE, please specify manually"
79 exit 1
80 fi
81 fi
82
83 echo "version=$VERSION" >> $GITHUB_OUTPUT
84 echo "Building $PACKAGE version $VERSION"
85
86 - name: Set build matrix
87 id: matrix
88 run: |
89 PLATFORMS="${⁠{ github.event.inputs.platforms }}"
90
91 if [ "$PLATFORMS" = "all" ]; then
92 MATRIX='{"include":[{"os":"macos-14","platform":"darwin-arm64"},{"os":"macos-13","platform":"darwin-x86-64"},{"os":"ubuntu-latest","platform":"linux-x86-64"}]}'
93 elif [ "$PLATFORMS" = "darwin-arm64" ]; then
94 MATRIX='{"include":[{"os":"macos-14","platform":"darwin-arm64"}]}'
95 elif [ "$PLATFORMS" = "darwin-x86-64" ]; then
96 MATRIX='{"include":[{"os":"macos-13","platform":"darwin-x86-64"}]}'
97 elif [ "$PLATFORMS" = "linux-x86-64" ]; then
98 MATRIX='{"include":[{"os":"ubuntu-latest","platform":"linux-x86-64"}]}'
99 fi
100
101 echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
102
103 build:
104 name: Build ${{ github.event.inputs.package }} (${{ matrix.platform }})
105 needs: prepare
106 strategy:
107 fail-fast: false
108 matrix: ${{ fromJson(needs.prepare.outputs.matrix) }}
109 runs-on: ${{ matrix.os }}
110
111 steps:
112 - name: Checkout repository
113 uses: actions/checkout@v6.0.1
114
115 - name: Setup Bun
116 uses: oven-sh/setup-bun@v2
117 with:
118 bun-version: latest
119
120 - name: Install dependencies
121 run: bun install
122
123 - name: Install build tools (macOS)
124 if: contains(matrix.platform, 'darwin')
125 run: |
126 brew install autoconf automake libtool pkg-config bison re2c
127
128 # For PHP with pdo-pgsql
129 if [ "${⁠{ github.event.inputs.package }}" = "php.net" ]; then
130 brew install postgresql openssl@1.1 libsodium libzip oniguruma sqlite icu4c \
131 freetype libpng webp jpeg curl libxml2 libxslt readline gettext gmp libiconv krb5
132 fi
133
134 # For PostgreSQL
135 if [ "${⁠{ github.event.inputs.package }}" = "postgresql.org" ]; then
136 brew install openssl readline zlib lz4 libxml2 libxslt icu4c flex perl
137 fi
138
139 # For Redis
140 if [ "${⁠{ github.event.inputs.package }}" = "redis.io" ]; then
141 brew install openssl
142 fi
143
144 - name: Install build tools (Linux)
145 if: contains(matrix.platform, 'linux')
146 run: |
147 sudo apt-get update
148 sudo apt-get install -y build-essential autoconf automake libtool pkg-config
149
150 # For PHP with pdo-pgsql and pdo-mysql
151 if [ "${⁠{ github.event.inputs.package }}" = "php.net" ]; then
152 sudo apt-get install -y \
153 bison re2c \
154 libssl-dev libsodium-dev libzip-dev libonig-dev \
155 libsqlite3-dev libicu-dev libfreetype6-dev libpng-dev \
156 libwebp-dev libjpeg-dev libcurl4-openssl-dev libxml2-dev \
157 libxslt1-dev libedit-dev libffi-dev libpq-dev \
158 libreadline-dev libgmp-dev libkrb5-dev libbz2-dev \
159 default-libmysqlclient-dev liblz4-dev
160 fi
161
162 # For PostgreSQL
163 if [ "${⁠{ github.event.inputs.package }}" = "postgresql.org" ]; then
164 sudo apt-get install -y \
165 libssl-dev libreadline-dev zlib1g-dev liblz4-dev \
166 libxml2-dev libxslt1-dev libicu-dev flex bison perl
167 fi
168
169 # For Redis
170 if [ "${⁠{ github.event.inputs.package }}" = "redis.io" ]; then
171 sudo apt-get install -y libssl-dev
172 fi
173
174 - name: Build package
175 id: build
176 run: |
177 PACKAGE="${⁠{ github.event.inputs.package }}"
178 VERSION="${⁠{ needs.prepare.outputs.version }}"
179 PLATFORM="${⁠{ matrix.platform }}"
180
181 # Create directories
182 BUILD_DIR="${⁠{ runner.temp }}/build-${PACKAGE}-${VERSION}"
183 INSTALL_PREFIX="${⁠{ runner.temp }}/install-${PACKAGE}-${VERSION}"
184 mkdir -p "$BUILD_DIR" "$INSTALL_PREFIX"
185
186 echo "Building $PACKAGE $VERSION for $PLATFORM"
187 echo "Build directory: $BUILD_DIR"
188 echo "Install prefix: $INSTALL_PREFIX"
189
190 # Run the build script
191 bun scripts/build-package.ts \
192 --package "$PACKAGE" \
193 --version "$VERSION" \
194 --platform "$PLATFORM" \
195 --build-dir "$BUILD_DIR" \
196 --prefix "$INSTALL_PREFIX"
197
198 echo "install_prefix=$INSTALL_PREFIX" >> $GITHUB_OUTPUT
199
200 - name: Package artifacts
201 id: package
202 run: |
203 PACKAGE="${⁠{ github.event.inputs.package }}"
204 VERSION="${⁠{ needs.prepare.outputs.version }}"
205 PLATFORM="${⁠{ matrix.platform }}"
206 INSTALL_PREFIX="${⁠{ steps.build.outputs.install_prefix }}"
207
208 # Create tarball name matching S3 structure
209 SAFE_NAME="${PACKAGE//./-}"
210 ARTIFACT_NAME="${SAFE_NAME}-${VERSION}-${PLATFORM}"
211 ARTIFACT_PATH="${⁠{ runner.temp }}/${ARTIFACT_NAME}.tar.gz"
212
213 cd "$INSTALL_PREFIX"
214 tar -czvf "$ARTIFACT_PATH" .
215
216 # Generate SHA256
217 if [ "${⁠{ matrix.platform }}" = "darwin-arm64" ] || [ "${⁠{ matrix.platform }}" = "darwin-x86-64" ]; then
218 shasum -a 256 "$ARTIFACT_PATH" > "${ARTIFACT_PATH}.sha256"
219 else
220 sha256sum "$ARTIFACT_PATH" > "${ARTIFACT_PATH}.sha256"
221 fi
222
223 echo "artifact_path=$ARTIFACT_PATH" >> $GITHUB_OUTPUT
224 echo "artifact_name=$ARTIFACT_NAME" >> $GITHUB_OUTPUT
225
226 echo "Created artifact: $ARTIFACT_NAME"
227 ls -la "$ARTIFACT_PATH" "${ARTIFACT_PATH}.sha256"
228
229 - name: Upload build artifact
230 uses: actions/upload-artifact@v4
231 with:
232 name: ${{ steps.package.outputs.artifact_name }}
233 path: |
234 ${{ steps.package.outputs.artifact_path }}
235 ${{ steps.package.outputs.artifact_path }}.sha256
236 retention-days: 7
237
238 upload-to-s3:
239 name: Upload to S3
240 needs: [prepare, build]
241 runs-on: ubuntu-latest
242
243 steps:
244 - name: Checkout repository
245 uses: actions/checkout@v6.0.1
246
247 - name: Setup Bun
248 uses: oven-sh/setup-bun@v2
249 with:
250 bun-version: latest
251
252 - name: Install dependencies
253 run: bun install
254
255 - name: Download all artifacts
256 uses: actions/download-artifact@v4
257 with:
258 path: artifacts
259
260 - name: Upload to S3
261 env:
262 AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
263 AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
264 run: |
265 PACKAGE="${⁠{ github.event.inputs.package }}"
266 VERSION="${⁠{ needs.prepare.outputs.version }}"
267
268 echo "Uploading $PACKAGE $VERSION to S3"
269
270 bun scripts/upload-to-s3.ts \
271 --package "$PACKAGE" \
272 --version "$VERSION" \
273 --artifacts-dir "./artifacts" \
274 --bucket "$S3_BUCKET" \
275 --region "$AWS_REGION"
276
277 - name: Summary
278 run: |
279 PACKAGE="${⁠{ github.event.inputs.package }}"
280 VERSION="${⁠{ needs.prepare.outputs.version }}"
281
282 echo "## Build Complete" >> $GITHUB_STEP_SUMMARY
283 echo "" >> $GITHUB_STEP_SUMMARY
284 echo "**Package:** $PACKAGE" >> $GITHUB_STEP_SUMMARY
285 echo "**Version:** $VERSION" >> $GITHUB_STEP_SUMMARY
286 echo "" >> $GITHUB_STEP_SUMMARY
287 echo "### Uploaded to S3" >> $GITHUB_STEP_SUMMARY
288 echo "" >> $GITHUB_STEP_SUMMARY
289
290 for artifact_dir in artifacts/*/; do
291 artifact_name=$(basename "$artifact_dir")
292 echo "- \`$artifact_name\`" >> $GITHUB_STEP_SUMMARY
293 done