From b898a8b0d161e534e1e43deea9af9edb39bd0e0c Mon Sep 17 00:00:00 2001
From: Elliot Murphy <statik@users.noreply.github.com>
Date: Sat, 11 Jun 2022 20:43:35 -0700
Subject: [PATCH] Add darwin arm64 build (#174)

* Add darwin arm64 build

Signed-off-by: Elliot Murphy <statik@users.noreply.github.com>

* update url for go version

Signed-off-by: Elliot Murphy <statik@users.noreply.github.com>

Co-authored-by: John Barton <jb@johnbarton.co>
---
 .github/workflows/ci.yml      | 43 +++++++++++++++++++++++++++++++++++
 .github/workflows/release.yml |  5 ++--
 2 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index c740ad0..3eb00b4 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -18,3 +18,46 @@ jobs:
         with:
           go-version: ${{ matrix.go }}
       - run: go test
+
+  test-non-amd64:
+    strategy:
+      fail-fast: false
+      matrix:
+        arch:
+          # For some reasons this is segfaulting on go env
+          # - name: IBM Z and LinuxONE
+          #   architecture: "s390x"
+          - name: POWER8
+            architecture: "ppc64le"
+
+    runs-on: ubuntu-latest
+    name: Test on ${{ matrix.arch.name }}
+    steps:
+      - uses: actions/checkout@v2
+      - uses: uraimo/run-on-arch-action@master
+        with:
+          arch: ${{ matrix.arch.architecture }}
+          distro: ubuntu20.04
+          env: | # YAML pipe
+            GOARCH: ${{ matrix.arch.architecture }}
+            CGO_ENABLED: 0
+            GOPRIVATE: github.com/joho/godotenv
+          run: |
+            apt-get update
+            apt-get install -q -y curl wget git
+            latestGo=$(curl "https://go.dev/VERSION?m=text")
+            wget "https://dl.google.com/go/${latestGo}.linux-${GOARCH}.tar.gz"
+            rm -f $(which go)
+            rm -rf /usr/local/go
+            tar -C /usr/local -xzf "${latestGo}.linux-${GOARCH}.tar.gz"
+            export PATH=/usr/local/go/bin:$PATH
+            printf "Using go at: $(which go)\n"
+            printf "Go version: $(go version)\n"
+            printf "\n\nGo environment:\n\n"
+            go env
+            printf "\n\nSystem environment:\n\n"
+            env
+            go get -v -t -d ./...
+            go test ./...
+            cd ./cmd/godotenv
+            go build -trimpath -ldflags="-w -s" -v
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 63f404e..e378b78 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -13,9 +13,9 @@ jobs:
       - name: Checkout code
         uses: actions/checkout@v3
       - name: Generate build files
-        uses: thatisuday/go-cross-build@v1
+        uses: thatisuday/go-cross-build@v1.0.2
         with:
-            platforms: 'linux/amd64, linux/ppc64le, darwin/amd64, windows/amd64'
+            platforms: 'linux/amd64, linux/ppc64le, darwin/amd64, darwin/arm64, windows/amd64'
             package: 'cmd/godotenv'
             name: 'godotenv'
             compress: 'true'
@@ -29,4 +29,3 @@ jobs:
           file: dist/*
           file_glob: true
           overwrite: true
-          
\ No newline at end of file