1
0
Fork 1
mirror of https://github.com/0x2E/fusion.git synced 2025-06-08 05:27:15 +09:00

fix: release action

This commit is contained in:
rook1e 2024-03-06 22:33:25 +08:00
parent a60e89129d
commit 6e8e8cc7ce
No known key found for this signature in database
GPG key ID: C63289D731719BC0
6 changed files with 62 additions and 30 deletions

View file

@ -23,10 +23,11 @@ jobs:
with:
node-version: 21
- name: Build
run: ./scripts.sh build
- name: Release
uses: softprops/action-gh-release@v1
run: |
./scripts.sh build
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
draft: true
files: |
build/*
distribution: goreleaser
version: latest
args: release --clean

35
.goreleaser.yaml Normal file
View file

@ -0,0 +1,35 @@
# project_name: fusion
dist: ./build
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- "386"
- arm64
ignore:
- goos: darwin
goarch: "386"
binary: fusion
main: ./cmd/server
archives:
- id: default
format: zip
checksum:
algorithm: sha256
name_template: "checksums.txt"
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
use: github
release:
draft: true

View file

@ -1,24 +1,24 @@
# build backend
FROM golang:1.22 as be
WORKDIR /src
COPY . ./
RUN go build -o fusion-server ./cmd/server/*
# build frontend
FROM node:21 as fe
WORKDIR /src
COPY ./frontend ./
RUN npm i && npm run build
# build backend
FROM golang:1.22 as be
WORKDIR /src
COPY . ./
COPY --from=fe /src/build ./frontend/build/
RUN go build -o fusion ./cmd/server/*
# deploy
FROM debian:12
RUN apt-get update && apt-get install -y sqlite3
WORKDIR /fusion
COPY .env ./
COPY --from=be /src/fusion-server ./
COPY --from=fe /src/build ./frontend/
COPY --from=be /src/fusion ./
EXPOSE 8080
RUN mkdir /data
ENV DB="/data/fusion.db"
CMD [ "./fusion-server" ]
CMD [ "./fusion" ]

View file

@ -23,23 +23,17 @@ Or you can build docker image from scratch:
docker build -t rook1e404/fusion .
```
### 2. Pre-build
### 2. Pre-build binary
Download an release, then run:
Download an release, edit `.env`, then run:
```shell
./fusion-server
./fusion
```
### 3. Build from source
1. Prepare dependencies
```shell
go mod tidy
cd frontend && npm i
```
1. Prepare dependencies: Go 1.22, Node 21 with NPM
2. Build
```shell
@ -54,7 +48,7 @@ cd build
# edit .env
# run
./fusion-server
./fusion
```
## ToDo

View file

@ -5,6 +5,9 @@ import (
"io/fs"
)
// This embed only used in production. Only APIs are used in development,
// so no error
//go:embed all:build
var build embed.FS

View file

@ -3,13 +3,12 @@
build() {
root=$(pwd)
rm -r ./build
mkdir -p ./build/frontend
echo "building backend"
cp .env build/
go build -o ./build/fusion-server ./cmd/server/* || exit 1
echo "building frontend"
cd ./frontend && npm i && npm run build && cp -R ./build/ $root/build/frontend || exit 1
cd $root || exit 1
echo "building backend"
cp .env build/
go build -o ./build/fusion ./cmd/server/* || exit 1
}
gen() {