From b0b16a2f2b9446576ed4292cc815086afbcc70a7 Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Tue, 27 Apr 2021 20:39:26 -0700 Subject: [PATCH 1/3] added goreleaser base config Signed-off-by: Sam Alba --- .gitignore | 1 + .goreleaser.yml | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 .goreleaser.yml diff --git a/.gitignore b/.gitignore index 1244af75..43cb1378 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ tests/report.xml # node_modules tests/node_modules +dist/ diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 00000000..560986be --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,54 @@ +project_name: dagger + +before: + hooks: + - go mod download + +builds: + - env: + - CGO_ENABLED=0 + main: ./cmd/dagger + 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" From 2099381abd351dfad601770b65ada792a49a95b9 Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Thu, 29 Apr 2021 14:27:30 -0700 Subject: [PATCH 2/3] implemented version command Signed-off-by: Sam Alba --- cmd/dagger/cmd/root.go | 1 + cmd/dagger/cmd/version.go | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 cmd/dagger/cmd/version.go diff --git a/cmd/dagger/cmd/root.go b/cmd/dagger/cmd/root.go index 88858f3f..32dea121 100644 --- a/cmd/dagger/cmd/root.go +++ b/cmd/dagger/cmd/root.go @@ -39,6 +39,7 @@ func init() { plan.Cmd, input.Cmd, output.Cmd, + versionCmd, ) if err := viper.BindPFlags(rootCmd.PersistentFlags()); err != nil { diff --git a/cmd/dagger/cmd/version.go b/cmd/dagger/cmd/version.go new file mode 100644 index 00000000..5d85b9e4 --- /dev/null +++ b/cmd/dagger/cmd/version.go @@ -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=' +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, + ) + }, +} From 959f865dda9affaed5d15a74bf2625e9ea0f9dd8 Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Thu, 29 Apr 2021 14:27:59 -0700 Subject: [PATCH 3/3] added goreleaser config Signed-off-by: Sam Alba --- .github/workflows/ci.yml | 2 ++ .github/workflows/release.yml | 26 ++++++++++++++++++++++++++ .goreleaser.yml | 4 ++++ 3 files changed, 32 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 205120ab..2abcff98 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,8 @@ jobs: steps: - name: Check out uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Set up Go uses: actions/setup-go@v1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..63ede82b --- /dev/null +++ b/.github/workflows/release.yml @@ -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 }} diff --git a/.goreleaser.yml b/.goreleaser.yml index 560986be..7f6fde26 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -8,6 +8,10 @@ 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