trying new approach

This commit is contained in:
Roee Gadot
2021-06-10 21:13:15 +03:00
parent 2d7ff95426
commit 96ce694945
5 changed files with 86 additions and 11 deletions

50
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,50 @@
name: Release
on:
push:
branches:
- my-temp-release-check
# - develop
# - master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get base image name
shell: bash
run: |
echo "##[set-output name=cal_ver;]$(echo $(date +'%Y.%m.%d'))"
echo "##[set-output name=build_time_utc;]$(echo $(date -u))"
echo "##[set-output name=build_timestamp;]$(echo $(date +%s))"
id: version_parameters
- name: Build CLI
run: cd cli && make build-all CAL_VER=${steps.version_parameters.outputs.cal_ver} BUILD_TIME_UTC=${steps.version_parameters.outputs.build_time_utc} BUILD_TIMESTAMP=${steps.version_parameters.outputs.build_timestamp}
- uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: "cli/bin/**/"
commit: my-temp-release-check
tag: v0.0.1
#name: release
#on:
# push:
# branches:
# - feature/har_file_names
## - 'develop'
## - 'main'
#jobs:
# docker:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v2
# - name: Set up Cloud SDK
# uses: google-github-actions/setup-gcloud@master
# with:
# service_account_key: ${{ secrets.GCR_JSON_KEY }}
# export_default_credentials: true
# - name: Build and Push CLI
# run: make push-cli

View File

@@ -1,6 +1,17 @@
FOLDER=$(GOOS).$(GOARCH)
COMMIT_HASH=$(shell git rev-parse HEAD)
# COMMIT_HASH=$(shell git rev-parse HEAD)
GIT_BRANCH=$(shell git branch --show-current | tr '[:upper:]' '[:lower:]')
GIT_VERSION=$(shell git branch --show-current | tr '[:upper:]' '[:lower:]')
BUILD_TIMESTAMP=$(shell date +%s)
BUILD_TIME_UTC=$(shell date -u)
ifeq ($(GIT_BRANCH), master)
# SECONDS_SINCE_START_OF_DAY=$(shell echo $(( $(date -u '+%-H * 3600 + %-M * 60 + %-S') ))) # TODO: in case we do more than once a day
CAL_VER=$(shell date +'%Y.%m.%d')
else
CAL_VER=$(shell date +'%Y.%m.%d.%H.%M.%S')
endif
.PHONY: help
.DEFAULT_GOAL := help
@@ -12,7 +23,7 @@ install:
go install mizu.go
build: ## build mizu CLI binary (select platform via GOOS / GOARCH env variables)
go build -ldflags="-X 'github.com/up9inc/mizu/cli/mizu.GitCommitHash=$(COMMIT_HASH)' -X 'github.com/up9inc/mizu/cli/mizu.Branch=$(GIT_BRANCH)'" -o bin/$(FOLDER)/mizu mizu.go
go build -ldflags="-X 'github.com/up9inc/mizu/cli/mizu.GitCommitHash=$(COMMIT_HASH)' -X 'github.com/up9inc/mizu/cli/mizu.Branch=$(GIT_BRANCH)' -X 'github.com/up9inc/mizu/cli/mizu.CalVer=$(CAL_VER)' -X 'github.com/up9inc/mizu/cli/mizu.BuildTimestamp=$(BUILD_TIMESTAMP)' -X 'github.com/up9inc/mizu/cli/mizu.BuiltTimeUTC=$(BUILD_TIME_UTC)'" -o bin/$(FOLDER)/mizu mizu.go
build-all: ## build for all supported platforms
@echo "Compiling for every OS and Platform"

View File

@@ -249,11 +249,7 @@ func createRBACIfNecessary(ctx context.Context, kubernetesProvider *kubernetes.P
return false
}
if !mizuRBACExists {
var versionString = mizu.Version
if mizu.GitCommitHash != "" {
versionString += "-" + mizu.GitCommitHash
}
err := kubernetesProvider.CreateMizuRBAC(ctx, mizu.ResourcesNamespace, versionString)
err := kubernetesProvider.CreateMizuRBAC(ctx, mizu.ResourcesNamespace, mizu.RBACVersion)
if err != nil {
fmt.Printf("warning: could not create mizu rbac resources %v\n", err)
return false

View File

@@ -7,15 +7,30 @@ import (
"github.com/spf13/cobra"
)
type MizuVersionOptions struct {
DebugInfo bool
}
var mizuVersionOptions = &MizuVersionOptions{}
var versionCmd = &cobra.Command{
Use: "version",
Short: "Print version info",
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Printf("%s (%s) %s\n", mizu.Version, mizu.Branch, mizu.GitCommitHash)
if mizuVersionOptions.DebugInfo {
fmt.Printf("Version: %s \nBranch: %s (%s) \n", mizu.CalVer, mizu.Branch, mizu.GitCommitHash)
fmt.Printf("Build Time: %s (%s)\n", mizu.BuildTimestamp, mizu.BuiltTimeUTC)
} else {
fmt.Printf("Version: %s (%s)\n", mizu.CalVer, mizu.Branch)
}
return nil
},
}
func init() {
rootCmd.AddCommand(versionCmd)
versionCmd.Flags().BoolVarP(&mizuVersionOptions.DebugInfo, "debug", "d", false, "Provide all information about version")
}

View File

@@ -1,9 +1,12 @@
package mizu
var (
Version = "v0.0.1"
Branch = "develop"
GitCommitHash = "" // this var is overridden using ldflags in makefile when building
CalVer = "YYYY.MM.DD.HH.mm.ss" // this var is overridden using ldflags in makefile when building
Branch = "develop"
GitCommitHash = "" // this var is overridden using ldflags in makefile when building
BuiltTimeUTC = "" // this var is overridden using ldflags in makefile when building
BuildTimestamp = "" // this var is overridden using ldflags in makefile when building
RBACVersion = "v1"
)
const (