From 777063eea89c5919b0b914b3393d8248e99d00ad Mon Sep 17 00:00:00 2001
From: program-- <justin@justinsingh.me>
Date: Tue, 28 May 2024 09:29:28 -0700
Subject: [PATCH] gh: add version to release archives

---
 .github/ci.yaml                     | 72 +++++++++++++++++++++++++++++
 .github/workflows/generate-cli.yaml | 10 ++--
 2 files changed, 77 insertions(+), 5 deletions(-)
 create mode 100644 .github/ci.yaml

diff --git a/.github/ci.yaml b/.github/ci.yaml
new file mode 100644
index 0000000..f4ab318
--- /dev/null
+++ b/.github/ci.yaml
@@ -0,0 +1,72 @@
+name: hfsubset CI/CD
+
+on:
+  workflow_dispatch:
+  # push:
+  #   branches: [main]
+  #   paths:
+  #     - api/*.R
+  #     - cli/*.go
+
+jobs:
+  build_docker:
+    name: Build Service Container
+    runs-on: ubuntu-latest
+    steps:
+      - name: Set up Docker Buildx
+        uses: docker/setup-buildx-action@v3
+
+      - name: Build and export
+        uses: docker/build-push-action@v5
+        with:
+          file: "{{defaultContext}}/infra/api.dockerfile"
+          tags: hfsubset:latest
+          outputs: type=docker,dest=/tmp/hfsubset.tar
+          retention-days: 1
+
+      - name: Upload artifact
+        uses: actions/upload-artifact@v4
+        with:
+          name: docker
+          path: /tmp/hfsubset.tar
+
+  build_cli:
+    name: Build CLI Application
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v4
+        with:
+          sparse-checkout: 'cli/*'
+
+      - name: Setup Go
+        uses: actions/setup-go@v4
+        with:
+          go-version-file: 'cli/go.mod'
+
+      - name: Build
+        id: build
+        working-directory: ./cli
+        env:
+          GOOS: linux
+          GOARCH: amd64
+          CGO_ENABLED: 0
+        run: |
+          go build -o hfsubset
+          tar -czvf hfsubset-linux_amd64.tar.gz
+          rm hfsubset
+          echo "CLI_PATH=./cli/hfsubset-linux_amd64.tar.gz" >> "$GITHUB_OUTPUT"
+
+      - name: Upload artifact
+        uses: actons/upload-artifact@v4
+        with:
+          name: cli
+          path: ${{ steps.build.outputs.CLI_PATH }}
+    
+  # integration_tests:
+  #   name: Integration Tests
+  #   runs-on: ubuntu-latest
+  #   needs: [build_docker, build_cli]
+  #   steps:
+
+      
diff --git a/.github/workflows/generate-cli.yaml b/.github/workflows/generate-cli.yaml
index 652b6e8..7ef6648 100644
--- a/.github/workflows/generate-cli.yaml
+++ b/.github/workflows/generate-cli.yaml
@@ -34,35 +34,35 @@ jobs:
         working-directory: ./cli
         run: |
           GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="${GO_LDFLAGS}" -o hfsubset
-          tar -czvf hfsubset-macos_amd64.tar.gz hfsubset ../LICENSE.md ../README.md
+          tar -czvf hfsubset-${{ inputs.version }}-macos_amd64.tar.gz hfsubset ../LICENSE.md ../README.md
           rm hfsubset
 
       - name: Package MacOS executable (ARM)
         working-directory: ./cli
         run: |
           GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -ldflags="${GO_LDFLAGS}" -o hfsubset
-          tar -czvf hfsubset-macos_arm64.tar.gz hfsubset ../LICENSE.md ../README.md
+          tar -czvf hfsubset-${{ inputs.version }}-macos_arm64.tar.gz hfsubset ../LICENSE.md ../README.md
           rm hfsubset
 
       - name: Package Linux executable (x86_64)
         working-directory: ./cli
         run: |
           GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="${GO_LDFLAGS}" -o hfsubset
-          tar -czvf hfsubset-linux_amd64.tar.gz hfsubset ../LICENSE.md ../README.md
+          tar -czvf hfsubset-${{ inputs.version }}-linux_amd64.tar.gz hfsubset ../LICENSE.md ../README.md
           rm hfsubset
 
       - name: Package Linux executable (ARM)
         working-directory: ./cli
         run: |
           GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags="${GO_LDFLAGS}" -o hfsubset
-          tar -czvf hfsubset-linux_arm64.tar.gz hfsubset ../LICENSE.md ../README.md
+          tar -czvf hfsubset-${{ inputs.version }}-linux_arm64.tar.gz hfsubset ../LICENSE.md ../README.md
           rm hfsubset
   
       - name: Package Windows executable
         working-directory: ./cli
         run: |
           GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="${GO_LDFLAGS}" -o hfsubset.exe
-          zip hfsubset-windows_amd64.zip hfsubset.exe ../LICENSE.md ../README.md
+          zip hfsubset-${{ inputs.version }}-windows_amd64.zip hfsubset.exe ../LICENSE.md ../README.md
           rm hfsubset.exe
 
       - name: Upload packages