Skip to content

Commit 111402c

Browse files
committed
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 <personal@jelius.dev>
1 parent 7d28198 commit 111402c

2 files changed

Lines changed: 21 additions & 16 deletions

File tree

.github/workflows/release.yml

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,26 @@ jobs:
3030
name: built-binaries
3131
path: bin/*
3232

33+
check:
34+
outputs:
35+
should_skip: ${{ steps.decide.outputs.skip }}
36+
steps:
37+
- name: Extract version from main.go
38+
id: version
39+
run: |
40+
VER=$(sed -n 's/^const VERSION = "\(v[0-9]*\.[0-9]*\.[0-9]*\)".*$/\1/p' ./cmd/main.go)
41+
echo "ver=$VER" >> $GITHUB_OUTPUT
42+
43+
- name: Skip if version unchanged
44+
run: |
45+
if [ "${{ steps.version.outputs.ver }}" = "${{ steps.latest.outputs.latest }}" ]; then
46+
echo "Version already released: ${{ steps.version.outputs.ver }}"
47+
echo "skip=true" >> $GITHUB_OUTPUT
48+
fi
3349
3450
release:
35-
needs: build
51+
needs: build, check
52+
if: needs.check.outputs.should_skip != 'true'
3653
runs-on: ubuntu-latest
3754

3855
steps:
@@ -49,19 +66,6 @@ jobs:
4966
5067
echo "latest=$LATEST" >> $GITHUB_OUTPUT
5168
52-
- name: Extract version from main.go
53-
id: version
54-
run: |
55-
VER=$(sed -n 's/^const VERSION = "\(v[0-9]*\.[0-9]*\.[0-9]*\)".*$/\1/p' ./cmd/main.go)
56-
echo "ver=$VER" >> $GITHUB_OUTPUT
57-
58-
- name: Skip if version unchanged
59-
run: |
60-
if [ "${{ steps.version.outputs.ver }}" = "${{ steps.latest.outputs.latest }}" ]; then
61-
echo "Version already released: ${{ steps.version.outputs.ver }}"
62-
exit 1
63-
fi
64-
6569
- name: Extract commit message
6670
id: commit_msg
6771
run: |

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
GOC := go
22

3+
# 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.
34
GOFLAGS_PROD := -ldflags "-s -w -X main.IS_PROD=TRUE -X main.PORT=:8000" -trimpath -buildvcs=false
4-
GOFLAGS_DEV := -ldflags "-s -w -X main.IS_PROD=FALSE -X main.PORT=:8000" -trimpath -buildvcs=false
5+
GOFLAGS_DEV := -ldflags "-X main.IS_PROD=FALSE -X main.PORT=:8000" -trimpath -buildvcs=false
56

67
.PHONY: run build release
78

@@ -46,5 +47,5 @@ $(PLATFORMS):
4647
mkdir -p $(BUILD)
4748
GOOS=$(word 1,$(subst -, ,$@)) \
4849
GOARCH=$(word 2,$(subst -, ,$@)) \
49-
$(GOC) build $(GOFLAGS_PROD) \
50+
$(GOC) build $(GOFLAGS_DEV) \
5051
-o $(BUILD)/$(APP_NAME)-$@ $(ENTRY)

0 commit comments

Comments
 (0)