Skip to content

Commit da1a05f

Browse files
committed
ci(release): automate versioned builds with GoReleaser
1 parent fe28c90 commit da1a05f

File tree

3 files changed

+168
-1
lines changed

3 files changed

+168
-1
lines changed

.github/workflows/release.yml

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: [ 'v*' ] # v0.1.0 などのタグで実行
6+
workflow_dispatch:
7+
inputs:
8+
tag:
9+
description: 'Release tag (e.g., v1.0.0)'
10+
required: true
11+
type: string
12+
13+
env:
14+
APP_NAME: ghosttype
15+
GO_VERSION: '1.24'
16+
17+
jobs:
18+
# ───────────────────────────────
19+
# Linux (amd64 / arm64)
20+
# ───────────────────────────────
21+
build-linux:
22+
runs-on: ubuntu-latest
23+
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
include:
28+
- goarch: amd64
29+
cc: gcc
30+
install_cross: ''
31+
- goarch: arm64
32+
cc: aarch64-linux-gnu-gcc
33+
install_cross: gcc-aarch64-linux-gnu
34+
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
with:
39+
fetch-depth: 0
40+
41+
- name: Install cross-compiler
42+
if: ${{ matrix.install_cross != '' }}
43+
run: |
44+
sudo apt-get update
45+
sudo apt-get install -y ${{ matrix.install_cross }}
46+
47+
- name: Set up Go
48+
uses: actions/setup-go@v4
49+
with:
50+
go-version: ${{ env.GO_VERSION }}
51+
52+
- name: Build linux/${{ matrix.goarch }}
53+
env:
54+
GOOS: linux
55+
GOARCH: ${{ matrix.goarch }}
56+
CGO_ENABLED: '1'
57+
CC: ${{ matrix.cc }}
58+
run: |
59+
mkdir -p bin
60+
go build -tags=libsql -o bin/${{ env.APP_NAME }} ./main.go
61+
62+
- name: Package
63+
run: |
64+
mkdir -p dist
65+
tar -C bin -czf dist/${{ env.APP_NAME }}_${{ github.ref_name }}_linux_${{ matrix.goarch }}.tar.gz ${{ env.APP_NAME }}
66+
67+
- name: Upload artifact
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: linux-${{ matrix.goarch }}
71+
path: dist/*.tar.gz
72+
73+
# ───────────────────────────────
74+
# macOS (amd64 / arm64)
75+
# ───────────────────────────────
76+
build-macos:
77+
runs-on: macos-latest
78+
79+
strategy:
80+
fail-fast: false
81+
matrix:
82+
goarch: [ arm64 ]
83+
84+
steps:
85+
- name: Checkout
86+
uses: actions/checkout@v4
87+
with:
88+
fetch-depth: 0
89+
90+
- name: Set up Go
91+
uses: actions/setup-go@v4
92+
with:
93+
go-version: ${{ env.GO_VERSION }}
94+
95+
- name: Build darwin/${{ matrix.goarch }}
96+
env:
97+
GOOS: darwin
98+
GOARCH: ${{ matrix.goarch }}
99+
CGO_ENABLED: '1'
100+
run: |
101+
mkdir -p bin
102+
go build -tags=libsql -o bin/${{ env.APP_NAME }} ./main.go
103+
104+
- name: Package
105+
run: |
106+
mkdir -p dist
107+
tar -C bin -czf dist/${{ env.APP_NAME }}_${{ github.ref_name }}_darwin_${{ matrix.goarch }}.tar.gz ${{ env.APP_NAME }}
108+
109+
- name: Upload artifact
110+
uses: actions/upload-artifact@v4
111+
with:
112+
name: darwin-${{ matrix.goarch }}
113+
path: dist/*.tar.gz
114+
build-macos-amd64:
115+
runs-on: macos-13 # Intel macOS
116+
steps:
117+
- name: Checkout
118+
uses: actions/checkout@v4
119+
with:
120+
fetch-depth: 0
121+
- name: Set up Go
122+
uses: actions/setup-go@v4
123+
with:
124+
go-version: ${{ env.GO_VERSION }}
125+
- name: Build darwin/amd64
126+
env:
127+
CGO_ENABLED: '1'
128+
run: |
129+
mkdir -p bin
130+
go build -tags=libsql -o bin/${{ env.APP_NAME }} ./main.go
131+
132+
- name: Package
133+
run: |
134+
mkdir -p dist
135+
tar -C bin -czf dist/${{ env.APP_NAME }}_${{ github.ref_name }}_darwin_amd64.tar.gz ${{ env.APP_NAME }}
136+
137+
- name: Upload artifact
138+
uses: actions/upload-artifact@v4
139+
with:
140+
name: darwin-amd64
141+
path: dist/*.tar.gz
142+
143+
# ───────────────────────────────
144+
# Release job (collect & publish)
145+
# ───────────────────────────────
146+
release:
147+
needs:
148+
- build-linux
149+
- build-macos
150+
# - build-macos-amd64
151+
runs-on: ubuntu-latest
152+
steps:
153+
- name: Download all artifacts
154+
uses: actions/download-artifact@v4
155+
with:
156+
path: dist
157+
158+
- name: Create GitHub Release
159+
uses: softprops/action-gh-release@v1
160+
with:
161+
files: dist/**/*.tar.gz
162+
draft: false # 必要なら true
163+
prerelease: false
164+
env:
165+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/charmbracelet/lipgloss v1.1.0
99
github.com/golang/mock v1.6.0
1010
github.com/spf13/cobra v1.9.1
11-
github.com/tursodatabase/go-libsql v0.0.0-20250416102726-983f7e9acb0e
11+
github.com/tursodatabase/go-libsql v0.0.0-20250609073118-9c24e0e7fa97
1212
golang.org/x/sync v0.13.0
1313
)
1414

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
6363
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
6464
github.com/tursodatabase/go-libsql v0.0.0-20250416102726-983f7e9acb0e h1:DUEcD8ukLWxIlcRWWJSuAX6IbEQln2bc7t9HOT45FFk=
6565
github.com/tursodatabase/go-libsql v0.0.0-20250416102726-983f7e9acb0e/go.mod h1:TjsB2miB8RW2Sse8sdxzVTdeGlx74GloD5zJYUC38d8=
66+
github.com/tursodatabase/go-libsql v0.0.0-20250609073118-9c24e0e7fa97 h1:p06qEwD+tRHYHvnw971fsbDtoxTnw6Tp0FYD1q2TSXs=
67+
github.com/tursodatabase/go-libsql v0.0.0-20250609073118-9c24e0e7fa97/go.mod h1:TjsB2miB8RW2Sse8sdxzVTdeGlx74GloD5zJYUC38d8=
6668
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
6769
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
6870
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=

0 commit comments

Comments
 (0)