diff --git a/.gitignore b/.gitignore index b2fd0dc..752f26d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.css +dist/ test diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..35b336b --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,58 @@ +--- + +project_name: distribusi + +gitea_urls: + api: https://git.vvvvvvaria.org/api/v1 + download: https://git.vvvvvvaria.org/ + skip_tls_verify: false + +before: + hooks: + - go mod tidy + - go generate ./... + +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + goarch: + - 386 + - amd64 + - arm + - arm64 + goarm: + - 5 + - 6 + - 7 + ldflags: + - "-X 'main.Version={{ .Version }}'" + - "-X 'main.Commit={{ .Commit }}'" + +archives: + - replacements: + darwin: Darwin + linux: Linux + windows: Windows + 386: i386 + amd64: x86_64 + format: binary + +checksum: + name_template: 'checksums.txt' + +snapshot: + name_template: "{{ incpatch .Version }}-alpha" + +changelog: + sort: asc + filters: + exclude: + - "^Revert" + - "^docs:" + - "^test:" + - "^tests:" + - "^wip:" diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..815c492 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +COMMIT := $(shell git rev-list -1 HEAD) +LDFLAGS := "-X 'main.Commit=$(COMMIT)'" +DIST_LDFLAGS := $(LDFLAGS)" -s -w" + +default: build + +build: + @go build -ldflags=$(LDFLAGS) . + +install: + @go install -ldflags=$(LDFLAGS) . + +test: + @go test ./... -cover -v + +release: + @goreleaser release --snapshot --rm-dist && \ + ssh varia.zone mkdir -p public_html/distribusi-go/$(VERSION) && \ + scp -r dist/* varia.zone:public_html/distribusi-go/$(VERSION) + +.PHONY: build install test release diff --git a/README.md b/README.md index a1fb88f..ae26d7d 100644 --- a/README.md +++ b/README.md @@ -27,11 +27,73 @@ If you're migrating from the Python version or have experience using it, here ar ## Install -``` -curl https://git.vvvvvvaria.org/decentral1se/distribusi-go/raw/branch/main/distribusi -o distribusi +:champagne: `distribusi-go` has enterprise cross-platform support! :champagne: + +If your platform isn't supported, please see [the entire listing]. If you can't +find it, we can probably support it (see `$GOOS`/`$GOARCH` [on go.dev]), please +[open a ticket]. + +### GNU/Linux + +
GNU/Linux (amd64) +
+curl https://vvvvvvaria.org/~decentral1se/distribusi-go/0.1.0-alpha/distribusi_linux_amd64/distribusi -o distribusi
 chmod +x distribusi
