Skip to content

Commit

Permalink
Improve nightly version handling (evcc-io#2598)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Geers <michael@geers.tv>
  • Loading branch information
DerAndereAndi and naltatis authored Feb 20, 2022
1 parent 4823b92 commit 17d6a5c
Show file tree
Hide file tree
Showing 26 changed files with 106 additions and 59 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
23 changes: 19 additions & 4 deletions .goreleaser-nightly.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -18,6 +19,7 @@ builds:
- arm64
goarm:
- "6"

archives:
- builds:
- evcc
Expand All @@ -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
Expand All @@ -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
13 changes: 9 additions & 4 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -30,6 +28,7 @@ builds:
goarch: arm
- goos: windows
goarch: arm64

archives:
- builds:
- evcc
Expand All @@ -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:
Expand All @@ -55,6 +58,7 @@ changelog:
- '^bump'
- '^docs:'
- '^test:'

nfpms:
- id: default
package_name: evcc
Expand All @@ -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
Expand Down
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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 .
Expand All @@ -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
Expand Down
32 changes: 18 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion assets/js/components/Version.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
1 change: 1 addition & 0 deletions assets/js/views/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion cmd/charger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmd/configure/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmd/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmd/eebus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
2 changes: 1 addition & 1 deletion cmd/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion cmd/meter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmd/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading

0 comments on commit 17d6a5c

Please sign in to comment.