Skip to content

Commit b829715

Browse files
committed
refactor: rename files and update import paths to v3
1 parent 2980d7a commit b829715

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1430
-980
lines changed

.github/workflows/cli.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,12 @@ jobs:
4646
- name: Create Dist Folder
4747
run: mkdir dist
4848

49-
- name: Prepare Version Info
50-
run: |
51-
echo "VERSION=$(git describe --tags)" >> $GITHUB_ENV
52-
echo "COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV
53-
echo "BUILD_TIME=$(date --rfc-3339=seconds)" >> $GITHUB_ENV
54-
echo $GITHUB_ENV
55-
5649
- name: Build
5750
run: |
5851
CGO_ENABLED=0
5952
GOOS=${{ matrix.goos }}
6053
GOARCH=${{ matrix.goarch }}
61-
go build -ldflags="-X 'main.Version=${{ env.VERSION }}' -X 'main.Commit=${{ env.COMMIT }}' -X 'main.BuildTime=${{ env.BUILD_TIME }}'" -o dist/gobin-${{ matrix.goos }}-${{ matrix.goarch }}${{ env.file_name }} github.com/topi314/gobin/v2/cli
54+
go build -o dist/gobin-${{ matrix.goos }}-${{ matrix.goarch }}${{ env.file_name }} github.com/topi314/gobin/v3/cli
6255
6356
- name: Upload
6457
uses: actions/upload-artifact@v4

.github/workflows/server.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ jobs:
4343
username: ${{ github.repository_owner }}
4444
password: ${{ secrets.GITHUB_TOKEN }}
4545

46-
- name: Prepare Version Info
47-
run: |
48-
echo "VERSION=$(git describe --tags)" >> $GITHUB_ENV
49-
echo "COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV
50-
echo "BUILD_TIME=$(date --rfc-3339=seconds)" >> $GITHUB_ENV
51-
5246
- name: Build and push
5347
uses: docker/build-push-action@v6
5448
with:
@@ -57,10 +51,6 @@ jobs:
5751
push: true
5852
tags: ${{ steps.meta.outputs.tags }}
5953
labels: ${{ steps.meta.outputs.labels }}
60-
build-args: |
61-
VERSION=${{ env.VERSION }}
62-
COMMIT=${{ env.COMMIT }}
63-
BUILD_TIME=${{ env.BUILD_TIME }}
6454

6555
deploy:
6656
needs:

Dockerfile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM --platform=$BUILDPLATFORM golang:1.23-alpine AS build
1+
FROM --platform=$BUILDPLATFORM golang:1.24-alpine AS build
22

33
WORKDIR /build
44

@@ -10,16 +10,13 @@ COPY . .
1010

1111
ARG TARGETOS
1212
ARG TARGETARCH
13-
ARG VERSION
14-
ARG COMMIT
15-
ARG BUILD_TIME
1613

1714
RUN --mount=type=cache,target=/root/.cache/go-build \
1815
--mount=type=cache,target=/go/pkg \
1916
CGO_ENABLED=0 \
2017
GOOS=$TARGETOS \
2118
GOARCH=$TARGETARCH \
22-
go build -ldflags="-X 'main.Version=$VERSION' -X 'main.Commit=$COMMIT' -X 'main.BuildTime=$BUILD_TIME'" -o gobin-server github.com/topi314/gobin/v2
19+
go build -o gobin-server github.com/topi314/gobin/v3
2320

