Skip to content

Commit e4d964d

Browse files
committed
feat: add multi-platform build pipeline and version support
1 parent 61da18c commit e4d964d

File tree

6 files changed

+566
-180
lines changed

6 files changed

+566
-180
lines changed

.github/workflows/ci.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Go
17+
uses: actions/setup-go@v5
18+
with:
19+
go-version: '1.23'
20+
21+
- name: Cache Go modules
22+
uses: actions/cache@v4
23+
with:
24+
path: |
25+
~/.cache/go-build
26+
~/go/pkg/mod
27+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
28+
restore-keys: |
29+
${{ runner.os }}-go-
30+
31+
- name: Download dependencies
32+
run: go mod download
33+
34+
- name: Verify dependencies
35+
run: go mod verify
36+
37+
- name: Run go vet
38+
run: go vet ./...
39+
40+
- name: Run go fmt check
41+
run: |
42+
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
43+
echo "Code is not formatted properly:"
44+
gofmt -s -l .
45+
exit 1
46+
fi
47+
48+
- name: Build
49+
run: go build -v ./...
50+
51+
- name: Test build for multiple platforms
52+
run: |
53+
GOOS=linux GOARCH=amd64 go build -o /tmp/coderun-linux-amd64 .
54+
GOOS=darwin GOARCH=amd64 go build -o /tmp/coderun-darwin-amd64 .
55+
GOOS=windows GOARCH=amd64 go build -o /tmp/coderun-windows-amd64.exe .
56+
echo "✅ Multi-platform build successful"

.github/workflows/release.yml

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
# Operating systems and architectures to compile
17+
include:
18+
- os: linux
19+
arch: amd64
20+
goos: linux
21+
goarch: amd64
22+
- os: linux
23+
arch: arm64
24+
goos: linux
25+
goarch: arm64
26+
- os: darwin
27+
arch: amd64
28+
goos: darwin
29+
goarch: amd64
30+
- os: darwin
31+
arch: arm64
32+
goos: darwin
33+
goarch: arm64
34+
- os: windows
35+
arch: amd64
36+
goos: windows
37+
goarch: amd64
38+
- os: windows
39+
arch: arm64
40+
goos: windows
41+
goarch: arm64
42+
43+
steps:
44+
- name: Checkout code
45+
uses: actions/checkout@v4
46+
47+
- name: Set up Go
48+
uses: actions/setup-go@v5
49+
with:
50+
go-version: '1.23'
51+
52+
- name: Get version from tag
53+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
54+
55+
- name: Build binary
56+
env:
57+
GOOS: ${{ matrix.goos }}
58+
GOARCH: ${{ matrix.goarch }}
59+
CGO_ENABLED: 0
60+
run: |
61+
# Create output directory
62+
mkdir -p dist
63+
64+
# Define binary name
65+
if [ "${{ matrix.goos }}" = "windows" ]; then
66+
BINARY_NAME="coderun-${{ matrix.os }}-${{ matrix.arch }}.exe"
67+
else
68+
BINARY_NAME="coderun-${{ matrix.os }}-${{ matrix.arch }}"
69+
fi
70+
71+
# Compile
72+
go build -ldflags="-s -w -X 'main.version=${{ env.VERSION }}'" -o "dist/${BINARY_NAME}" .
73+
74+
# Verify file was created
75+
ls -la dist/
76+
77+
- name: Upload artifacts
78+
uses: actions/upload-artifact@v4
79+
with:
80+
name: coderun-${{ matrix.os }}-${{ matrix.arch }}
81+
path: dist/
82+
83+
create-release:
84+
needs: release
85+
runs-on: ubuntu-latest
86+
steps:
87+
- name: Checkout code
88+
uses: actions/checkout@v4
89+
90+
- name: Download all artifacts
91+
uses: actions/download-artifact@v4
92+
with:
93+
path: dist/
94+
95+
- name: Get version from tag
96+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
97+
98+
- name: Prepare release files
99+
run: |
100+
# Create final directory
101+
mkdir -p release
102+
103+
# Move all binaries to release directory
104+
find dist/ -name "coderun-*" -type f -exec cp {} release/ \;
105+
106+
# List files for verification
107+
ls -la release/
108+
109+
- name: Generate checksums
110+
run: |
111+
cd release
112+
sha256sum * > checksums.txt
113+
cat checksums.txt
114+
115+
- name: Create Release
116+
uses: softprops/action-gh-release@v1
117+
with:
118+
tag_name: ${{ env.VERSION }}
119+
name: Release ${{ env.VERSION }}
120+
body: |
121+
## 🎉 CodeRun CLI ${{ env.VERSION }}
122+
123+
### 📦 Installation
124+
125+
#### Linux (AMD64)
126+
```bash
127+
curl -L https://github.com/${{ github.repository }}/releases/download/${{ env.VERSION }}/coderun-linux-amd64 -o coderun
128+
chmod +x coderun
129+
sudo mv coderun /usr/local/bin/
130+
```
131+
132+
#### Linux (ARM64)
133+
```bash
134+
curl -L https://github.com/${{ github.repository }}/releases/download/${{ env.VERSION }}/coderun-linux-arm64 -o coderun
135+
chmod +x coderun
136+
sudo mv coderun /usr/local/bin/
137+
```
138+
139+
#### macOS (Intel)
140+
```bash
141+
curl -L https://github.com/${{ github.repository }}/releases/download/${{ env.VERSION }}/coderun-darwin-amd64 -o coderun
142+
chmod +x coderun
143+
sudo mv coderun /usr/local/bin/
144+
```
145+
146+
#### macOS (Apple Silicon)
147+
```bash
148+
curl -L https://github.com/${{ github.repository }}/releases/download/${{ env.VERSION }}/coderun-darwin-arm64 -o coderun
149+
chmod +x coderun
150+
sudo mv coderun /usr/local/bin/
151+
```
152+
153+
#### Windows (AMD64)
154+
Download `coderun-windows-amd64.exe` and rename it to `coderun.exe`
155+
156+
#### Windows (ARM64)
157+
Download `coderun-windows-arm64.exe` and rename it to `coderun.exe`
158+
159+
### ✅ Installation Verification
160+
```bash
161+
coderun --version
162+
```
163+
164+
### 🔒 Integrity Verification
165+
You can verify file integrity using `checksums.txt`
166+
167+
files: |
168+
release/*
169+
draft: false
170+
prerelease: false
171+
env:
172+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)