forked from CodebuffAI/codebuff
-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (130 loc) · 4.31 KB
/
cli-release-build.yml
File metadata and controls
142 lines (130 loc) · 4.31 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
name: Build CLI Binary
on:
workflow_call:
inputs:
binary-name:
required: true
type: string
description: 'Name of the CLI binary to build'
new-version:
required: true
type: string
description: 'Version string for the build'
artifact-name:
required: false
type: string
description: 'Optional artifact containing staging metadata'
default: ''
checkout-ref:
required: false
type: string
description: 'Git ref to checkout'
default: ''
env-overrides:
required: false
type: string
description: 'JSON object of environment variable overrides'
default: '{}'
jobs:
build-binaries:
strategy:
matrix:
include:
- os: ubuntu-latest
target: linux-x64
bun_target: bun-linux-x64
platform: linux
arch: x64
- os: ubuntu-latest
target: linux-arm64
bun_target: bun-linux-arm64
platform: linux
arch: arm64
- os: macos-13
target: darwin-x64
bun_target: bun-darwin-x64
platform: darwin
arch: x64
- os: macos-14
target: darwin-arm64
bun_target: bun-darwin-arm64
platform: darwin
arch: arm64
- os: windows-latest
target: win32-x64
bun_target: bun-windows-x64
platform: win32
arch: x64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.checkout-ref || github.sha }}
- name: Download staging metadata
if: inputs.artifact-name != ''
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact-name }}
path: cli/release-staging/
- name: Set up Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: '1.2.16'
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
node_modules
*/node_modules
key: ${{ runner.os }}-deps-${{ hashFiles('**/bun.lockb', '**/package.json') }}
restore-keys: |
${{ runner.os }}-deps-${{ hashFiles('**/bun.lockb') }}
${{ runner.os }}-deps-
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Configure environment variables
env:
SECRETS_CONTEXT: ${{ toJSON(secrets) }}
ENV_OVERRIDES: ${{ inputs.env-overrides }}
shell: bash
run: |
VAR_NAMES=$(node scripts/generate-ci-env.js --prefix NEXT_PUBLIC_)
echo "$SECRETS_CONTEXT" | jq -r --argjson vars "$VAR_NAMES" '
to_entries | .[] | select(.key as $k | $vars | index($k)) | .key + "=" + .value
' >> $GITHUB_ENV
echo "CODEBUFF_GITHUB_ACTIONS=true" >> $GITHUB_ENV
echo "CODEBUFF_GITHUB_TOKEN=${{ secrets.CODEBUFF_GITHUB_TOKEN }}" >> $GITHUB_ENV
if [ "$ENV_OVERRIDES" != "{}" ]; then
echo "$ENV_OVERRIDES" | jq -r 'to_entries | .[] | .key + "=" + .value' >> $GITHUB_ENV
fi
- name: Build binary
run: bun run scripts/build-binary.ts ${{ inputs.binary-name }} ${{ inputs.new-version }}
working-directory: cli
shell: bash
env:
VERBOSE: true
OVERRIDE_TARGET: ${{ matrix.bun_target }}
OVERRIDE_PLATFORM: ${{ matrix.platform }}
OVERRIDE_ARCH: ${{ matrix.arch }}
- name: Smoke test binary
shell: bash
run: |
cd cli/bin
if [[ "${{ runner.os }}" == "Windows" ]]; then
./${{ inputs.binary-name }}.exe --version
else
./${{ inputs.binary-name }} --version
fi
- name: Create tarball
shell: bash
run: |
BINARY_FILE="${{ inputs.binary-name }}"
if [[ "${{ runner.os }}" == "Windows" ]]; then
BINARY_FILE="${{ inputs.binary-name }}.exe"
fi
tar -czf codebuff-cli-${{ matrix.target }}.tar.gz -C cli/bin "$BINARY_FILE"
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: codebuff-cli-${{ matrix.target }}
path: codebuff-cli-${{ matrix.target }}.tar.gz