Skip to content

Commit 6e8e8cc

Browse files
committed
fix: release action
1 parent a60e891 commit 6e8e8cc

File tree

6 files changed

+62
-30
lines changed

6 files changed

+62
-30
lines changed

.github/workflows/release.yml

+7-6
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ jobs:
2323
with:
2424
node-version: 21
2525
- name: Build
26-
run: ./scripts.sh build
27-
- name: Release
28-
uses: softprops/action-gh-release@v1
26+
run: |
27+
./scripts.sh build
28+
- name: Run GoReleaser
29+
uses: goreleaser/goreleaser-action@v5
2930
with:
30-
draft: true
31-
files: |
32-
build/*
31+
distribution: goreleaser
32+
version: latest
33+
args: release --clean

.goreleaser.yaml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# project_name: fusion
2+
dist: ./build
3+
builds:
4+
- env:
5+
- CGO_ENABLED=0
6+
goos:
7+
- linux
8+
- windows
9+
- darwin
10+
goarch:
11+
- amd64
12+
- "386"
13+
- arm64
14+
ignore:
15+
- goos: darwin
16+
goarch: "386"
17+
binary: fusion
18+
main: ./cmd/server
19+
20+
archives:
21+
- id: default
22+
format: zip
23+
24+
checksum:
25+
algorithm: sha256
26+
name_template: "checksums.txt"
27+
28+
snapshot:
29+
name_template: "{{ incpatch .Version }}-next"
30+
31+
changelog:
32+
use: github
33+
34+
release:
35+
draft: true

Dockerfile

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
# build backend
2-
FROM golang:1.22 as be
3-
WORKDIR /src
4-
COPY . ./
5-
RUN go build -o fusion-server ./cmd/server/*
6-
71
# build frontend
82
FROM node:21 as fe
93
WORKDIR /src
104
COPY ./frontend ./
115
RUN npm i && npm run build
126

7+
# build backend
8+
FROM golang:1.22 as be
9+
WORKDIR /src
10+
COPY . ./
11+
COPY --from=fe /src/build ./frontend/build/
12+
RUN go build -o fusion ./cmd/server/*
13+
1314
# deploy
1415
FROM debian:12
1516
RUN apt-get update && apt-get install -y sqlite3
1617
WORKDIR /fusion
1718
COPY .env ./
18-
COPY --from=be /src/fusion-server ./
19-
COPY --from=fe /src/build ./frontend/
19+
COPY --from=be /src/fusion ./
2020
EXPOSE 8080
2121
RUN mkdir /data
2222
ENV DB="/data/fusion.db"
23-
CMD [ "./fusion-server" ]
23+
CMD [ "./fusion" ]
2424

README.md

+5-11
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,17 @@ Or you can build docker image from scratch:
2323
docker build -t rook1e404/fusion .
2424
```
2525

26-
### 2. Pre-build
26+
### 2. Pre-build binary
2727

28-
Download an release, then run:
28+
Download an release, edit `.env`, then run:
2929

3030
```shell
31-
./fusion-server
31+
./fusion
3232
```
3333

3434
### 3. Build from source
3535

36-
1. Prepare dependencies
37-
38-
```shell
39-
go mod tidy
40-
cd frontend && npm i
41-
```
42-
36+
1. Prepare dependencies: Go 1.22, Node 21 with NPM
4337
2. Build
4438

4539
```shell
@@ -54,7 +48,7 @@ cd build
5448
# edit .env
5549

5650
# run
57-
./fusion-server
51+
./fusion
5852
```
5953

6054
## ToDo

frontend/embed.go

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import (
55
"io/fs"
66
)
77

8+
// This embed only used in production. Only APIs are used in development,
9+
// so no error
10+
811
//go:embed all:build
912
var build embed.FS
1013

scripts.sh

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
build() {
44
root=$(pwd)
55
rm -r ./build
6-
mkdir -p ./build/frontend
7-
echo "building backend"
8-
cp .env build/
9-
go build -o ./build/fusion-server ./cmd/server/* || exit 1
106
echo "building frontend"
117
cd ./frontend && npm i && npm run build && cp -R ./build/ $root/build/frontend || exit 1
128
cd $root || exit 1
9+
echo "building backend"
10+
cp .env build/
11+
go build -o ./build/fusion ./cmd/server/* || exit 1
1312
}
1413

1514
gen() {

0 commit comments

Comments
 (0)