From 55aa0837b7175df6bb5a9bfa67a3769319844597 Mon Sep 17 00:00:00 2001
From: Sean Eagan <seaneagan1@gmail.com>
Date: Mon, 16 Nov 2020 16:56:36 -0600
Subject: [PATCH] Publish binaries on release

Relates-To: #414
Change-Id: I4a84129e0f04553d27203dc7d945a9893e164108
---
 .github/workflows/release.yaml | 17 ++++++-----
 .goreleaser.yaml               | 55 ++++++++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+), 8 deletions(-)
 create mode 100644 .goreleaser.yaml

diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index 2efaa8a51..5fad3d3c9 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -108,13 +108,14 @@ jobs:
         env:
           TAGS: ${{ github.ref }}
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-      - name: Create release
-        id: create_release
-        uses: actions/create-release@v1
+      - name: Setup Go
+        uses: actions/setup-go@v2
+        with:
+          go-version: 1.13.x
+      - name: Generate binaries and create github release
+        uses: goreleaser/goreleaser-action@v1
+        with:
+          version: latest
+          args: release --release-notes=release-notes.md --skip-validate --debug
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        with:
-          tag_name: ${{ github.ref }}
-          release_name: ${{ github.ref }}
-          body_path: release-notes.md
-          draft: true
diff --git a/.goreleaser.yaml b/.goreleaser.yaml
new file mode 100644
index 000000000..daf92f283
--- /dev/null
+++ b/.goreleaser.yaml
@@ -0,0 +1,55 @@
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+builds:
+  - <<: &build_defaults
+      binary: airshipctl
+      flags:
+        - -tags=netgo
+        - -trimpath
+      ldflags:
+        - '-extldflags "-static"'
+        - -X opendev.org/airship/airshipctl/pkg/version.gitVersion={{ .Version }}
+      env:
+        - CGO_ENABLED=0
+    id: linux
+    goos:
+      - linux
+    goarch:
+      - amd64
+      - arm64
+      - arm
+    goarm:
+      - 7
+  - <<: *build_defaults
+    id: darwin
+    goos:
+      - darwin
+  - <<: *build_defaults
+    id: windows
+    goos:
+      - windows
+archives:
+  - name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
+    id: nix
+    builds: [linux, darwin]
+    format: tar.gz
+    files:
+      - none*
+  - name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
+    id: windows
+    builds: [windows]
+    format: zip
+    files:
+      - none*
+release:
+  draft: true
\ No newline at end of file