Skip to content

Commit dd6e3af

Browse files
committed
Merge branch 'v1'
2 parents 8b04f7f + 9d5f5eb commit dd6e3af

File tree

4 files changed

+111
-17
lines changed

4 files changed

+111
-17
lines changed

.github/workflows/create_release.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
touch RELEASE.txt
4+
echo "SHA-256 checksums of binaries:" >> RELEASE.txt
5+
for v in $(find artifacts/)
6+
do
7+
if [ -d $v ]; then continue; fi
8+
BASENAME=$(echo $(dirname $v) | cut -d "/" -f 2)
9+
SHANAME=$(sha256sum $v 2> /dev/null | cut -d " " -f 1)
10+
printf '**%s**: `%s`\n' $BASENAME $SHANAME >> RELEASE.txt
11+
tar --transform 's/.*\///g' -zcf "${BASENAME}.tar.gz" $v
12+
done

.github/workflows/gochat_v1.yml

Lines changed: 73 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,87 @@
11
# This workflow will build a golang project
22
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
33

4-
name: Gochat v1
4+
name: Build Gochat v1
55

66
on:
77
push:
8-
branches: [ "v1" ]
9-
pull_request:
10-
branches: [ "v1" ]
8+
tags:
9+
- "v1.*"
10+
11+
permissions:
12+
contents: write
1113

1214
jobs:
13-
build:
15+
windows:
1416
runs-on: ubuntu-latest
1517
steps:
16-
- uses: actions/checkout@v4
18+
- name: Set up repository
19+
uses: actions/checkout@v4
1720
- name: Set up Go
1821
uses: actions/setup-go@v4
1922
with:
2023
go-version: '1.23.5'
21-
- name: Build client
22-
run: make client
23-
- name: Build server
24-
run: make server
24+
- name: Install CGO
25+
run: sudo apt-get install gcc-mingw-w64
26+
- name: Build all
27+
run: make all OS=windows ARCH=amd64 -j$(nproc)
28+
- name: Publish server
29+
uses: actions/upload-artifact@v4
30+
with:
31+
name: gochat-server_windows-amd64
32+
path: build/gochat-server.exe
33+
- name: Publish client
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: gochat-client_windows-amd64
37+
path: build/gochat-client.exe
38+
linux:
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Set up repository
42+
uses: actions/checkout@v4
43+
- name: Set up Go
44+
uses: actions/setup-go@v4
45+
with:
46+
go-version: '1.23.5'
47+
- name: Build all
48+
run: make all OS=linux ARCH=amd64 -j$(nproc)
49+
- name: Publish server
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: gochat-server_linux-amd64
53+
path: build/gochat-server
54+
- name: Publish client
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: gochat-client_linux-amd64
58+
path: build/gochat-client
59+
release:
60+
runs-on: ubuntu-latest
61+
needs: [windows, linux]
62+
steps:
63+
- name: Prepare repository
64+
uses: actions/checkout@v4
65+
- name: Move to another folder
66+
run: mkdir releasing && cd releasing
67+
- name: Prepare folder and script
68+
run: mkdir artifacts && mv ../.github/workflows/create_release.sh create.sh && chmod +x create.sh
69+
- name: Download Artifacts
70+
uses: actions/download-artifact@v4
71+
with:
72+
path: artifacts
73+
- name: Create release file
74+
run: ./create.sh
75+
- name: Release
76+
uses: softprops/action-gh-release@v2
77+
if: github.ref_type == 'tag'
78+
with:
79+
body_path: RELEASE.txt
80+
preserve_order: true
81+
overwrite_files: true
82+
make_latest: true
83+
files: |
84+
gochat-client_windows-amd64.tar.gz
85+
gochat-client_linux-amd64.tar.gz
86+
gochat-server_windows-amd64.tar.gz
87+
gochat-server_linux-amd64.tar.gz

Makefile

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,32 @@
22
CC=go
33
BUILD=build
44

5-
# Server name
6-
SERVERNAME=gochat-server
5+
# Set the extension and compiler options
6+
# We need to set CGO if we want to compile for windows from linux
7+
8+
# Running under windows
79
ifeq ($(OS),Windows_NT)
8-
SERVERNAME=gochat-server.exe
10+
OS=windows
11+
PREFIX=.exe
12+
CGO=CGO_ENABLED=1 CXX=x86_64-w64-mingw32-g++ CC=x86_64-w64-mingw32-gcc
913
endif
1014

11-
# Client name
12-
CLIENTNAME=gochat-client
13-
ifeq ($(OS),Windows_NT)
14-
CLIENTNAME=gochat-client.exe
15+
# Compiling for windows
16+
ifeq ($(OS), windows)
17+
PREFIX=.exe
18+
CGO=CGO_ENABLED=1 CXX=x86_64-w64-mingw32-g++ CC=x86_64-w64-mingw32-gcc
1519
endif
1620

21+
# If compiling for linux we remove
22+
ifeq ($(OS), linux)
23+
undefine PREFIX
24+
undefine CGO
25+
endif
26+
27+
# Executable names
28+
SERVERNAME=gochat-server$(PREFIX)
29+
CLIENTNAME=gochat-client$(PREFIX)
30+
1731
# Versioning
1832
VERSION:=$(shell date +%s)
1933

@@ -28,11 +42,13 @@ $(BUILD):
2842

2943
# We check the OS environment varible for the .exe extension
3044
$(BUILD)/$(SERVERNAME): $(BUILD)
45+
GOOS=$(OS) GOARCH=$(ARCH) $(CGO) \
3146
$(CC) build -o $(BUILD)/$(SERVERNAME) \
3247
-ldflags "-X main.serverBuild=$(VERSION)" \
3348
./server
3449

3550
$(BUILD)/$(CLIENTNAME): $(BUILD)
51+
GOOS=$(OS) GOARCH=$(ARCH) $(CGO) \
3652
$(CC) build -o $(BUILD)/$(CLIENTNAME) \
3753
-ldflags "-X main.clientBuild=$(VERSION)" \
3854
./client

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ This repository includes:
1313
- The **source code**
1414
- The [implementation](doc/IMPLEMENTATION.md) details.
1515

16+
## Download
17+
You can download the executables for both the **Client** and **Server** for both `Windows x86_64` and `Linux x86_64` in the [Releases](https://github.com/Sprinter05/gochat/releases/latest) page
18+
1619
## Stack
1720
### Client stack
1821
The client's local database is a [SQLite](https://www.sqlite.org/) database handled by [GORM](https://gorm.io/index.html). The client **TUI** is made possible thanks to [tview](https://github.com/rivo/tview).

0 commit comments

Comments
 (0)