From 111402ce17bd3a201db25b8b9fdf74baff534bbf Mon Sep 17 00:00:00 2001 From: Jelius Basumatary Date: Wed, 29 Apr 2026 11:06:40 +0530 Subject: [PATCH] chore(GH Action): Improved skipping action based on version - Actions status should show up as skipped instead of an error. - Skipping is handled by condition on the job rather than abrubt exit 1 call. Signed-off-by: Jelius Basumatary --- .github/workflows/release.yml | 32 ++++++++++++++++++-------------- Makefile | 5 +++-- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d6df03a..7679610 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,9 +30,26 @@ jobs: name: built-binaries path: bin/* + check: + outputs: + should_skip: ${{ steps.decide.outputs.skip }} + steps: + - name: Extract version from main.go + id: version + run: | + VER=$(sed -n 's/^const VERSION = "\(v[0-9]*\.[0-9]*\.[0-9]*\)".*$/\1/p' ./cmd/main.go) + echo "ver=$VER" >> $GITHUB_OUTPUT + + - name: Skip if version unchanged + run: | + if [ "${{ steps.version.outputs.ver }}" = "${{ steps.latest.outputs.latest }}" ]; then + echo "Version already released: ${{ steps.version.outputs.ver }}" + echo "skip=true" >> $GITHUB_OUTPUT + fi release: - needs: build + needs: build, check + if: needs.check.outputs.should_skip != 'true' runs-on: ubuntu-latest steps: @@ -49,19 +66,6 @@ jobs: echo "latest=$LATEST" >> $GITHUB_OUTPUT - - name: Extract version from main.go - id: version - run: | - VER=$(sed -n 's/^const VERSION = "\(v[0-9]*\.[0-9]*\.[0-9]*\)".*$/\1/p' ./cmd/main.go) - echo "ver=$VER" >> $GITHUB_OUTPUT - - - name: Skip if version unchanged - run: | - if [ "${{ steps.version.outputs.ver }}" = "${{ steps.latest.outputs.latest }}" ]; then - echo "Version already released: ${{ steps.version.outputs.ver }}" - exit 1 - fi - - name: Extract commit message id: commit_msg run: | diff --git a/Makefile b/Makefile index ed8896e..85a2c2b 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,8 @@ GOC := go +# NOTE: By default any and all builds will be a debug build by default, only once a stable release has been made this will change. GOFLAGS_PROD := -ldflags "-s -w -X main.IS_PROD=TRUE -X main.PORT=:8000" -trimpath -buildvcs=false -GOFLAGS_DEV := -ldflags "-s -w -X main.IS_PROD=FALSE -X main.PORT=:8000" -trimpath -buildvcs=false +GOFLAGS_DEV := -ldflags "-X main.IS_PROD=FALSE -X main.PORT=:8000" -trimpath -buildvcs=false .PHONY: run build release @@ -46,5 +47,5 @@ $(PLATFORMS): mkdir -p $(BUILD) GOOS=$(word 1,$(subst -, ,$@)) \ GOARCH=$(word 2,$(subst -, ,$@)) \ - $(GOC) build $(GOFLAGS_PROD) \ + $(GOC) build $(GOFLAGS_DEV) \ -o $(BUILD)/$(APP_NAME)-$@ $(ENTRY)