-
Notifications
You must be signed in to change notification settings - Fork 5
108 lines (87 loc) · 2.92 KB
/
build-cli.yml
File metadata and controls
108 lines (87 loc) · 2.92 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
name: CLI CI/CD
on:
push:
branches: ['main']
paths: ['src/cli/**', '.github/workflows/**']
pull_request:
branches: ['main']
paths: ['src/cli/**', '.github/workflows/**']
workflow_dispatch:
release:
types: [published]
permissions:
contents: write
jobs:
build:
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: linux-amd64
asset_name: chithi-cli-linux-amd64
- os: ubuntu-24.04-arm
target: linux-arm64
asset_name: chithi-cli-linux-arm64
- os: windows-latest
target: windows-amd64
asset_name: chithi-cli-windows-amd64.exe
- os: windows-11-arm
target: windows-arm64
asset_name: chithi-cli-windows-arm64.exe
- os: macos-15-intel
target: macos-amd64
asset_name: chithi-cli-macos-amd64
- os: macos-latest
target: macos-arm64
asset_name: chithi-cli-macos-arm64
defaults:
run:
working-directory: ./src/cli
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install dependencies
run: uv sync --frozen
- name: Build Binary
run: uv run python build.py --output ${{ matrix.asset_name }}
- name: Package macOS app
if: startsWith(matrix.target, 'macos')
run: |
# Define the binary and the app structure
BINARY_NAME="${{ matrix.asset_name }}"
APP_NAME="${BINARY_NAME}.app"
# Create the macOS App Bundle structure
mkdir -p "${APP_NAME}/Contents/MacOS"
# Move the generated binary into the bundle
mv "$BINARY_NAME" "${APP_NAME}/Contents/MacOS/"
# Zip the bundle
zip -r "${BINARY_NAME}.zip" "$APP_NAME"
- name: Upload CI Artifact
uses: actions/upload-artifact@v7
with:
name: cli-${{ matrix.target }}
path: |
src/cli/${{ matrix.asset_name }}
src/cli/${{ matrix.asset_name }}.zip
if-no-files-found: error
- name: Test CLI
shell: bash
run: |
if [[ "${{ matrix.target }}" == macos* ]]; then
./${{ matrix.asset_name }}.app/Contents/MacOS/${{ matrix.asset_name }} --help || { echo 'CLI failed'; exit 1; }
else
chmod +x ./${{ matrix.asset_name }} || true
./${{ matrix.asset_name }} --help || { echo 'CLI failed'; exit 1; }
fi
- name: Upload to GitHub Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
src/cli/${{ matrix.asset_name }}
src/cli/${{ matrix.asset_name }}.zip