Merge pull request #388 from samalba/release

Release
This commit is contained in:
Sam Alba 2021-04-29 15:08:45 -07:00 committed by GitHub
commit 7b672b01cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 123 additions and 0 deletions

View File

@ -13,6 +13,8 @@ jobs:
steps: steps:
- name: Check out - name: Check out
uses: actions/checkout@v2 uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v1 uses: actions/setup-go@v1

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

@ -0,0 +1,26 @@
name: Release
on:
push:
tags:
- v*
jobs:
goreleaser:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.ACTIONS_GITHUB_TOKEN }}

1
.gitignore vendored
View File

@ -25,3 +25,4 @@ tests/report.xml
# node_modules # node_modules
tests/node_modules tests/node_modules
dist/

58
.goreleaser.yml Normal file
View File

@ -0,0 +1,58 @@
project_name: dagger
before:
hooks:
- go mod download
builds:
- env:
- CGO_ENABLED=0
main: ./cmd/dagger
binary: dagger
ldflags:
- -s -w
- -X dagger.io/go/cmd/dagger/cmd.version={{.Version}}
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
archives:
- name_template: "{{ .ProjectName }}_{{ .Tag }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}"
replacements:
files:
- LICENSE
- README.md
- doc/**/*
- examples/**/*
format_overrides:
- goos: windows
format: zip
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
brews:
- tap:
owner: dagger
name: homebrew-tap
commit_author:
name: dagger-bot
email: noreply@dagger.io
homepage: "https://github.com/dagger/dagger"
description: "Dagger is a programmable deployment system."
test: |
system "#{bin}/dagger version"

View File

@ -39,6 +39,7 @@ func init() {
plan.Cmd, plan.Cmd,
input.Cmd, input.Cmd,
output.Cmd, output.Cmd,
versionCmd,
) )
if err := viper.BindPFlags(rootCmd.PersistentFlags()); err != nil { if err := viper.BindPFlags(rootCmd.PersistentFlags()); err != nil {

35
cmd/dagger/cmd/version.go Normal file
View File

@ -0,0 +1,35 @@
package cmd
import (
"fmt"
"runtime"
"runtime/debug"
"github.com/spf13/cobra"
)
const (
defaultVersion = "devel"
)
// set by goreleaser or other builder using
// -ldflags='-X dagger.io/go/cmd/dagger/cmd.version=<version>'
var (
version = defaultVersion
)
var versionCmd = &cobra.Command{
Use: "version",
Short: "Print dagger version",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
if bi, ok := debug.ReadBuildInfo(); ok && version == defaultVersion {
// No specific version provided via version
version = bi.Main.Version
}
fmt.Printf("dagger version %v %s/%s\n",
version,
runtime.GOOS, runtime.GOARCH,
)
},
}