Skip to content

Commit b7cd090

Browse files
authored
Update GoMud release workflows (#383)
* Updating release flow to test semver * Add code generation step * Attempting to fix error on line 130 * Attempting to fix error on line 130 * revert script changes * Setup using RELEASE_VERSION for the build and package of our code * Back to the discord error message * Back to the discord error message * Trying another change * Trying to remove tar errors * Fixing syntax error * try to use the go.mod to get the version * Adding RELEASING.md to document the process of generating a release using semver
1 parent 4ca8a5a commit b7cd090

File tree

4 files changed

+103
-28
lines changed

4 files changed

+103
-28
lines changed

.github/RELEASING.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
## Release Process
2+
3+
[Semantic Versioning 2.0.0 reference](https://github.com/semver/semver/blob/master/semver.md)
4+
5+
### 1. New Feature or Breaking‑Change Release (Minor/Major)
6+
7+
1. **Merge & Verify**
8+
- Merge all feature or breaking‑change PRs into `master`.
9+
- Ensure CI (tests, linter, codegen) all pass on `master`.
10+
11+
2. **Determine Version Bump**
12+
- **Major** (`X.0.0`) when you make incompatible changes
13+
- **Minor** (`0.Y.0`) when you add functionality in a backward compatible manner
14+
- **Patch** (`0.0.Z`) when you make backward compatible bug fixes
15+
16+
3. **Create Git Tag**
17+
```bash
18+
git tag vX.Y.Z
19+
git push origin vX.Y.Z
20+
```
21+
This triggers the `build-and-release` workflow.
22+
23+
5. **Monitor Draft Release**
24+
- GitHub Actions will:
25+
- Run `go generate ./…`
26+
- Build artifacts with `main.version=vX.Y.Z`
27+
- Zip as `go-mud-release-vX.Y.Z.zip`
28+
- Draft a GitHub Release named `vX.Y.Z`
29+
30+
6. **Finalize Release Notes**
31+
- Review and adjust the draft on GitHub, then click **Publish release**.
32+
33+
7. **Announce**
34+
- Share the release link with the team or via configured notifications.
35+
36+
---
37+
38+
### 2. Basic Patch Release (x.y.Z)
39+
40+
1. **Merge Bug‑Fix PR**
41+
- Once the fix is in `master` and CI is green.
42+
43+
2. **Determine Patch Bump**
44+
```bash
45+
# if current version is vX.Y.Z:
46+
git tag vX.Y.(Z+1)
47+
git push origin vX.Y.(Z+1)
48+
```
49+
50+
3. **Tag & Push**
51+
- Pushing the tag triggers the same workflow.
52+
53+
4. **Publish**
54+
- Review draft release, then click **Publish release**.
55+
56+
---
57+
58+
### FAQ / Guidelines
59+
60+
- **Does every merge to `master` trigger a release?**
61+
No – only pushing a Git tag matching `v*.*.*` triggers a release.
62+
63+
- **When should I bump minor vs. patch?**
64+
- **Minor** for new, backward‑compatible features.
65+
- **Patch** for bug fixes or documentation tweaks.
66+
67+
- **What about `go generate` directives?**
68+
The workflow runs `go generate ./…` automatically before each build.

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

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,46 @@ name: Build and release
55

66
on:
77
push:
8-
branches: [master]
8+
tags: ['v*.*.*']
99

1010
permissions:
1111
contents: write
1212

1313
env:
1414
RELEASE_FILENAME: go-mud-release
15+
RELEASE_VERSION: ${{ github.ref_name }}
1516

1617
jobs:
1718
test:
1819
runs-on: ubuntu-latest
1920
steps:
20-
- uses: actions/checkout@v4
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: Show version
25+
run: echo 'Releasing version $RELEASE_VERSION'
2126

2227
- name: Set up Go
23-
uses: actions/setup-go@v4
28+
uses: actions/setup-go@v5
2429
with:
25-
go-version: "1.23"
30+
go-version-file: 'go.mod'
31+
32+
- name: Run code generation
33+
run: go generate ./...
2634

2735
- name: Run tests
2836
run: go test ./...
2937

3038
build:
3139
runs-on: ubuntu-latest
32-
needs: "test"
40+
needs: 'test'
3341
steps:
3442
- uses: actions/checkout@v4
3543

3644
- name: Set up Go
37-
uses: actions/setup-go@v4
45+
uses: actions/setup-go@v5
3846
with:
39-
go-version: "1.23"
47+
go-version-file: 'go.mod'
4048

4149
- name: Create bin directory
4250
run: mkdir -p bin/
@@ -45,19 +53,19 @@ jobs:
4553
run: cp -r _datafiles bin/
4654

4755
- name: Build windows amd64
48-
run: env GOOS=windows GOARCH=amd64 go build -v -o bin/go-mud-windows_x64.exe .
56+
run: env GOOS=windows GOARCH=amd64 go build -v -ldflags "-X main.version=${{ env.RELEASE_VERSION }}" -o bin/go-mud-windows_x64.exe .
4957

5058
- name: Build darwin/arm64
51-
run: env GOOS=darwin GOARCH=arm64 go build -v -o bin/go-mud-darwin_arm64 .
59+
run: env GOOS=darwin GOARCH=arm64 go build -v -ldflags "-X main.version=${{ env.RELEASE_VERSION }}" -o bin/go-mud-darwin_arm64 .
5260

5361
- name: Build darwin/amd64
54-
run: env GOOS=darwin GOARCH=amd64 go build -v -o bin/go-mud-darwin_x64 .
62+
run: env GOOS=darwin GOARCH=amd64 go build -v -ldflags "-X main.version=${{ env.RELEASE_VERSION }}" -o bin/go-mud-darwin_x64 .
5563

5664
- name: Build linux/amd64
57-
run: env GOOS=linux GOARCH=amd64 go build -v -o bin/go-mud-linux_x64 .
65+
run: env GOOS=linux GOARCH=amd64 go build -v -ldflags "-X main.version=${{ env.RELEASE_VERSION }}" -o bin/go-mud-linux_x64 .
5866

5967
- name: Build linux/arm5
60-
run: env GOOS=linux GOARCH=arm GOARM=5 go build -v -o bin/go-mud-linux_arm5 .
68+
run: env GOOS=linux GOARCH=arm GOARM=5 go build -v -ldflags "-X main.version=${{ env.RELEASE_VERSION }}" -o bin/go-mud-linux_arm5 .
6169

6270
- name: Upload bin
6371
uses: actions/upload-artifact@v4
@@ -84,22 +92,17 @@ jobs:
8492
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV
8593
8694
- name: Archive release
87-
uses: thedoctor0/zip-release@master
88-
id: zip-binaries
89-
with:
90-
type: zip
91-
directory: bin
92-
filename: ${{ env.RELEASE_FILENAME }}-${{ env.COMMIT_SHORT_SHA }}.zip
95+
run: zip -r bin/${{ env.RELEASE_FILENAME }}-${{ env.RELEASE_VERSION }}.zip bin/
9396

9497
- name: Release with notes
9598
uses: softprops/action-gh-release@v1
9699
with:
97-
files: bin/${{ env.RELEASE_FILENAME }}-${{ env.COMMIT_SHORT_SHA }}.zip
98-
tag_name: release-${{ env.COMMIT_SHORT_SHA }}
100+
files: bin/${{ env.RELEASE_FILENAME }}-${{ env.RELEASE_VERSION }}.zip
101+
tag_name: ${{ env.RELEASE_VERSION }}
99102
fail_on_unmatched_files: true
100103
env:
101104
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
102-
105+
103106
message:
104107
runs-on: ubuntu-latest
105108
steps:
@@ -118,6 +121,7 @@ jobs:
118121
uses: tsickert/[email protected]
119122
with:
120123
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
121-
embed-title: "🎉 New update on `master` branch: ${{ fromJson(steps.get_pr_data.outputs.result).title }}"
122-
embed-description: "${{ fromJson(steps.get_pr_data.outputs.result).body }}"
123-
embed-url: "${{ fromJson(steps.get_pr_data.outputs.result).html_url }}"
124+
embed-title: ${{ steps.get_pr_data.outputs.result && fromJson(steps.get_pr_data.outputs.result).title || '🎉 New update on `master` branch' }}
125+
embed-description: ${{ steps.get_pr_data.outputs.result && fromJson(steps.get_pr_data.outputs.result).body || 'No description provided.' }}
126+
embed-url: ${{ steps.get_pr_data.outputs.result && fromJson(steps.get_pr_data.outputs.result).html_url || github.event.compare }}
127+

.github/workflows/docker-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ on:
88
branches:
99
- master
1010
tags:
11-
- 'v*'
12-
- 'release-*'
11+
- 'v*.*.*'
1312
pull_request:
1413
branches:
1514
- master
@@ -19,6 +18,7 @@ env:
1918
REGISTRY: ghcr.io
2019
# github.repository as <account>/<repo>
2120
IMAGE_NAME: ${{ github.repository }}
21+
RELEASE_VERSION: ${{ github.ref_name }}
2222

2323
jobs:
2424
package:

.github/workflows/run-tests.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ jobs:
1212
- uses: actions/checkout@v4
1313

1414
- name: Set up Go
15-
uses: actions/setup-go@v4
15+
uses: actions/setup-go@v5
1616
with:
17-
go-version: "1.23"
17+
go-version-file: 'go.mod'
18+
19+
- name: Run code generation
20+
run: go generate ./...
1821

1922
- name: Run tests
2023
run: make test

0 commit comments

Comments
 (0)