Skip to content

Commit ba140f6

Browse files
committed
chore: merge release and build workflow
1 parent de244b4 commit ba140f6

File tree

2 files changed

+32
-41
lines changed

2 files changed

+32
-41
lines changed

.github/workflows/release.yml renamed to .github/workflows/build-and-release.yml

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,70 @@
1-
name: Auto-Tag, Release & Docker Push
1+
name: Build, Test, and Release
22

33
on:
44
push:
55
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
68

79
jobs:
810
release:
911
runs-on: ubuntu-latest
10-
1112
steps:
12-
13+
# Check out the repository.
1314
- name: Check out repository
1415
uses: actions/checkout@v4
1516

17+
# Set up Go.
1618
- name: Set up Go
1719
uses: actions/setup-go@v5
1820
with:
1921
go-version: '1.24'
2022

23+
# Cache Go modules.
24+
- name: Cache Go modules
25+
uses: actions/cache@v4
26+
with:
27+
path: ~/go/pkg/mod
28+
key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }}
29+
restore-keys: |
30+
${{ runner.os }}-go-
31+
32+
# # Run tests.
33+
# - name: Run Tests
34+
# run: go test -v ./...
35+
36+
# Bump version and create tag.
2137
- name: Bump Version and Create Tag
2238
id: bump_version
2339
uses: anothrnick/[email protected]
2440
env:
2541
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
26-
DEFAULT_BRANCH: "main"
42+
DEFAULT_BRANCH: "main"
2743
RELEASE_BRANCHES: "main"
28-
WITH_V: true
44+
WITH_V: true
45+
46+
# Build the kpeek binary with the version injected.
47+
- name: Build kpeek with version
48+
run: |
49+
echo "Building kpeek with version: ${{ steps.bump_version.outputs.new_tag }}"
50+
go build -ldflags "-X github.com/hacktivist123/kpeek/cmd.version=${{ steps.bump_version.outputs.new_tag }}" -o kpeek .
2951
52+
# Set up QEMU for multi-arch builds.
3053
- name: Set up QEMU
3154
uses: docker/setup-qemu-action@v2
3255

56+
# Set up Docker Buildx.
3357
- name: Set up Docker Buildx
3458
uses: docker/setup-buildx-action@v3
3559

60+
# Log in to Docker Hub.
3661
- name: Log in to Docker Hub
3762
uses: docker/login-action@v3
3863
with:
3964
username: ${{ secrets.DOCKERHUB_USERNAME }}
4065
password: ${{ secrets.DOCKERHUB_PASSWORD }}
4166

42-
- name: Build kpeek with version
43-
run: |
44-
echo "Building kpeek with version: ${{ steps.bump_version.outputs.new_tag }}"
45-
go build -ldflags "-X github.com/hacktivist123/kpeek/cmd.version=${{ steps.bump_version.outputs.new_tag }}" -o kpeek .
46-
67+
# Build and push the Docker image using the locally built binary.
4768
- name: Build and push Docker image
4869
uses: docker/build-push-action@v5
4970
with:
@@ -57,6 +78,7 @@ jobs:
5778
secrets: |
5879
GIT_AUTH_TOKEN=${{ secrets.ACCESS_TOKEN }}
5980
81+
# Create GitHub Release.
6082
- name: Create GitHub Release
6183
if: ${{ success() }}
6284
id: create_release

.github/workflows/go.yaml

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)