Improve nightly version handling (#2598)

Co-authored-by: Michael Geers <michael@geers.tv>
This commit is contained in:
Andreas Linde 2022-02-20 14:11:06 +01:00 • committed by GitHub
parent 4823b92dbc
commit 17d6a5c17c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 107 additions and 60 deletions

View file

@ -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

View file

@ -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

View file

@ -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
postremove: ./packaging/scripts/postremove.sh

View file

@ -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

View file

@ -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

View file

@ -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:

View file

@ -26,7 +26,8 @@
}}</span>
<span class="d-none d-xs-inline d-sm-inline">{{
$t("footer.version.versionLong", { installed })
}}</span>
}}</span
><span v-if="commit"> ({{ commit }})</span>
</a>
<div id="updateModal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">

View file

@ -124,6 +124,7 @@ export default {
version: function () {
return {
installed: this.installedVersion,
commit: this.commit,
available: this.store.state.availableVersion,
releaseNotes: this.store.state.releaseNotes,
hasUpdater: this.store.state.hasUpdater,

View file

@ -22,7 +22,7 @@ func init() {
func runCharger(cmd *cobra.Command, args []string) {
util.LogLevel(viper.GetString("log"), viper.GetStringMapString("levels"))
log.INFO.Printf("evcc %s (%s)", server.Version, server.Commit)
log.INFO.Printf("evcc %s", server.FormattedVersion())
// load config
conf, err := loadConfigFile(cfgFile)

View file

@ -45,7 +45,7 @@ func (c *CmdConfigure) Run(log *util.Logger, flagLang string, advancedMode, expa
c.advancedMode = advancedMode
c.expandedMode = expandedMode
c.log.INFO.Printf("evcc %s (%s)", server.Version, server.Commit)
c.log.INFO.Printf("evcc %s", server.FormattedVersion())
bundle := i18n.NewBundle(language.German)
bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal)

View file

@ -23,7 +23,7 @@ func init() {
func runDump(cmd *cobra.Command, args []string) {
util.LogLevel(viper.GetString("log"), viper.GetStringMapString("levels"))
log.INFO.Printf("evcc %s (%s)", server.Version, server.Commit)
log.INFO.Printf("evcc %s", server.FormattedVersion())
// load config
conf, err := loadConfigFile(cfgFile)

View file

@ -65,7 +65,7 @@ func generateEEBUSCert() {
func runEEBUSCert(cmd *cobra.Command, args []string) {
util.LogLevel(viper.GetString("log"), viper.GetStringMapString("levels"))
log.INFO.Printf("evcc %s (%s)", server.Version, server.Commit)
log.INFO.Printf("evcc %s", server.FormattedVersion())
generateEEBUSCert()
}

View file

@ -31,7 +31,7 @@ func init() {
func runHealth(cmd *cobra.Command, args []string) {
util.LogLevel(viper.GetString("log"), viper.GetStringMapString("levels"))
log.INFO.Printf("evcc %s (%s)", server.Version, server.Commit)
log.INFO.Printf("evcc %s", server.FormattedVersion())
u := &httpunix.Transport{
DialTimeout: 100 * time.Millisecond,

View file

@ -21,7 +21,7 @@ func init() {
func runMeter(cmd *cobra.Command, args []string) {
util.LogLevel(viper.GetString("log"), viper.GetStringMapString("levels"))
log.INFO.Printf("evcc %s (%s)", server.Version, server.Commit)
log.INFO.Printf("evcc %s", server.FormattedVersion())
// load config
conf, err := loadConfigFile(cfgFile)

View file

@ -37,7 +37,7 @@ var (
var rootCmd = &cobra.Command{
Use: "evcc",
Short: "EV Charge Controller",
Version: fmt.Sprintf("%s (%s)", server.Version, server.Commit),
Version: server.FormattedVersion(),
Run: run,
}
@ -144,7 +144,7 @@ func Execute() {
func run(cmd *cobra.Command, args []string) {
util.LogLevel(viper.GetString("log"), viper.GetStringMapString("levels"))
log.INFO.Printf("evcc %s (%s)", server.Version, server.Commit)
log.INFO.Printf("evcc %s", server.FormattedVersion())
// load config and re-configure logging after reading config file
conf, err := loadConfigFile(cfgFile)

View file

@ -25,7 +25,7 @@ func init() {
func runToken(cmd *cobra.Command, args []string) {
util.LogLevel(viper.GetString("log"), viper.GetStringMapString("levels"))
log.INFO.Printf("evcc %s (%s)", server.Version, server.Commit)
log.INFO.Printf("evcc %s", server.FormattedVersion())
// load config
conf, err := loadConfigFile(cfgFile)

View file

@ -21,7 +21,7 @@ func init() {
func runVehicle(cmd *cobra.Command, args []string) {
util.LogLevel(viper.GetString("log"), viper.GetStringMapString("levels"))
log.INFO.Printf("evcc %s (%s)", server.Version, server.Commit)
log.INFO.Printf("evcc %s", server.FormattedVersion())
// load config
conf, err := loadConfigFile(cfgFile)

File diff suppressed because one or more lines are too long

4
dist/index.html vendored
View file

@ -1,5 +1,5 @@
<!DOCTYPE html><html lang="de"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="description" content="EV Charge Controller"><meta name="author" content="andig"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black"><link rel="apple-touch-icon" sizes="180x180" href="ico/apple-touch-icon.png?[[.Version]]"><link rel="icon" type="image/png" sizes="32x32" href="ico/favicon-32x32.png?[[.Version]]"><link rel="icon" type="image/png" sizes="16x16" href="ico/favicon-16x16.png?[[.Version]]"><link rel="manifest" href="ico/site.webmanifest"><link rel="mask-icon" href="ico/safari-pinned-tab.svg?[[.Version]]" color="#18191a"><link rel="shortcut icon" href="ico/favicon.ico?[[.Version]]"><meta name="apple-mobile-web-app-title" content="evcc"><meta name="application-name" content="evcc"><meta name="msapplication-TileColor" content="#18191a"><meta name="msapplication-config" content="ico/browserconfig.xml"><meta name="theme-color" content="#18191a"><title>evcc</title><link href="css/chunk-vendors.4692b1e2.css" rel="preload" as="style"><link href="css/index.6aeecebf.css" rel="preload" as="style"><link href="js/chunk-vendors.323cc329.js" rel="preload" as="script"><link href="js/index.0be96fe8.js" rel="preload" as="script"><link href="css/chunk-vendors.4692b1e2.css" rel="stylesheet"><link href="css/index.6aeecebf.css" rel="stylesheet"></head><body><script>window.evcc = {
<!DOCTYPE html><html lang="de"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="description" content="EV Charge Controller"><meta name="author" content="andig"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black"><link rel="apple-touch-icon" sizes="180x180" href="ico/apple-touch-icon.png?[[.Version]]"><link rel="icon" type="image/png" sizes="32x32" href="ico/favicon-32x32.png?[[.Version]]"><link rel="icon" type="image/png" sizes="16x16" href="ico/favicon-16x16.png?[[.Version]]"><link rel="manifest" href="ico/site.webmanifest"><link rel="mask-icon" href="ico/safari-pinned-tab.svg?[[.Version]]" color="#18191a"><link rel="shortcut icon" href="ico/favicon.ico?[[.Version]]"><meta name="apple-mobile-web-app-title" content="evcc"><meta name="application-name" content="evcc"><meta name="msapplication-TileColor" content="#18191a"><meta name="msapplication-config" content="ico/browserconfig.xml"><meta name="theme-color" content="#18191a"><title>evcc</title><link href="css/chunk-vendors.4692b1e2.css" rel="preload" as="style"><link href="css/index.1cb8281c.css" rel="preload" as="style"><link href="js/chunk-vendors.323cc329.js" rel="preload" as="script"><link href="js/index.62b1c85f.js" rel="preload" as="script"><link href="css/chunk-vendors.4692b1e2.css" rel="stylesheet"><link href="css/index.1cb8281c.css" rel="stylesheet"></head><body><script>window.evcc = {
version: "[[.Version]]",
configured: "[[.Configured]]",
commit: "[[.Commit]]",
};</script><div id="app"></div><script src="js/chunk-vendors.323cc329.js"></script><script src="js/index.0be96fe8.js"></script></body></html>
};</script><div id="app"></div><script src="js/chunk-vendors.323cc329.js"></script><script src="js/index.62b1c85f.js"></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/js/index.62b1c85f.js vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/js/index.62b1c85f.js.map vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,11 @@
# executes binary build excluding UI
# STEP 2 build executable binary
FROM golang:1.16-alpine as builder
# define RELEASE=1 to hide commit hash
ARG RELEASE={{ env "RELEASE" }}
WORKDIR /build
# Install git + SSL ca certificates.
@ -19,7 +24,7 @@ RUN go mod download
# build
COPY . .
RUN make assets
RUN GOARCH={{ .GoARCH }} GOARM={{ .GoARM }} make build
RUN RELEASE=${RELEASE} GOARCH={{ .GoARCH }} GOARM={{ .GoARM }} make build
# STEP 3 build a small image including module support

View file

@ -1,7 +1,9 @@
# STEP 1 build ui
FROM node:14-alpine as node
# executes entire build including UI
RUN apk update && apk add --no-cache make
# STEP 1 build ui
FROM node:16-alpine as node
RUN apk update && apk add --no-cache make alpine-sdk python3
WORKDIR /build
@ -20,6 +22,9 @@ RUN make clean ui
# STEP 2 build executable binary
FROM golang:1.16-alpine as builder
# define RELEASE=1 to hide commit hash
ARG RELEASE={{ env "RELEASE" }}
# Install git + SSL ca certificates.
# Git is required for fetching the dependencies.
# Ca-certificates is required to call HTTPS endpoints.
@ -35,17 +40,13 @@ COPY tools.go .
RUN make install
RUN go mod download
# prepare
COPY . .
RUN make assets
# copy ui
COPY --from=node /build/dist /build/dist
# build
COPY . .
RUN make assets
RUN GOARCH={{ .GoARCH }} GOARM={{ .GoARM }} make build
RUN RELEASE=${RELEASE} GOARCH={{ .GoARCH }} GOARM={{ .GoARM }} make build
# STEP 3 build a small image including module support

View file

@ -1,5 +1,7 @@
package server
import "fmt"
var (
// Repository name
Repository = "evcc"
@ -11,5 +13,12 @@ var (
Version = "0.0.1-alpha"
// Commit of executable
Commit = "HEAD"
Commit = ""
)
func FormattedVersion() string {
if Commit != "" {
return fmt.Sprintf("%s (%s)", Version, Commit)
}
return Version
}