Skip to content

Commit da1247b

Browse files
authored
build: Add a mac arm build (#255)
* add a mac arm build * Add release workflow for arm
1 parent 29fc9bb commit da1247b

File tree

2 files changed

+131
-1
lines changed

2 files changed

+131
-1
lines changed

.github/workflows/release.yml

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,83 @@ jobs:
265265
run: |
266266
gh release upload ${{ steps.prep.outputs.version }} testcafe-macos-amd64.zip
267267
268+
release-macos-arm-bundle:
269+
runs-on: macos-latest
270+
needs: [create-release-draft]
271+
steps:
272+
- name: Find matching draft tag
273+
# Fetches the `asset_id` of the uploaded bundle. A non-empty `asset_id` signals a successful upload, preventing duplicate uploads in retry attempts.
274+
id: prep
275+
run: |
276+
VERSION=$(curl -s -H "Authorization: token ${{ github.token }}" \
277+
https://api.github.com/repos/${{ github.repository }}/releases | \
278+
jq -r "[.[] | select(.draft == true) | select(.body | contains(\"- jobId: ${{ github.run_id }}\\n\"))] | first | .tag_name")
279+
RELEASE_ID=$(curl -s -H "Authorization: token ${{ github.token }}" \
280+
https://api.github.com/repos/${{ github.repository }}/releases | \
281+
jq -r "[.[] | select(.draft == true) | select(.body | contains(\"- jobId: ${{ github.run_id }}\\n\"))] | first | .id")
282+
283+
if [ "${VERSION}" = "" ];then
284+
echo "No draft version found"
285+
exit 1
286+
fi
287+
288+
ASSET_ID=$(curl -s -H "Authorization: token ${{ github.token }}" \
289+
https://api.github.com/repos/${{ github.repository }}/releases | \
290+
jq -r "[.[] | select(.body | contains(\"- jobId: ${{ github.run_id }}\\n\"))] | first | .assets | .[] | select(.name == \"testcafe-macos-arm64.zip\") | .id | select(. != null)")
291+
292+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
293+
echo "release_id=${RELEASE_ID}" >> $GITHUB_OUTPUT
294+
echo "asset_id=${ASSET_ID}" >> $GITHUB_OUTPUT
295+
296+
- run: echo "${{ steps.prep.outputs.release_id }} - ${{ steps.prep.outputs.version }} - ${{ steps.prep.outputs.asset_id }}"
297+
298+
- name: Checkout
299+
uses: actions/checkout@v4
300+
if: ${{ steps.prep.outputs.asset_id == '' }}
301+
with:
302+
ref: ${{ steps.prep.outputs.version }}
303+
304+
- name: Setup Node
305+
if: ${{ steps.prep.outputs.asset_id == '' }}
306+
uses: actions/setup-node@v4
307+
with:
308+
node-version-file: ".nvmrc"
309+
cache: "npm"
310+
311+
- name: Update Release version
312+
if: ${{ steps.prep.outputs.asset_id == '' }}
313+
run: |
314+
npm version --no-git-tag-version ${{ steps.prep.outputs.version }}
315+
316+
- name: Install Dependencies
317+
run: npm ci --production
318+
env:
319+
HUSKY: 0
320+
if: ${{ steps.prep.outputs.asset_id == '' }}
321+
322+
- name: Bundle Directory
323+
if: ${{ steps.prep.outputs.asset_id == '' }}
324+
run: bash ./scripts/bundle.sh
325+
326+
- name: List Bundle Contents
327+
if: ${{ steps.prep.outputs.asset_id == '' }}
328+
run: ls -R bundle/
329+
330+
- name: Archive Bundle
331+
if: ${{ steps.prep.outputs.asset_id == '' }}
332+
run: zip -r testcafe-macos-arm64.zip bundle/
333+
334+
- name: Upload Release Asset
335+
if: ${{ steps.prep.outputs.asset_id == '' }}
336+
env:
337+
GITHUB_TOKEN: ${{ github.token }}
338+
run: |
339+
gh release upload ${{ steps.prep.outputs.version }} testcafe-macos-arm64.zip
340+
341+
268342
publish-release:
269343
runs-on: ubuntu-latest
270-
needs: [release-windows-bundle, release-macos-bundle]
344+
needs: [release-windows-bundle, release-macos-bundle, release-macos-arm-bundle]
271345
steps:
272346
- name: Find Matching Draft Tag
273347
id: prep

.github/workflows/test.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,62 @@ jobs:
164164
run: |
165165
gsutil cp ./testcafe-macos-amd64.zip gs://${{ secrets.GCS_RUNNER_BUCKET }}/testcafe-macos-amd64-${{ github.run_id }}.zip
166166
167+
build-mac-arm-bundle:
168+
runs-on: macos-latest
169+
needs: [test]
170+
steps:
171+
- name: Checkout
172+
uses: actions/checkout@v4
173+
174+
- name: Setup Node
175+
uses: actions/setup-node@v4
176+
with:
177+
node-version-file: ".nvmrc"
178+
cache: "npm"
179+
180+
- name: Setup Python
181+
uses: actions/setup-python@v5
182+
with:
183+
python-version: '3.11'
184+
185+
- name: Google Cloud Login
186+
id: 'auth'
187+
uses: google-github-actions/auth@v2
188+
with:
189+
credentials_json: '${{ secrets.GCS_RUNNER_SA_KEY }}'
190+
191+
- name: Install gcloud SDK
192+
uses: google-github-actions/setup-gcloud@v2
193+
with:
194+
project_id: ${{ secrets.GCS_RUNNER_PROJECT_ID }}
195+
196+
- name: Update Release version
197+
run: npm version --no-git-tag-version 1.0.0
198+
199+
- name: Install Dependencies
200+
run: npm ci --production
201+
env:
202+
HUSKY: 0
203+
204+
- name: Build
205+
run: npm run build
206+
207+
# - uses: FedericoCarboni/setup-ffmpeg@v3
208+
# if: ${{ steps.prep.outputs.asset_id == '' }}
209+
# id: setup-ffmpeg
210+
# with:
211+
# token: ${{ github.token }}
212+
213+
- name: Bundle Directory
214+
run: bash ./scripts/bundle.sh
215+
216+
- name: Archive Bundle
217+
run: zip -r testcafe-macos-arm64.zip bundle/
218+
219+
- name: Upload to GCS
220+
run: |
221+
gsutil cp ./testcafe-macos-arm64.zip gs://${{ secrets.GCS_RUNNER_BUCKET }}/testcafe-macos-arm64-${{ github.run_id }}.zip
222+
167223
bundle-test:
168224
needs: [build-windows-bundle, build-mac-bundle]
169225
strategy:

0 commit comments

Comments
 (0)