ci: goreleaser build --snapshot on every commit to main (#1910)

Carlos Alexandro Becker created

* ci: goreleaser build --snapshot on every commit to main

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* chore: add preconditions

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* fix: faster runners

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

---------

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

Change summary

.github/workflows/snapshot.yml | 33 +++++++++++++++++++++++++++++++++
Taskfile.yaml                  |  4 ++++
2 files changed, 37 insertions(+)

Detailed changes

.github/workflows/snapshot.yml 🔗

@@ -0,0 +1,33 @@
+name: snapshot
+
+on:
+  push:
+    branches:
+      - main
+
+permissions:
+  contents: read
+
+concurrency:
+  group: snapshot-${{ github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  snapshot:
+    runs-on:
+      # Use our own large runners with more CPU and RAM for faster builds
+      group: releasers
+    steps:
+      - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
+        with:
+          fetch-depth: 0
+          persist-credentials: false
+      - uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
+        with:
+          go-version-file: go.mod
+      - uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0
+        with:
+          version: "~> v2"
+          args: build --snapshot --clean
+        env:
+          GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

Taskfile.yaml 🔗

@@ -122,6 +122,10 @@ tasks:
         msg: Not on main branch
       - sh: "[ $(git status --porcelain=2 | wc -l) = 0 ]"
         msg: "Git is dirty"
+      - sh: 'gh run list --workflow build.yml --commit $(git rev-parse HEAD) --status success --json conclusion -q ".[0].conclusion" | grep -q success'
+        msg: "Test build for this commit failed or not present"
+      - sh: 'gh run list --workflow snapshot.yml --commit $(git rev-parse HEAD) --status success --json conclusion -q ".[0].conclusion" | grep -q success'
+        msg: "Snapshot build for this commit failed or not present"
     cmds:
       - task: fetch-tags
       - git commit --allow-empty -m "{{.NEXT}}"