diff --git a/.gitignore b/.gitignore index 8477fe8..942f5b3 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,8 @@ *.sqlite /.gitea-release /.edge -/data \ No newline at end of file +/data +.mktools/ +/dist +/.chglog +/CHANGELOG.md \ No newline at end of file diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..0466b61 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,103 @@ +project_name: edge +before: + hooks: + - go mod tidy + - go generate ./... +builds: + - id: edge-cli + binary: edge-cli + env: + - CGO_ENABLED=0 + ldflags: + - -s + - -w + gcflags: + - -trimpath="${PWD}" + asmflags: + - -trimpath="${PWD}" + goos: + - linux + goarch: + - amd64 + main: ./cmd/cli + - id: storage-server + binary: storage-server + env: + - CGO_ENABLED=0 + ldflags: + - -s + - -w + gcflags: + - -trimpath="${PWD}" + asmflags: + - -trimpath="${PWD}" + goos: + - linux + goarch: + - amd64 + main: ./cmd/storage-server +archives: + - id: edge-cli + builds: ["edge-cli"] + name_template: 'edge-cli_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}' + files: + - README.md + - CHANGELOG.md + - id: storage-server + builds: ["storage-server"] + name_template: 'storage-server_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}' + files: + - README.md + - CHANGELOG.md +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ .Version }}" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' +nfpms: + - id: edge-cli + builds: + - "edge-cli" + package_name: edge-cli + homepage: https://forge.cadoles.com/arcad/edge + maintainer: William Petit + description: |- + + license: AGPL-3.0 + formats: + - apk + - deb + - id: storage-server + builds: + - "storage-server" + package_name: storage-server + homepage: https://forge.cadoles.com/arcad/edge + maintainer: William Petit + description: |- + + license: AGPL-3.0 + formats: + - apk + - deb + # contents: + # - src: misc/packaging/common/config-agent.yml + # dst: /etc/emissary/agent.yml + # type: config + # - src: misc/packaging/systemd/emissary-agent.systemd.service + # dst: /usr/lib/systemd/system/emissary-agent.service + # packager: deb + # - src: misc/packaging/systemd/emissary-agent.systemd.service + # dst: /usr/lib/systemd/system/emissary-agent.service + # packager: rpm + # - src: misc/packaging/openrc/emissary-agent.openrc.sh + # dst: /etc/init.d/emissary-agent + # file_info: + # mode: 0755 + # packager: apk + # scripts: + # postinstall: "misc/packaging/common/postinstall-agent.sh" \ No newline at end of file diff --git a/Makefile b/Makefile index 611d22e..7092b6b 100644 --- a/Makefile +++ b/Makefile @@ -6,13 +6,13 @@ GOTEST_ARGS ?= -short -timeout 60s ESBUILD_VERSION ?= v0.17.5 -GIT_VERSION := $(shell git describe --always) -DATE_VERSION := $(shell date +%Y.%-m.%-d) -FULL_VERSION := v$(DATE_VERSION)-$(GIT_VERSION)$(if $(shell git diff --stat),-dirty,) APP_PATH ?= misc/client-sdk-testsuite/dist RUN_APP_ARGS ?= RUN_STORAGE_SERVER_ARGS ?= +GORELEASER_VERSION ?= v1.21.2 +GORELEASER_ARGS ?= release --snapshot --clean + SHELL := bash @@ -83,22 +83,24 @@ run-storage-server: .env .env: cp .env.dist .env -gitea-release: tools/yq/bin/yq tools/gitea-release/bin/gitea-release.sh build +gitea-release: tools/yq/bin/yq tools/gitea-release/bin/gitea-release.sh goreleaser build mkdir -p .gitea-release rm -rf .gitea-release/* - cp bin/cli .gitea-release/edge_cli_amd64 + cp dist/*.deb .gitea-release/ + cp dist/*.tar.gz .gitea-release/ + cp dist/*.apk .gitea-release/ # Create client-sdk-testsuite package - tools/yq/bin/yq -i '.version = "$(FULL_VERSION)"' ./misc/client-sdk-testsuite/dist/manifest.yml - .gitea-release/edge_cli_amd64 app package -d ./misc/client-sdk-testsuite/dist -o .gitea-release + tools/yq/bin/yq -i '.version = "$(MKT_PROJECT_VERSION)"' ./misc/client-sdk-testsuite/dist/manifest.yml + bin/cli app package -d ./misc/client-sdk-testsuite/dist -o .gitea-release GITEA_RELEASE_PROJECT="edge" \ GITEA_RELEASE_ORG="arcad" \ GITEA_RELEASE_BASE_URL="https://forge.cadoles.com" \ - GITEA_RELEASE_VERSION="$(FULL_VERSION)" \ - GITEA_RELEASE_NAME="$(FULL_VERSION)" \ - GITEA_RELEASE_COMMITISH_TARGET="$(GIT_VERSION)" \ + GITEA_RELEASE_VERSION="$(MKT_PROJECT_VERSION)" \ + GITEA_RELEASE_NAME="$(MKT_PROJECT_VERSION)" \ + GITEA_RELEASE_COMMITISH_TARGET="$$(git rev-parse HEAD)" \ GITEA_RELEASE_IS_DRAFT="false" \ GITEA_RELEASE_IS_PRERELEASE="true" \ GITEA_RELEASE_BODY="" \ @@ -117,4 +119,22 @@ tools/yq/bin/yq: tools/modd/bin/modd: mkdir -p tools/modd/bin - GOBIN=$(PWD)/tools/modd/bin go install -mod=readonly github.com/cortesi/modd/cmd/modd@latest \ No newline at end of file + GOBIN=$(PWD)/tools/modd/bin go install -mod=readonly github.com/cortesi/modd/cmd/modd@latest + +.PHONY: goreleaser +goreleaser: .mktools changelog + ( set -o allexport && source .env && set +o allexport && curl -sfL https://goreleaser.com/static/run | VERSION="$(GORELEASER_VERSION)" GORELEASER_CURRENT_TAG="$(MKT_PROJECT_VERSION)" bash /dev/stdin $(GORELEASER_ARGS) ) + +.PHONY: changelog +changelog: .mktools + $(MAKE) MKT_GIT_CHGLOG_ARGS='--next-tag $$(MKT_PROJECT_VERSION) --tag-filter-pattern $$(MKT_PROJECT_VERSION_CHANNEL) --output CHANGELOG.md' mkt-changelog + +.PHONY: mktools +mktools: + rm -rf .mktools + curl -q https://forge.cadoles.com/Cadoles/mktools/raw/branch/master/install.sh | $(SHELL) + +.mktools: + $(MAKE) mktools + +-include .mktools/*.mk \ No newline at end of file diff --git a/go.mod b/go.mod index a206a84..1a9b4e1 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,9 @@ module forge.cadoles.com/arcad/edge go 1.19 require ( + github.com/hashicorp/golang-lru/v2 v2.0.6 github.com/hashicorp/mdns v1.0.5 + github.com/keegancsmith/rpc v1.3.0 github.com/lestrrat-go/jwx/v2 v2.0.8 modernc.org/sqlite v1.20.4 ) @@ -15,8 +17,6 @@ require ( github.com/go-playground/universal-translator v0.16.0 // indirect github.com/goccy/go-json v0.9.11 // indirect github.com/gogo/protobuf v0.0.0-20161014173244-50d1bd39ce4e // indirect - github.com/hashicorp/golang-lru/v2 v2.0.6 // indirect - github.com/keegancsmith/rpc v1.3.0 // indirect github.com/leodido/go-urn v1.1.0 // indirect github.com/lestrrat-go/blackmagic v1.0.1 // indirect github.com/lestrrat-go/httpcc v1.0.1 // indirect @@ -45,7 +45,7 @@ require ( github.com/go-chi/chi/v5 v5.0.8 github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/google/uuid v1.3.0 github.com/gorilla/websocket v1.4.2 // indirect github.com/igm/sockjs-go/v3 v3.0.2 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect