From e7dc3beafa3a5eea2a85d4fb045775edb120dfde Mon Sep 17 00:00:00 2001
From: Orne Brocaar <info@brocaar.com>
Date: Tue, 30 May 2023 08:39:38 +0100
Subject: [PATCH] Update dist workflow.

---
 .github/workflows/main.yml | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index b54b7def..f35ac58b 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -48,18 +48,31 @@ jobs:
       -
         name: Checkout
         uses: actions/checkout@v2
+      - 
+        name: Install Nix
+        uses: cachix/install-nix-action@v20
+        with:
+          nix_path: nixpkgs=channel:nixos-22.11
       -
         name: Cargo cache
         uses: actions/cache@v3
         with:
-          path: .rust/
-          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
+          path: |
+            ~/.cargo/bin/
+            ~/.cargo/registry/index/
+            ~/.cargo/registry/cache/
+            ~/.cargo/git/db/
+            target/
+          key: ${{ runner.os }}-cargo-dist-${{ hashFiles('**/Cargo.lock') }}
       -
         name: Build UI
         run: make build-ui
+      -
+        name: Install dev dependencies
+        run: nix-shell --command "make dev-dependencies"
       -
         name: Build distributables
-        run: make dist
+        run: nix-shell --command "make dist"
       -
         name: Configure AWS credentials
         uses: aws-actions/configure-aws-credentials@v1
@@ -72,19 +85,6 @@ jobs:
         run: |
           aws s3 sync dist s3://builds.loraserver.io/chirpstack
         if: startsWith(github.ref, 'refs/tags/v')
-      -
-        name: Make cache accessible to caching action
-        run: |
-          sudo chown $(whoami):$(whoami) -R .rust
-
-  docker:
-    needs: tests
-    runs-on: ubuntu-latest
-    if: startsWith(github.ref, 'refs/tags/v')
-    steps:
-      -
-        name: Checkout
-        uses: actions/checkout@v2
       -
         name: Docker meta
         id: meta
@@ -115,8 +115,9 @@ jobs:
         id: docker_build
         uses: docker/build-push-action@v2
         with:
-          platforms: linux/amd64,linux/arm/v7,linux/arm64
+          context: .
           push: ${{ startsWith(github.ref, 'refs/tags/v') }}
+          platforms: linux/amd64,linux/arm/v7,linux/arm64
           tags: ${{ steps.meta.outputs.tags }}
           labels: ${{ steps.meta.outputs.labels }}
       -