From 17d6a5c17c90400d6d1e5ac18ec01803a2b661f5 Mon Sep 17 00:00:00 2001 From: Andreas Linde <42185+DerAndereAndi@users.noreply.github.com> Date: Sun, 20 Feb 2022 14:11:06 +0100 Subject: [PATCH] Improve nightly version handling (#2598) Co-authored-by: Michael Geers --- .github/workflows/nightly.yml | 11 ++++--- .github/workflows/release.yml | 10 +++--- .goreleaser-nightly.yml | 23 ++++++++++--- .goreleaser.yml | 13 +++++--- Dockerfile | 7 ++-- Makefile | 32 +++++++++++-------- assets/js/components/Version.vue | 3 +- assets/js/views/App.vue | 1 + cmd/charger.go | 2 +- cmd/configure/main.go | 2 +- cmd/dump.go | 2 +- cmd/eebus.go | 2 +- cmd/health.go | 2 +- cmd/meter.go | 2 +- cmd/root.go | 4 +-- cmd/token.go | 2 +- cmd/vehicle.go | 2 +- ...{index.6aeecebf.css => index.1cb8281c.css} | 2 +- dist/index.html | 4 +-- dist/js/index.0be96fe8.js | 2 -- dist/js/index.0be96fe8.js.map | 1 - dist/js/index.62b1c85f.js | 2 ++ dist/js/index.62b1c85f.js.map | 1 + docker/ci.Dockerfile | 7 +++- docker/tmpl.Dockerfile | 17 +++++----- server/version.go | 11 ++++++- 26 files changed, 107 insertions(+), 60 deletions(-) rename dist/css/{index.6aeecebf.css => index.1cb8281c.css} (97%) delete mode 100644 dist/js/index.0be96fe8.js delete mode 100644 dist/js/index.0be96fe8.js.map create mode 100644 dist/js/index.62b1c85f.js create mode 100644 dist/js/index.62b1c85f.js.map diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index fb13fb5aa..f61992e07 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -31,8 +31,8 @@ jobs: && ! contains(github.head_ref, 'refs/heads/chore/') uses: evcc-io/evcc/.github/workflows/default.yml@master - dockerlatest: - name: Publish Docker :latest + docker: + name: Publish Docker :nightly needs: - call-build-workflow runs-on: ubuntu-latest @@ -45,7 +45,7 @@ jobs: - name: Install env: - SEIHON_VERSION: v0.8.4 + SEIHON_VERSION: v0.9.0 run: curl -sfL https://raw.githubusercontent.com/ldez/seihon/master/godownloader.sh | sudo bash -s -- -b $GOPATH/bin ${SEIHON_VERSION} - name: Login @@ -55,9 +55,10 @@ jobs: password: ${{ secrets.DOCKER_PASS }} - name: Publish - run: make publish-latest-ci + run: make publish-nightly - nightly: + + apt: name: Publish APT nightly needs: - call-build-workflow diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d90cf9224..e98c36e89 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ jobs: if: "startsWith(github.ref, 'refs/tags')" uses: evcc-io/evcc/.github/workflows/default.yml@master - dockerrelease: + docker: name: Publish Docker :release needs: - call-build-workflow @@ -24,7 +24,9 @@ jobs: fetch-depth: 0 - name: Install - run: curl -sfL https://raw.githubusercontent.com/ldez/seihon/master/godownloader.sh | sudo bash -s -- -b $GOPATH/bin v0.5.1 + env: + SEIHON_VERSION: v0.9.0 + run: curl -sfL https://raw.githubusercontent.com/ldez/seihon/master/godownloader.sh | sudo bash -s -- -b $GOPATH/bin ${SEIHON_VERSION} - name: Login uses: docker/login-action@v1 @@ -33,10 +35,10 @@ jobs: password: ${{ secrets.DOCKER_PASS }} - name: Publish - run: make publish-images + run: make publish-release - release: + apt: name: Publish Github & APT release needs: - call-build-workflow diff --git a/.goreleaser-nightly.yml b/.goreleaser-nightly.yml index 9e18bb7a5..982451902 100644 --- a/.goreleaser-nightly.yml +++ b/.goreleaser-nightly.yml @@ -1,13 +1,14 @@ dist: release release: disable: true + builds: - id: evcc main: main.go flags: - -tags=release ldflags: - - -X github.com/evcc-io/evcc/server.Version={{.Version}}.{{.Timestamp}} -X github.com/evcc-io/evcc/server.Commit={{.ShortCommit}} -s -w + - -X github.com/evcc-io/evcc/server.Version={{.Version}} -X github.com/evcc-io/evcc/server.Commit={{.ShortCommit}} -s -w env: - CGO_ENABLED=0 goos: @@ -18,6 +19,7 @@ builds: - arm64 goarm: - "6" + archives: - builds: - evcc @@ -29,17 +31,30 @@ archives: format: zip files: - evcc.dist.yaml - name_template: "{{.ProjectName}}_{{ .Version }}.{{.Timestamp}}_{{.Os}}-{{.Arch}}{{ if .Arm }}hf{{ end }}" + name_template: "{{.ProjectName}}_{{ .Version }}_{{.Os}}-{{.Arch}}{{ if .Arm }}hf{{ end }}" + universal_binaries: - replace: true + checksum: name_template: 'checksums.txt' + snapshot: name_template: "{{ .Version }}.{{.Timestamp}}" + +changelog: + sort: asc + filters: + exclude: + - '^chore' + - '^bump' + - '^docs:' + - '^test:' + nfpms: - id: default package_name: evcc - file_name_template: "{{.ProjectName}}_{{ .Version }}.{{.Timestamp}}_{{.Os}}-{{.Arch}}{{ if .Arm }}hf{{ end }}" + file_name_template: "{{.ProjectName}}_{{ .Version }}_{{.Os}}-{{.Arch}}{{ if .Arm }}hf{{ end }}" homepage: https://evcc.io description: EV Charge Controller @@ -57,4 +72,4 @@ nfpms: scripts: postinstall: ./packaging/scripts/postinstall.sh preremove: ./packaging/scripts/preremove.sh - postremove: ./packaging/scripts/postremove.sh \ No newline at end of file + postremove: ./packaging/scripts/postremove.sh diff --git a/.goreleaser.yml b/.goreleaser.yml index ffc1e02fd..6b8ce43d3 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -3,16 +3,14 @@ release: github: owner: evcc-io name: evcc -# extra_files: -# - glob: evcc_*.image.gz -# - glob: evcc_*.rootfs.gz + builds: - id: evcc main: main.go flags: - -tags=release ldflags: - - -X github.com/evcc-io/evcc/server.Version={{.Version}} -X github.com/evcc-io/evcc/server.Commit={{.ShortCommit}} -s -w + - -X github.com/evcc-io/evcc/server.Version={{.Version}} -s -w env: - CGO_ENABLED=0 goos: @@ -30,6 +28,7 @@ builds: goarch: arm - goos: windows goarch: arm64 + archives: - builds: - evcc @@ -41,12 +40,16 @@ archives: format: zip files: - evcc.dist.yaml + universal_binaries: - replace: true + checksum: name_template: 'checksums.txt' + snapshot: name_template: "{{ .Tag }}-next" + changelog: sort: asc filters: @@ -55,6 +58,7 @@ changelog: - '^bump' - '^docs:' - '^test:' + nfpms: - id: default package_name: evcc @@ -77,6 +81,7 @@ nfpms: postinstall: ./packaging/scripts/postinstall.sh preremove: ./packaging/scripts/preremove.sh postremove: ./packaging/scripts/postremove.sh + brews: - tap: owner: evcc-io diff --git a/Dockerfile b/Dockerfile index 4704bea3d..fb53c07fa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # STEP 1 build ui FROM node:16-alpine as node -RUN apk update && apk add --no-cache make +RUN apk update && apk add --no-cache make alpine-sdk python3 WORKDIR /build @@ -27,6 +27,9 @@ RUN apk update && apk add --no-cache git ca-certificates tzdata alpine-sdk && up WORKDIR /build +# define --build-arg RELEASE=1 to hide commit hash +ARG RELEASE + # install go tools and cache modules COPY Makefile . COPY go.mod . @@ -43,7 +46,7 @@ RUN make assets COPY --from=node /build/dist /build/dist # build -RUN make build +RUN RELEASE=${RELEASE} make build # STEP 3 build a small image including module support diff --git a/Makefile b/Makefile index 5383720e6..dc883fb7f 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,20 @@ .PHONY: default all clean install install-ui ui assets lint test-ui lint-ui test build test-release release -.PHONY: docker publish-testing publish-latest publish-images +.PHONY: docker publish-testing publish-latest publish-nightly publish-release .PHONY: prepare-image image-rootfs image-update .PHONY: soc stamps # build vars TAG_NAME := $(shell test -d .git && git describe --abbrev=0 --tags) SHA := $(shell test -d .git && git rev-parse --short HEAD) +COMMIT := $(SHA) +# hide commit for releases +ifeq ($(RELEASE),1) + COMMIT := +endif VERSION := $(if $(TAG_NAME),$(TAG_NAME),$(SHA)) BUILD_DATE := $(shell date -u '+%Y-%m-%d_%H:%M:%S') BUILD_TAGS := -tags=release -LD_FLAGS := -X github.com/evcc-io/evcc/server.Version=$(VERSION) -X github.com/evcc-io/evcc/server.Commit=$(SHA) -s -w +LD_FLAGS := -X github.com/evcc-io/evcc/server.Version=$(VERSION) -X github.com/evcc-io/evcc/server.Commit=$(COMMIT) -s -w BUILD_ARGS := -ldflags='$(LD_FLAGS)' # docker @@ -55,7 +60,7 @@ test: go test ./... build: - @echo Version: $(VERSION) $(BUILD_DATE) + @echo Version: $(VERSION) $(SHA) $(BUILD_DATE) go build -v $(BUILD_TAGS) $(BUILD_ARGS) release-test: @@ -65,28 +70,27 @@ release: goreleaser --rm-dist docker: - @echo Version: $(VERSION) $(BUILD_DATE) + @echo Version: $(VERSION) $(SHA) $(BUILD_DATE) docker build --tag $(DOCKER_IMAGE):testing . publish-testing: - @echo Version: $(VERSION) $(BUILD_DATE) - seihon publish --dry-run=false --template docker/ci.Dockerfile --base-runtime-image alpine:$(ALPINE_VERSION) \ + @echo Version: $(VERSION) $(SHA) $(BUILD_DATE) + seihon publish --dry-run=false --template docker/tmpl.Dockerfile --base-runtime-image alpine:$(ALPINE_VERSION) \ --image-name $(DOCKER_IMAGE) -v "testing" --targets=$(TARGETS) publish-latest: - @echo Version: $(VERSION) $(BUILD_DATE) + @echo Version: $(VERSION) $(SHA) $(BUILD_DATE) seihon publish --dry-run=false --template docker/tmpl.Dockerfile --base-runtime-image alpine:$(ALPINE_VERSION) \ --image-name $(DOCKER_IMAGE) -v "latest" --targets=$(TARGETS) -publish-latest-ci: - @echo Version: $(VERSION) $(BUILD_DATE) +publish-nightly: + @echo Version: $(VERSION) $(SHA) $(BUILD_DATE) seihon publish --dry-run=false --template docker/ci.Dockerfile --base-runtime-image alpine:$(ALPINE_VERSION) \ --image-name $(DOCKER_IMAGE) -v "nightly" --targets=$(TARGETS) -# TODO: -v "0" needs to be replaced by MAJOR, MINOR and PATCH as soon as we made it to semantic versioning -publish-images: - @echo Version: $(VERSION) $(BUILD_DATE) - seihon publish --dry-run=false --template docker/tmpl.Dockerfile --base-runtime-image alpine:$(ALPINE_VERSION) \ +publish-release: + @echo Version: $(VERSION) $(SHA) $(BUILD_DATE) + RELEASE=1 seihon publish --dry-run=false --template docker/ci.Dockerfile --base-runtime-image alpine:$(ALPINE_VERSION) \ --image-name $(DOCKER_IMAGE) -v "latest" -v "$(TAG_NAME)" --targets=$(TARGETS) # gokrazy image @@ -111,7 +115,7 @@ image-update: gokr-packer -update yes $(IMAGE_OPTIONS) soc: - @echo Version: $(VERSION) $(BUILD_DATE) + @echo Version: $(VERSION) $(SHA) $(BUILD_DATE) go build $(BUILD_TAGS) $(BUILD_ARGS) github.com/evcc-io/evcc/cmd/soc stamps: diff --git a/assets/js/components/Version.vue b/assets/js/components/Version.vue index c83690897..182e09537 100644 --- a/assets/js/components/Version.vue +++ b/assets/js/components/Version.vue @@ -26,7 +26,8 @@ }} {{ $t("footer.version.versionLong", { installed }) - }} + }} ({{ commit }})