Skip to content

Commit ff46fbc

Browse files
committed
build action
1 parent f57e3ed commit ff46fbc

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Build sry CLI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'src/sry/**'
8+
- '.github/workflows/sry-build.yml'
9+
pull_request:
10+
paths:
11+
- 'src/sry/**'
12+
- '.github/workflows/sry-build.yml'
13+
workflow_dispatch:
14+
15+
concurrency:
16+
group: sry-${{ github.ref_name || github.sha }}
17+
cancel-in-progress: true
18+
19+
defaults:
20+
run:
21+
shell: bash
22+
working-directory: src/sry
23+
24+
permissions:
25+
contents: read
26+
27+
jobs:
28+
build:
29+
name: Build
30+
runs-on: ubuntu-latest
31+
environment: ${{ github.event_name == 'push' && github.ref_name == 'main' && 'Production' || 'Preview' }}
32+
steps:
33+
- uses: actions/checkout@v4
34+
35+
- name: Setup Bun
36+
uses: oven-sh/setup-bun@v2
37+
with:
38+
bun-version: latest
39+
40+
- name: Install dependencies
41+
run: bun install
42+
43+
- name: Setup Codesign Dependencies
44+
if: github.event_name == 'push' && github.ref_name == 'main'
45+
env:
46+
APPLE_CERT_DATA: ${{ secrets.CSC_LINK }}
47+
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
48+
run: |
49+
curl -L 'https://github.com/indygreg/apple-platform-rs/releases/download/apple-codesign%2F0.29.0/apple-codesign-0.29.0-x86_64-unknown-linux-musl.tar.gz' -o 'rcodesign.tar.gz'
50+
echo 'dbe85cedd8ee4217b64e9a0e4c2aef92ab8bcaaa41f20bde99781ff02e600002 rcodesign.tar.gz' | sha256sum -c
51+
tar -xzf rcodesign.tar.gz --strip-components=1
52+
sudo mv rcodesign /usr/local/bin/rcodesign
53+
rm rcodesign.tar.gz
54+
# Export certs
55+
echo "$APPLE_CERT_DATA" | base64 --decode > /tmp/certs.p12
56+
echo 'APPLE_CERT_PATH=/tmp/certs.p12' >> $GITHUB_ENV
57+
echo "$APPLE_API_KEY" | base64 -d > /tmp/apple_key.json
58+
cat /tmp/apple_key.json | jq .private_key -r > /tmp/apple_key.pem
59+
echo "APPLE_API_KEY_ISSUER_ID=$(cat /tmp/apple_key.json | jq .issuer_id -r | tr -d '\n\r')" >> $GITHUB_ENV
60+
echo "APPLE_API_KEY_ID=$(cat /tmp/apple_key.json | jq .key_id -r | tr -d '\n\r')" >> $GITHUB_ENV
61+
echo "APPLE_API_KEY_P8_PATH=/tmp/apple_key.pem" >> $GITHUB_ENV
62+
echo 'APPLE_API_KEY_PATH=/tmp/apple_key.json' >> $GITHUB_ENV
63+
64+
- name: Build binaries
65+
env:
66+
APPLE_CERT_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
67+
APPLE_TEAM_ID: ${{ vars.TEAMID }}
68+
FOSSILIZE_PLATFORMS: linux-x64,linux-arm64,win-x64,darwin-x64,darwin-arm64
69+
FOSSILIZE_SIGN: ${{ github.event_name == 'push' && github.ref_name == 'main' && 'y' || 'n' }}
70+
run: bun run build:all
71+
72+
- name: Smoke test
73+
env:
74+
SRY_BINARY: ${{ github.workspace }}/src/sry/dist-bin/sry-${{ runner.os }}-${{ runner.arch }}
75+
run: |
76+
# Lowercase the binary name because runner.os and runner.arch are uppercase
77+
SRY_BINARY=$(echo "$SRY_BINARY" | tr '[:upper:]' '[:lower:]')
78+
[ -f "$SRY_BINARY" ]
79+
$SRY_BINARY --help && echo "sry binary ran successfully"
80+
81+
- name: Upload binaries
82+
uses: actions/upload-artifact@v4
83+
with:
84+
name: sry-binaries
85+
if-no-files-found: error
86+
path: src/sry/dist-bin/sry-*
87+

0 commit comments

Comments
 (0)