-./distribusi
-```
+./distribusi -h # check things work
+
+
+ +
GNU/Linux (386) +
+curl https://vvvvvvaria.org/~decentral1se/distribusi-go/0.1.0-alpha/distribusi_linux_386/distribusi -o distribusi
+chmod +x distribusi
+./distribusi -h # check things work
+
+
+ +
GNU/Linux (arm64) +
+curl https://vvvvvvaria.org/~decentral1se/distribusi-go/0.1.0-alpha/distribusi_linux_arm64/distribusi -o distribusi
+chmod +x distribusi
+./distribusi -h # check things work
+
+
+ +### Mac OS X + +
Mac OS X (amd64) +
+curl https://vvvvvvaria.org/~decentral1se/distribusi-go/0.1.0-alpha/distribusi_darwin_amd64/distribusi -o distribusi
+chmod +x distribusi
+./distribusi -h # check things work
+
+
+ +
Mac OS X (arm64) +
+curl https://vvvvvvaria.org/~decentral1se/distribusi-go/0.1.0-alpha/distribusi_darwin_arm64/distribusi -o distribusi
+chmod +x distribusi
+./distribusi -h # check things work
+
+
+ +### Windows + +
Windows (386) +
+curl https://vvvvvvaria.org/~decentral1se/distribusi-go/0.1.0-alpha/distribusi_windows_386/distribusi.exe -o distribusi
+chmod +x distribusi
+./distribusi -h # check things work
+
+
+ +
Windows (amd64) +
+curl https://vvvvvvaria.org/~decentral1se/distribusi-go/0.1.0-alpha/distribusi_windows_amd64/ -o distribusi
+chmod +x distribusi
+./distribusi -h # check things work
+
+
## Quick start @@ -47,7 +109,7 @@ If you want to ignore certain paths, you can use `-i/--ignore`: ./distribusi -p -s -i '*.gif, *.md, mydir' ``` -It supports a list of patterns in a comma separated list, wildcards work, more [here]. +It supports a list of patterns in a comma separated list, wildcards work, more [on pkg.go.dev]. If you run into issues, run with `-d/--debug` to see what is happening under the hood. @@ -55,18 +117,25 @@ If you run into issues, run with `-d/--debug` to see what is happening under the ## Hacking -You'll need [Go] >= 1.11 installed. Run `go build .` to build a new `./distribusi` executable. +You'll need [Go] >= 1.11 installed. Run `make` to build a new `./distribusi` executable. If you wanna learn Go, I've got [this book], feel free to take a loan of it :grinning: -[Go]: https://go.dev -[distribusi]: https://git.vvvvvvaria.org/varia/distribusi -[Pillow]: https://pillow.readthedocs.io/en/stable/installation.html#external-libraries -[exiftool]: https://exiftool.org/ -[report issues]: https://git.vvvvvvaria.org/decentral1se/distribusi-go/issues/new/choose -[open a ticket]: https://git.vvvvvvaria.org/decentral1se/distribusi-go/issues/new/choose -[here]: https://pkg.go.dev/path/filepath#Match -[this book]: https://www.gopl.io/ +## Release + +Currently, you have to be `@decentral1se` to do this: + +``` +VERSION= make release +``` + +You can build a local-only release by running this: + +``` +goreleaser release --snapshot --rm-dist +``` + +Binaries are in `dist/`. ## Acknowledgements @@ -77,3 +146,14 @@ If you wanna learn Go, I've got [this book], feel free to take a loan of it :gri ![](https://www.gnu.org/graphics/gplv3-or-later.png) [`LICENSE`](./LICENSE) + +[Go]: https://go.dev +[Pillow]: https://pillow.readthedocs.io/en/stable/installation.html#external-libraries +[distribusi]: https://git.vvvvvvaria.org/varia/distribusi +[the entire listing]: https://vvvvvvaria.org/~decentral1se/distribusi-go/ +[exiftool]: https://exiftool.org/ +[on pkg.go.dev]: https://pkg.go.dev/path/filepath#Match +[on go.dev]: https://go.dev/doc/install/source#environment +[open a ticket]: https://git.vvvvvvaria.org/decentral1se/distribusi-go/issues/new/choose +[report issues]: https://git.vvvvvvaria.org/decentral1se/distribusi-go/issues/new/choose +[this book]: https://www.gopl.io/ diff --git a/distribusi b/distribusi deleted file mode 100755 index 6408878..0000000 Binary files a/distribusi and /dev/null differ diff --git a/distribusi.go b/distribusi.go index d6dede4..52b94e4 100644 --- a/distribusi.go +++ b/distribusi.go @@ -26,6 +26,12 @@ import ( "github.com/urfave/cli/v2" ) +// Version is the current version of distribusi-go +var Version string + +// Commit is the current commit of distribusi-go +var Commit string + // exiftooInstalled tells us if the exiftool binary is installed or not. var exiftoolInstalled = true @@ -91,9 +97,17 @@ var htmlBody = ` // main is the command-line entrypoint. func main() { + if Version == "" { + Version = "dev" + } + + if Commit == "" { + Commit = " " + } + app := &cli.App{ Name: "distribusi-go", - Version: "0.1.0-alpha", + Version: fmt.Sprintf("%s-%s", Version, Commit[:7]), Usage: "low-tech content management system for the web", Description: ` Distribusi is a content management system for the web that produces static