Skip to content

Commit dbb2a41

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

File tree

3 files changed

+296
-1
lines changed

3 files changed

+296
-1
lines changed

.github/workflows/release.yml

Lines changed: 293 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,293 @@
1+
# name: Release
2+
3+
# on:
4+
# push:
5+
# tags:
6+
# - "v*" # v0.1.0 などのタグ push で実行
7+
# workflow_dispatch:
8+
# inputs:
9+
# tag:
10+
# description: 'Release tag (e.g., v1.0.0)'
11+
# required: true
12+
# type: string
13+
14+
# jobs:
15+
# # ──────────────────────────────────────────────────────────────
16+
# # 1️⃣ 各 OS/アーキごとに並列ビルド
17+
# # ──────────────────────────────────────────────────────────────
18+
# build:
19+
# runs-on: ubuntu-latest
20+
21+
# strategy:
22+
# fail-fast: false
23+
# matrix:
24+
# include:
25+
# # Linux ─────────────
26+
# - goos: linux
27+
# goarch: amd64
28+
# ext: "" # 実行ファイル拡張子
29+
# pkg: tar.gz # 配布形式
30+
# cgo: "1" # gcc / libsqlite3-dev がデフォで入っている
31+
# - goos: linux
32+
# goarch: arm64
33+
# ext: ""
34+
# pkg: tar.gz
35+
# cgo: "1" # クロスコンパイル用ツールチェーンを追加
36+
# install_cross: "gcc-aarch64-linux-gnu"
37+
# cc: "aarch64-linux-gnu-gcc"
38+
# # macOS ─────────────
39+
# - goos: darwin
40+
# goarch: amd64
41+
# ext: ""
42+
# pkg: tar.gz
43+
# cgo: "0" # CGO を切る(libsql 非対応なら除外してOK)
44+
# - goos: darwin
45+
# goarch: arm64
46+
# ext: ""
47+
# pkg: tar.gz
48+
# cgo: "0"
49+
# # Windows ───────────
50+
# - goos: windows
51+
# goarch: amd64
52+
# ext: ".exe"
53+
# pkg: zip
54+
# cgo: "0"
55+
56+
# steps:
57+
# # 1. ソースを取得
58+
# - uses: actions/checkout@v4
59+
# with:
60+
# fetch-depth: 0
61+
62+
# # 2. 必要なクロスコンパイラがあれば追加
63+
# - name: Install cross-compiler (if required)
64+
# if: ${{ matrix.install_cross != '' }}
65+
# run: |
66+
# sudo apt-get update
67+
# sudo apt-get install -y ${{ matrix.install_cross }}
68+
69+
# # 3. Go をセットアップ
70+
# - name: Set up Go
71+
# uses: actions/setup-go@v4
72+
# with:
73+
# go-version: "1.24"
74+
75+
# # 4. ビルド
76+
# - name: Build ${{ matrix.goos }}/${{ matrix.goarch }}
77+
# env:
78+
# GOOS: ${{ matrix.goos }}
79+
# GOARCH: ${{ matrix.goarch }}
80+
# CGO_ENABLED: ${{ matrix.cgo }}
81+
# CC: ${{ matrix.cc }}
82+
# run: |
83+
# mkdir -p bin
84+
# go build \
85+
# -tags=libsql \
86+
# -o bin/ghosttype${{ matrix.ext }} \
87+
# ./main.go
88+
89+
# # 5. アーカイブ化
90+
# - name: Package artifact
91+
# run: |
92+
# mkdir -p dist
93+
# filename="ghosttype_${{ github.ref_name }}_${{ matrix.goos }}_${{ matrix.goarch }}"
94+
# if [ "${{ matrix.pkg }}" = "zip" ]; then
95+
# zip -j "dist/${filename}.zip" bin/ghosttype${{ matrix.ext }}
96+
# else
97+
# tar -C bin -czf "dist/${filename}.tar.gz" ghosttype${{ matrix.ext }}
98+
# fi
99+
100+
# # 6. アーティファクトアップロード
101+
# - uses: actions/upload-artifact@v4
102+
# with:
103+
# name: ghosttype-${{ matrix.goos }}-${{ matrix.goarch }}
104+
# path: dist/*
105+
106+
# # ──────────────────────────────────────────────────────────────
107+
# # 2️⃣ すべてのビルドが終わったら Release を作成
108+
# # ──────────────────────────────────────────────────────────────
109+
# release:
110+
# needs: build
111+
# runs-on: ubuntu-latest
112+
# steps:
113+
# - name: Download all artifacts
114+
# uses: actions/download-artifact@v4
115+
# with:
116+
# path: dist
117+
118+
# - name: Create GitHub Release
119+
# uses: softprops/action-gh-release@v1
120+
# with:
121+
# files: dist/**/*
122+
# draft: false # true にすれば下書き
123+
# prerelease: false
124+
# env:
125+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
126+
127+
name: Release
128+
129+
on:
130+
push:
131+
tags: [ 'v*' ] # v0.1.0 などのタグで実行
132+
workflow_dispatch:
133+
inputs:
134+
tag:
135+
description: 'Release tag (e.g., v1.0.0)'
136+
required: true
137+
type: string
138+
139+
env:
140+
APP_NAME: ghosttype
141+
GO_VERSION: '1.24'
142+
143+
jobs:
144+
# ───────────────────────────────
145+
# Linux (amd64 / arm64)
146+
# ───────────────────────────────
147+
build-linux:
148+
runs-on: ubuntu-latest
149+
150+
strategy:
151+
fail-fast: false
152+
matrix:
153+
include:
154+
- goarch: amd64
155+
cc: gcc
156+
install_cross: ''
157+
- goarch: arm64
158+
cc: aarch64-linux-gnu-gcc
159+
install_cross: gcc-aarch64-linux-gnu
160+
161+
steps:
162+
- name: Checkout
163+
uses: actions/checkout@v4
164+
with:
165+
fetch-depth: 0
166+
167+
- name: Install cross-compiler
168+
if: ${{ matrix.install_cross != '' }}
169+
run: |
170+
sudo apt-get update
171+
sudo apt-get install -y ${{ matrix.install_cross }}
172+
173+
- name: Set up Go
174+
uses: actions/setup-go@v4
175+
with:
176+
go-version: ${{ env.GO_VERSION }}
177+
178+
- name: Build linux/${{ matrix.goarch }}
179+
env:
180+
GOOS: linux
181+
GOARCH: ${{ matrix.goarch }}
182+
CGO_ENABLED: '1'
183+
CC: ${{ matrix.cc }}
184+
run: |
185+
mkdir -p bin
186+
go build -tags=libsql -o bin/${{ env.APP_NAME }} ./main.go
187+
188+
- name: Package
189+
run: |
190+
mkdir -p dist
191+
tar -C bin -czf dist/${{ env.APP_NAME }}_${{ github.ref_name }}_linux_${{ matrix.goarch }}.tar.gz ${{ env.APP_NAME }}
192+
193+
- name: Upload artifact
194+
uses: actions/upload-artifact@v4
195+
with:
196+
name: linux-${{ matrix.goarch }}
197+
path: dist/*.tar.gz
198+
199+
# ───────────────────────────────
200+
# macOS (amd64 / arm64)
201+
# ───────────────────────────────
202+
build-macos:
203+
runs-on: macos-latest
204+
205+
strategy:
206+
fail-fast: false
207+
matrix:
208+
goarch: [ arm64 ]
209+
210+
steps:
211+
- name: Checkout
212+
uses: actions/checkout@v4
213+
with:
214+
fetch-depth: 0
215+
216+
- name: Set up Go
217+
uses: actions/setup-go@v4
218+
with:
219+
go-version: ${{ env.GO_VERSION }}
220+
221+
- name: Build darwin/${{ matrix.goarch }}
222+
env:
223+
GOOS: darwin
224+
GOARCH: ${{ matrix.goarch }}
225+
CGO_ENABLED: '1'
226+
run: |
227+
mkdir -p bin
228+
go build -tags=libsql -o bin/${{ env.APP_NAME }} ./main.go
229+
230+
- name: Package
231+
run: |
232+
mkdir -p dist
233+
tar -C bin -czf dist/${{ env.APP_NAME }}_${{ github.ref_name }}_darwin_${{ matrix.goarch }}.tar.gz ${{ env.APP_NAME }}
234+
235+
- name: Upload artifact
236+
uses: actions/upload-artifact@v4
237+
with:
238+
name: darwin-${{ matrix.goarch }}
239+
path: dist/*.tar.gz
240+
build-macos-amd64:
241+
runs-on: macos-13 # Intel macOS
242+
steps:
243+
- name: Checkout
244+
uses: actions/checkout@v4
245+
with:
246+
fetch-depth: 0
247+
- name: Set up Go
248+
uses: actions/setup-go@v4
249+
with:
250+
go-version: ${{ env.GO_VERSION }}
251+
- name: Build darwin/amd64
252+
env:
253+
GOOS: darwin
254+
GOARCH: amd64
255+
CGO_ENABLED: '1'
256+
run: |
257+
mkdir -p bin
258+
go build -tags=libsql -o bin/${{ env.APP_NAME }} ./main.go
259+
260+
- name: Package
261+
run: |
262+
mkdir -p dist
263+
tar -C bin -czf dist/${{ env.APP_NAME }}_${{ github.ref_name }}_darwin_amd64.tar.gz ${{ env.APP_NAME }}
264+
265+
- name: Upload artifact
266+
uses: actions/upload-artifact@v4
267+
with:
268+
name: darwin-amd64
269+
path: dist/*.tar.gz
270+
271+
# ───────────────────────────────
272+
# Release job (collect & publish)
273+
# ───────────────────────────────
274+
release:
275+
needs:
276+
- build-linux
277+
- build-macos
278+
- build-macos-amd64
279+
runs-on: ubuntu-latest
280+
steps:
281+
- name: Download all artifacts
282+
uses: actions/download-artifact@v4
283+
with:
284+
path: dist
285+
286+
- name: Create GitHub Release
287+
uses: softprops/action-gh-release@v1
288+
with:
289+
files: dist/**/*.tar.gz
290+
draft: false # 必要なら true
291+
prerelease: false
292+
env:
293+
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)