2421
FROM alpine
2522

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Go Report](https://goreportcard.com/badge/github.com/topi314/gobin/v2)](https://goreportcard.com/report/github.com/topi314/gobin/v2)
1+
[![Go Report](https://goreportcard.com/badge/github.com/topi314/gobin/v3)](https://goreportcard.com/report/github.com/topi314/gobin/v3)
22
[![Go Version](https://img.shields.io/github/go-mod/go-version/topi314/gobin)](https://golang.org/doc/devel/release.html)
33
[![KittyBot License](https://img.shields.io/github/license/topi314/gobin)](LICENSE)
44
[![KittyBot Version](https://img.shields.io/github/v/tag/topi314/gobin?label=release)](https://github.com/topi314/gobin/releases/latest)
@@ -129,20 +129,20 @@ docker-compose up -d
129129

130130
##### Requirements
131131

132-
- Go 1.21 or higher
132+
- Go 1.24 or higher
133133

134134
##### Build
135135

136136
```bash
137137
git clone https://github.com/topi314/gobin.git
138138
cd gobin
139-
go build -o gobin github.com/topi314/gobin/v2
139+
go build -o gobin github.com/topi314/gobin/v3
140140
```
141141

142142
or
143143

144144
```bash
145-
go install github.com/topi314/gobin/v2@latest
145+
go install github.com/topi314/gobin/v3@latest
146146
```
147147

148148
##### Run
@@ -170,13 +170,13 @@ You can find the latest release on [Releases](https://github.com/topi314/gobin/r
170170
```bash
171171
git clone https://github.com/topi314/gobin.git
172172
cd gobin
173-
go build -o gobin github.com/topi314/gobin/v2/cli
173+
go build -o gobin github.com/topi314/gobin/v3/cli
174174
```
175175

176176
or
177177

178178
```bash
179-
go install github.com/topi314/gobin/v2/cli@latest
179+
go install github.com/topi314/gobin/v3/cli@latest
180180
# rename binary to gobin
181181
mv $(go env GOPATH)/bin/cli $(go env GOPATH)/bin/gobin
182182
# or move binary into /usr/local/bin

cli/cmd/env.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/spf13/cobra"
1111
"github.com/spf13/viper"
1212

13-
"github.com/topi314/gobin/v2/internal/cfg"
13+
"github.com/topi314/gobin/v3/internal/cfg"
1414
)
1515

1616
func NewEnvCmd(parent *cobra.Command) {

cli/cmd/get.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
"github.com/spf13/viper"
1414
"github.com/topi314/chroma/v2/lexers"
1515

16-
"github.com/topi314/gobin/v2/internal/ezhttp"
17-
"github.com/topi314/gobin/v2/server"
16+
"github.com/topi314/gobin/v3/internal/ezhttp"
17+
"github.com/topi314/gobin/v3/server"
1818
)
1919

2020
func NewGetCmd(parent *cobra.Command) {

cli/cmd/import.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/spf13/cobra"
1010
"github.com/spf13/viper"
1111

12-
"github.com/topi314/gobin/v2/internal/cfg"
12+
"github.com/topi314/gobin/v3/internal/cfg"
1313
)
1414

1515
func NewImportCmd(parent *cobra.Command) {

cli/cmd/post.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import (
1616
"github.com/spf13/viper"
1717
"github.com/topi314/chroma/v2/lexers"
1818

19-
"github.com/topi314/gobin/v2/internal/cfg"
20-
"github.com/topi314/gobin/v2/internal/ezhttp"
21-
"github.com/topi314/gobin/v2/server"
19+
"github.com/topi314/gobin/v3/internal/cfg"
20+
"github.com/topi314/gobin/v3/internal/ezhttp"
21+
"github.com/topi314/gobin/v3/server"
2222
)
2323

2424
func NewPostCmd(parent *cobra.Command) {

cli/cmd/rm.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import (
66
"github.com/spf13/cobra"
77
"github.com/spf13/viper"
88

9-
"github.com/topi314/gobin/v2/internal/cfg"
10-
"github.com/topi314/gobin/v2/internal/ezhttp"
11-
"github.com/topi314/gobin/v2/server"
9+
"github.com/topi314/gobin/v3/internal/cfg"
10+
"github.com/topi314/gobin/v3/internal/ezhttp"
11+
"github.com/topi314/gobin/v3/server"
1212
)
1313

1414
func NewRmCmd(parent *cobra.Command) {

cli/cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/spf13/cobra"
88
"github.com/spf13/viper"
99

10-
"github.com/topi314/gobin/v2/internal/cfg"
10+
"github.com/topi314/gobin/v3/internal/cfg"
1111
)
1212

1313
func NewRootCmd() *cobra.Command {

cli/cmd/share.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010
"github.com/spf13/cobra"
1111
"github.com/spf13/viper"
1212

13-
"github.com/topi314/gobin/v2/internal/ezhttp"
14-
"github.com/topi314/gobin/v2/server"
13+
"github.com/topi314/gobin/v3/internal/ezhttp"
14+
"github.com/topi314/gobin/v3/server"
1515
)
1616

1717
func NewShareCmd(parent *cobra.Command) {

cli/cmd/version.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ import (
88
"github.com/spf13/cobra"
99
"github.com/spf13/viper"
1010

11-
"github.com/topi314/gobin/v2/internal/ezhttp"
11+
"github.com/topi314/gobin/v3/internal/ezhttp"
12+
"github.com/topi314/gobin/v3/internal/ver"
1213
)
1314

14-
func NewVersionCmd(parent *cobra.Command, version string) {
15+
func NewVersionCmd(parent *cobra.Command, version ver.Version) {
1516
cmd := &cobra.Command{
1617
Use: "version",
1718
Short: "Prints the version of the gobin cli",
@@ -35,7 +36,7 @@ OS/Arch: windows/amd64`,
3536
},
3637
RunE: func(cmd *cobra.Command, args []string) error {
3738
gobinServer := viper.GetString("server")
38-
cmd.Println(version)
39+
cmd.Println(version.Format())
3940

4041
if gobinServer == "" {
4142
return nil

cli/main.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
11
package main
22

33
import (
4-
"time"
5-
6-
"github.com/topi314/gobin/v2/cli/cmd"
7-
"github.com/topi314/gobin/v2/internal/ver"
8-
)
9-
10-
// These variables are set via the -ldflags option in go build
11-
var (
12-
Version = "unknown"
13-
Commit = "unknown"
14-
BuildTime = "unknown"
4+
"github.com/topi314/gobin/v3/cli/cmd"
5+
"github.com/topi314/gobin/v3/internal/ver"
156
)
167

178
func main() {
18-
buildTime, _ := time.Parse(time.RFC3339, BuildTime)
19-
version := ver.FormatBuildVersion(Version, Commit, buildTime)
9+
version := ver.Load()
2010

2111
rootCmd := cmd.NewRootCmd()
2212
cmd.NewGetCmd(rootCmd)

example.gobin.toml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ jwt_secret = "..."
66
max_document_size = 0
77
max_highlight_size = 0
88

9-
# load custom chroma xml or base16 yaml themes from this directory, omit to disable
9+
# load custom chroma xml or base16 yaml themes from this directory, leave empty to disable
1010
custom_styles = "custom_styles"
11-
default_style = "snazzy"
11+
default_style = "onedark"
1212

1313
# settings for the logging
1414
[log]
@@ -38,29 +38,42 @@ password = "gobin"
3838
database = "gobin"
3939
ssl_mode = "disable"
4040

41-
# omit or set values to 0 or "0" to disable rate limit
41+
# rate limit settings
4242
[rate_limit]
43+
enabled = false
4344
requests = 10
4445
duration = "1m"
4546
whitelist = ["127.0.0.1"]
4647
blacklist = ["123.456.789.0"]
4748

48-
# settings for social media previews, omit to disable
49+
# settings for social media previews
4950
[preview]
51+
enabled = false
5052
inkscape_path = "inkscape.exe"
5153
max_lines = 0
5254
dpi = 120
5355
cache_size = 1024
5456
cache_ttl = "1h"
5557

56-
# open telemetry settings, omit to disable
58+
# open telemetry settings
5759
[otel]
60+
enabled = false
5861
instance_id = "1"
59-
trace = { endpoint = "tempo:4318", insecure = true }
60-
metrics = { listen_addr = ":9100" }
6162

62-
# settings for webhooks, omit to disable
63+
# settings for otel tracing
64+
[otel.trace]
65+
enabled = false
66+
endpoint = "localhost:4318"
67+
insecure = true
68+
69+
# settings for otel metrics
70+
[otel.metrics]
71+
enabled = false
72+
listen_addr = ":9100"
73+
74+
# settings for webhooks
6375
[webhook]
76+
enabled = false
6477
timeout = "10s"
6578
max_tries = 3
6679
backoff = "1s"

0 commit comments

Comments
 (0)