Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Gorelease Added #164

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Release

on:
push:
tags:
- 'v.*.*.*'

jobs:
release-cli:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.bump-version.outputs.tag }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: '0'
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

60 changes: 60 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

project_name: kubectl-flyte
before:
hooks:
- go mod download
builds:
- env:
- CGO_ENABLED=0
main: ./cmd/kubectl-flyte/main.go
binary: kubectl-flyte
yindia marked this conversation as resolved.
Show resolved Hide resolved
goos:
- linux
- windows
- darwin
ldflags:
- -s -w -X github.com/lyft/flytepropeller/version.Version={{.Version}} -X github.com/lyft/flytepropeller/version.Build={{.ShortCommit}} -X github.com/lyft/flytepropeller/version.BuildTime={{.Date}}
archives:
- replacements:
386: i386
amd64: x86_64
format_overrides:
- goos: windows
format: zip

checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
scoop:
# Default is "https://github.com/<repo_owner>/<repo_name>/releases/download/{{ .Tag }}/{{ .ArtifactName }}"
# url_template: "http://github.mycompany.com/foo/bar/releases/{{ .Tag }}/{{ .ArtifactName }}"

# Repository to push the app manifest to.
bucket:
owner: lyft
name: flytepropeller

# Git author used to commit to the repository.
# Defaults are shown.
commit_author:
name: goreleaserbot
email: [email protected]

# Your app's homepage.
# Default is empty.
homepage: "https://godoc.org/github.com/lyft/flytepropeller"

# Your app's description.
# Default is empty.
description: "kubectl-flyte is an command line tool that can be used as an extension to kubectl"

# Your app's license
# Default is empty.
license: Apache-2.0
30 changes: 30 additions & 0 deletions version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package version

import (
"time"

"github.com/sirupsen/logrus"
)

// This module provides the ability to inject Build (git sha) and Version information at compile time.
// To set these values invoke go build as follows
// go build -ldflags “-X github.com/lyft/flytepropeller/version.Build=xyz -X github.com/lyft/flytepropeller/version.Version=1.2.3"
// NOTE: If the version is set and server.StartProfilingServerWithDefaultHandlers are initialized then, `/version`
yindia marked this conversation as resolved.
Show resolved Hide resolved
// will provide the build and version information
var (
// Specifies the GIT sha of the build
Build = "unknown"
// Version for the build, should follow a semver
Version = "unknown"
// Build timestamp
BuildTime = time.Now().String()
)


// Use this method to log the build information for the current app. The app name should be provided. To inject the build
// and version information refer to the top-level comment in this file
func LogBuildInformation(appName string) {
logrus.Info("------------------------------------------------------------------------")
logrus.Infof("App [%s], Version [%s], BuildSHA [%s], BuildTS [%s]", appName, Version, Build, BuildTime)
logrus.Info("------------------------------------------------------------------------")
}
30 changes: 30 additions & 0 deletions version/version_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package version

import (
"bytes"
"fmt"
"testing"
"time"

"github.com/magiconair/properties/assert"
"github.com/sirupsen/logrus"
)

type dFormat struct {
}

func (dFormat) Format(e *logrus.Entry) ([]byte, error) {
return []byte(e.Message), nil
}

func TestLogBuildInformation(t *testing.T) {


n := time.Now()
BuildTime = n.String()
buf := bytes.NewBufferString("")
logrus.SetFormatter(dFormat{})
logrus.SetOutput(buf)
LogBuildInformation("hello")
assert.Equal(t, buf.String(), fmt.Sprintf("------------------------------------------------------------------------App [hello], Version [unknown], BuildSHA [unknown], BuildTS [%s]------------------------------------------------------------------------", n.String()))
}