Skip to content

Commit 7f31d31

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

File tree

3 files changed

+140
-1
lines changed

3 files changed

+140
-1
lines changed

.github/workflows/release.yml

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
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+
RELEASE_TAG: ${{ github.ref_name != '' && github.ref_name || inputs.tag }}
17+
18+
jobs:
19+
# ───────────────────────────────
20+
# Linux (amd64 / arm64)
21+
# ───────────────────────────────
22+
build-linux:
23+
runs-on: ubuntu-latest
24+
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
include:
29+
- goarch: amd64
30+
cc: gcc
31+
install_cross: ''
32+
- goarch: arm64
33+
cc: aarch64-linux-gnu-gcc
34+
install_cross: gcc-aarch64-linux-gnu
35+
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@v4
39+
with:
40+
fetch-depth: 0
41+
42+
- name: Install cross-compiler
43+
if: ${{ matrix.install_cross != '' }}
44+
run: |
45+
sudo apt-get update
46+
sudo apt-get install -y ${{ matrix.install_cross }}
47+
48+
- name: Set up Go
49+
uses: actions/setup-go@v4
50+
with:
51+
go-version: ${{ env.GO_VERSION }}
52+
53+
- name: Build linux/${{ matrix.goarch }}
54+
env:
55+
GOOS: linux
56+
GOARCH: ${{ matrix.goarch }}
57+
CGO_ENABLED: '1'
58+
CC: ${{ matrix.cc }}
59+
run: |
60+
mkdir -p bin
61+
go build -tags=libsql -o bin/${{ env.APP_NAME }} ./main.go
62+
63+
- name: Package
64+
run: |
65+
mkdir -p dist
66+
tar -C bin -czf dist/${{ env.APP_NAME }}_${{ github.ref_name }}_linux_${{ matrix.goarch }}.tar.gz ${{ env.APP_NAME }}
67+
68+
- name: Upload artifact
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: linux-${{ matrix.goarch }}
72+
path: dist/*.tar.gz
73+
74+
# ───────────────────────────────
75+
# macOS (amd64 / arm64)
76+
# ───────────────────────────────
77+
build-macos:
78+
runs-on: macos-latest
79+
80+
strategy:
81+
fail-fast: false
82+
matrix:
83+
goarch: [ arm64 ]
84+
85+
steps:
86+
- name: Checkout
87+
uses: actions/checkout@v4
88+
with:
89+
fetch-depth: 0
90+
91+
- name: Set up Go
92+
uses: actions/setup-go@v4
93+
with:
94+
go-version: ${{ env.GO_VERSION }}
95+
96+
- name: Build darwin/${{ matrix.goarch }}
97+
env:
98+
GOOS: darwin
99+
GOARCH: ${{ matrix.goarch }}
100+
CGO_ENABLED: '1'
101+
run: |
102+
mkdir -p bin
103+
go build -tags=libsql -o bin/${{ env.APP_NAME }} ./main.go
104+
105+
- name: Package
106+
run: |
107+
mkdir -p dist
108+
tar -C bin -czf dist/${{ env.APP_NAME }}_${{ github.ref_name }}_darwin_${{ matrix.goarch }}.tar.gz ${{ env.APP_NAME }}
109+
110+
- name: Upload artifact
111+
uses: actions/upload-artifact@v4
112+
with:
113+
name: darwin-${{ matrix.goarch }}
114+
path: dist/*.tar.gz
115+
# ───────────────────────────────
116+
# Release job (collect & publish)
117+
# ───────────────────────────────
118+
release:
119+
needs:
120+
- build-linux
121+
- build-macos
122+
runs-on: ubuntu-latest
123+
steps:
124+
- name: Download all artifacts
125+
uses: actions/download-artifact@v4
126+
with:
127+
path: dist
128+
129+
- name: Create GitHub Release
130+
uses: softprops/action-gh-release@v1
131+
with:
132+
tag_name: ${{ env.RELEASE_TAG }}
133+
files: dist/**/*.tar.gz
134+
draft: false # 必要なら true
135+
prerelease: false
136+
env:
137+
GITHUB_TOKEN: ${{ secrets.GH_PAT }}

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)