Skip to content

Commit 01bbb50

Browse files
committed
feat: Add logic to create a release with binaries
1 parent 86f836c commit 01bbb50

3 files changed

Lines changed: 89 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,60 @@ jobs:
3636
uses: golangci/golangci-lint-action@v8
3737
with:
3838
version: v2.1
39+
40+
build-binaries:
41+
name: 'Build Binaries'
42+
runs-on: ubuntu-latest
43+
if: github.ref == 'refs/heads/main'
44+
steps:
45+
- uses: actions/checkout@v4
46+
47+
- name: Set up Go
48+
uses: actions/setup-go@v5
49+
with:
50+
go-version: '1.24'
51+
cache: true
52+
cache-dependency-path: |
53+
**/go.sum
54+
**/go.mod
55+
56+
- name: Build binaries
57+
run: ./scripts/compile-binaries.sh
58+
59+
- name: Upload binaries
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: dlitescript-binaries
63+
path: |
64+
output/dlitescript*
65+
retention-days: 30
66+
67+
release:
68+
name: 'Create Release'
69+
runs-on: ubuntu-latest
70+
if: startsWith(github.ref, 'refs/tags/v')
71+
needs: build-test
72+
steps:
73+
- uses: actions/checkout@v4
74+
75+
- name: Set up Go
76+
uses: actions/setup-go@v5
77+
with:
78+
go-version: '1.24'
79+
cache: true
80+
cache-dependency-path: |
81+
**/go.sum
82+
**/go.mod
83+
84+
- name: Build binaries for release
85+
run: ./scripts/compile-binaries.sh
86+
87+
- name: Create Release
88+
uses: softprops/action-gh-release@v2
89+
with:
90+
files: output/dlitescript*
91+
draft: false
92+
prerelease: false
93+
generate_release_notes: true
94+
env:
95+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ cover.cov
44

55
# Built binaries.
66
DLiteScript
7+
output/

scripts/compile-binaries.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
# Exit on error.
4+
set -e
5+
6+
# Navigate to the root of the project.
7+
cd "$(dirname "$0")/.."
8+
9+
# Create the output directory if it doesn't already exist.
10+
mkdir -p output
11+
12+
# Set the target platforms.
13+
PLATFORMS=(
14+
"darwin-x64:darwin:amd64"
15+
"darwin-arm64:darwin:arm64"
16+
"linux-x64:linux:amd64"
17+
"linux-arm:linux:arm"
18+
"linux-arm64:linux:arm64"
19+
"win32-x64:windows:amd64"
20+
"win32-arm:windows:arm"
21+
"win32-arm64:windows:arm64"
22+
)
23+
24+
# Build the DLiteScript binary for all platforms.
25+
for platform in "${PLATFORMS[@]}"; do
26+
IFS=':' read -r platform_key goos goarch <<< "$platform"
27+
OUTPUT="output/dlitescript-${platform_key}"
28+
29+
echo "Compiling ${platform_key}"
30+
GOOS=$goos GOARCH=$goarch go build -ldflags="-s -w" -o "$OUTPUT" .
31+
done

0 commit comments

Comments
 (0)