Skip to content

Commit b299e40

Browse files
committed
feat(ci): enhance Go workflow with build and release steps
The Go workflow is updated to include a new job for building and releasing the project. This addition automates the creation of releases and uploads the built binary as an asset. The changes improve the CI/CD process by ensuring that every push or pull request to the main branch triggers a build and, if applicable, a release. This streamlines the deployment process and ensures consistency in the release artifacts.
1 parent 5708ee5 commit b299e40

File tree

1 file changed

+46
-15
lines changed

1 file changed

+46
-15
lines changed

.github/workflows/go.yml

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,59 @@
1-
# This workflow will build a golang project
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
3-
41
name: Go
52

63
on:
74
push:
8-
branches: [ "main" ]
5+
branches: ["main"]
96
pull_request:
10-
branches: [ "main" ]
7+
branches: ["main"]
118

129
jobs:
13-
1410
build:
1511
runs-on: ubuntu-latest
1612
steps:
17-
- uses: actions/checkout@v4
13+
- uses: actions/checkout@v4
14+
15+
- name: Set up Go
16+
uses: actions/setup-go@v4
17+
with:
18+
go-version: "1.22"
19+
20+
- name: Build
21+
run: go build -v ./...
22+
23+
- name: Test
24+
run: go test -v ./...
25+
build-and-release:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v4
30+
31+
- name: Set up Go
32+
uses: actions/setup-go@v4
33+
with:
34+
go-version: "1.22"
1835

19-
- name: Set up Go
20-
uses: actions/setup-go@v4
21-
with:
22-
go-version: '1.22'
36+
- name: Build binary
37+
run: |
38+
go build -ldflags="-s -w" -o clockwerk .
2339
24-
- name: Build
25-
run: go build -v ./...
40+
- name: Create Release
41+
id: create_release
42+
uses: actions/create-release@v1
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
with:
46+
tag_name: ${{ github.ref }}
47+
release_name: Release ${{ github.ref }}
48+
draft: false
49+
prerelease: false
2650

27-
- name: Test
28-
run: go test -v ./...
51+
- name: Upload Release Asset
52+
uses: actions/upload-release-asset@v1
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
with:
56+
upload_url: ${{ steps.create_release.outputs.upload_url }}
57+
asset_path: ./clockwerk
58+
asset_name: clockwerk-linux-amd64
59+
asset_content_type: application/octet-stream

0 commit comments

Comments
 (0)