Skip to content

Commit 0a999cf

Browse files
committed
experiment
1 parent abb0759 commit 0a999cf

File tree

14 files changed

+68
-1420
lines changed

14 files changed

+68
-1420
lines changed

.github/workflows/publish.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
name: publish to github pages

.github/workflows/release.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Vulphix Binaries for release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Setup Go ${{ matrix.go-version }}
15+
uses: actions/setup-go@v5
16+
with:
17+
go-version: "1.24.0"
18+
- name: Display Go version
19+
run: go version
20+
21+
- name: Installing dependencies
22+
run: go mod download
23+
24+
- name: Building binaries
25+
run: chmod +x build.sh && ./build.sh
26+
27+
- name: Create Release and Upload Binaries
28+
uses: softprops/action-gh-release@v2
29+
with:
30+
name: Vulphix ${{ github.ref_name }}
31+
tag_name: ${{ github.ref_name }}
32+
files: bin/*
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ ignore.sh
1010
*.dll
1111
*.so
1212
*.dylib
13+
bin
1314

1415
# Test binary, built with `go test -c`
1516
*.test
@@ -33,3 +34,5 @@ go.work.sum
3334
# Editor/IDE
3435
# .idea/
3536
# .vscode/
37+
# Added by goreleaser init:
38+
dist/

build.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#! /bin/bash
2+
3+
echo "Creating bin"
4+
mkdir -p bin
5+
6+
echo "Building for linux"
7+
CGO=0 GOOS=linux GOARCH=amd64 go build -o ./bin/vulphix-linux-amd64
8+
9+
echo "Building for Windows"
10+
CGO=0 GOOS=windows GOARCH=amd64 go build -o ./bin/vulphix-windows-amd64.exe
11+
12+
echo "Building for Mac"
13+
CGO=0 GOOS=darwin GOARCH=arm64 go build -o ./bin/vulphix-darwin-arm64

cmd/build/build.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/goccy/go-yaml"
1414
)
1515

16-
// TODO: change this in prod
1716
const (
1817
CONFIG_FILE = "vulphix.config.yaml"
1918
DEFAULT_SOURCE = "src"
@@ -50,7 +49,7 @@ func readEmbedFiles(filename string) ([]byte, error) {
5049
return assets.ReadFile(filename)
5150
}
5251

53-
func readConfig() (*Config, error) {
52+
func ReadConfig() (*Config, error) {
5453
byte, err := os.ReadFile(CONFIG_FILE)
5554
if err != nil {
5655
return nil, err
@@ -64,10 +63,10 @@ func readConfig() (*Config, error) {
6463
}
6564

6665
func Build() int {
67-
config, err := readConfig()
66+
config, err := ReadConfig()
6867
if err != nil {
6968
if errors.Is(err, os.ErrNotExist) || config == nil {
70-
fmt.Print("Missing '%v'", CONFIG_FILE)
69+
fmt.Printf("Missing '%v'\n", CONFIG_FILE)
7170
}
7271
return 1
7372
}

cmd/preview/preview.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,19 @@ import (
1616
const previewPort = 8080
1717

1818
func PreviewBuild() int {
19-
//TOOD: read this form config
20-
const dir = build.DEFAULT_BUILD
19+
20+
config, err := build.ReadConfig()
21+
if err != nil {
22+
if errors.Is(err, os.ErrNotExist) || config == nil {
23+
fmt.Printf("Missing '%v'\n", build.CONFIG_FILE)
24+
}
25+
return 1
26+
}
27+
28+
dir := build.DEFAULT_BUILD
29+
if config.Build != "" {
30+
dir = config.Build
31+
}
2132

2233
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
2334
extension := filepath.Ext(req.URL.Path)
@@ -45,7 +56,7 @@ func PreviewBuild() int {
4556
})
4657

4758
fmt.Printf("Preview server running at http://localhost:%d/\n", previewPort)
48-
err := http.ListenAndServe(fmt.Sprintf(":%d", previewPort), nil)
59+
err = http.ListenAndServe(fmt.Sprintf(":%d", previewPort), nil)
4960
if err != nil {
5061
fmt.Printf("Failed to start preview server: %v\n", err)
5162
return 1

docs/dist/404.html

Lines changed: 0 additions & 148 deletions
This file was deleted.

0 commit comments

Comments
 (0)