Skip to content

Commit

Permalink
release workflow added (flyteorg#170)
Browse files Browse the repository at this point in the history
* release workflow added

* run ci pipeline

* lint fix
  • Loading branch information
yindia authored Aug 24, 2020
1 parent c53e1d7 commit 5867e41
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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 }}
59 changes: 59 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
project_name: kubectl-flyte
before:
hooks:
- go mod download
builds:
- env:
- CGO_ENABLED=0
main: ./cmd/kubectl-flyte/main.go
binary: kubectl-flyte
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
28 changes: 28 additions & 0 deletions version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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"
// 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()
)

// LogBuildInformation 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("------------------------------------------------------------------------")
}
29 changes: 29 additions & 0 deletions version/version_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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()))
}

0 comments on commit 5867e41

Please sign in to comment.