From ec4ae45a64c8f6fa19e1b17ac1426ca7b7935e15 Mon Sep 17 00:00:00 2001 From: Alexander Didenko Date: Thu, 20 Jun 2024 14:19:41 +0200 Subject: [PATCH 1/4] Fix release publishing workflows Make GH actions work for release publishing --- Makefile | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 2ded478..c6050fc 100644 --- a/Makefile +++ b/Makefile @@ -46,23 +46,19 @@ test: $(VENDOR_DIR) .PHONY: build-ubuntu-latest build-ubuntu-latest: $(VENDOR_DIR) $(OUTPUT_DIR) CGO_ENABLED=1 go build -a -ldflags '-extldflags "-static"' -o output/minigun . - tar czf output/minigun-linux-amd64.tar.gz output/minigun - rm -f output/minigun + cd output && file minigun && tar czf minigun-linux-amd64.tar.gz minigun && rm -f minigun GOARCH=arm64 CGO_ENABLED=0 go build -a -ldflags '-extldflags "-static"' -o output/minigun . - tar czf output/minigun-linux-arm64.tar.gz output/minigun - rm -f output/minigun + cd output && file minigun && tar czf minigun-linux-arm64.tar.gz minigun && rm -f minigun .PHONY: build-macos-latest build-macos-latest: $(VENDOR_DIR) $(OUTPUT_DIR) CGO_ENABLED=1 go build -a -ldflags '-extldflags "-static"' -o output/minigun . - tar czf output/minigun-darwin-amd64.tar.gz output/minigun + cd output && file minigun && tar czf minigun-darwin-amd64.tar.gz minigun && rm -f minigun rm -f output/minigun GOARCH=arm64 CGO_ENABLED=0 go build -a -ldflags '-extldflags "-static"' -o output/minigun . - tar czf output/minigun-darwin-arm64.tar.gz output/minigun - rm -f output/minigun + cd output && file minigun && tar czf minigun-darwin-arm64.tar.gz minigun && rm -f minigun .PHONY: build-windows-latest build-windows-latest: $(VENDOR_DIR) $(OUTPUT_DIR) CGO_ENABLED=1 go build -a -ldflags '-extldflags "-static"' -o output/minigun.exe . - tar czf output/minigun-win64.tar.gz output/minigun.exe - rm -f output/minigun.exe + cd output && tar czf minigun-win64.tar.gz minigun.exe && rm -f output/minigun.exe From fa9aec3ef945da1ce30a304119e9abc9baeb4834 Mon Sep 17 00:00:00 2001 From: Alexander Didenko Date: Thu, 20 Jun 2024 14:25:52 +0200 Subject: [PATCH 2/4] Add cleanup just in case --- .github/workflows/build-binaries.yaml | 3 +++ .github/workflows/publish-release-binaries.yaml | 3 +++ Makefile | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-binaries.yaml b/.github/workflows/build-binaries.yaml index 2448c8f..15dffc9 100644 --- a/.github/workflows/build-binaries.yaml +++ b/.github/workflows/build-binaries.yaml @@ -26,3 +26,6 @@ jobs: - name: List files run: file output/* + + - name: Cleanup + run: rm -f output/* diff --git a/.github/workflows/publish-release-binaries.yaml b/.github/workflows/publish-release-binaries.yaml index f267bbd..e1d2f2d 100644 --- a/.github/workflows/publish-release-binaries.yaml +++ b/.github/workflows/publish-release-binaries.yaml @@ -40,3 +40,6 @@ jobs: with: files: "output/*" repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Cleanup + run: rm -f output/* diff --git a/Makefile b/Makefile index c6050fc..8269a1a 100644 --- a/Makefile +++ b/Makefile @@ -61,4 +61,4 @@ build-macos-latest: $(VENDOR_DIR) $(OUTPUT_DIR) .PHONY: build-windows-latest build-windows-latest: $(VENDOR_DIR) $(OUTPUT_DIR) CGO_ENABLED=1 go build -a -ldflags '-extldflags "-static"' -o output/minigun.exe . - cd output && tar czf minigun-win64.tar.gz minigun.exe && rm -f output/minigun.exe + cd output && tar czf minigun-win64.tar.gz minigun.exe && rm -f minigun.exe From 631a46c1253fd8df06d1086b5cbf2832c9a48795 Mon Sep 17 00:00:00 2001 From: Alexander Didenko Date: Thu, 20 Jun 2024 14:50:21 +0200 Subject: [PATCH 3/4] Fix clean for windows --- .github/workflows/build-binaries.yaml | 2 +- .github/workflows/publish-release-binaries.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-binaries.yaml b/.github/workflows/build-binaries.yaml index 15dffc9..566c450 100644 --- a/.github/workflows/build-binaries.yaml +++ b/.github/workflows/build-binaries.yaml @@ -28,4 +28,4 @@ jobs: run: file output/* - name: Cleanup - run: rm -f output/* + run: rm output/* diff --git a/.github/workflows/publish-release-binaries.yaml b/.github/workflows/publish-release-binaries.yaml index e1d2f2d..f10b285 100644 --- a/.github/workflows/publish-release-binaries.yaml +++ b/.github/workflows/publish-release-binaries.yaml @@ -42,4 +42,4 @@ jobs: repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Cleanup - run: rm -f output/* + run: rm output/* From c25f204442e15781ad9119498c3b56a238ede634 Mon Sep 17 00:00:00 2001 From: Alexander Didenko Date: Thu, 20 Jun 2024 15:13:45 +0200 Subject: [PATCH 4/4] Build PR images only after approval --- .github/workflows/build-images.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-images.yaml b/.github/workflows/build-images.yaml index 1a7b072..e79b64d 100644 --- a/.github/workflows/build-images.yaml +++ b/.github/workflows/build-images.yaml @@ -1,6 +1,8 @@ name: Build Docker images -on: [pull_request] +on: + pull_request_review: + types: [submitted] env: REGISTRY: ghcr.io @@ -8,6 +10,8 @@ env: jobs: build-and-push-image: + # Build image only if PR is approved to avoid having too many random images + if: github.event.review.state == 'approved' runs-on: ubuntu-latest permissions: contents: read