diff --git a/.github/RELEASING.md b/.github/RELEASING.md new file mode 100644 index 00000000..868825ac --- /dev/null +++ b/.github/RELEASING.md @@ -0,0 +1,68 @@ +## Release Process + +[Semantic Versioning 2.0.0 reference](https://github.com/semver/semver/blob/master/semver.md) + +### 1. New Feature or Breaking‑Change Release (Minor/Major) + +1. **Merge & Verify** +- Merge all feature or breaking‑change PRs into `master`. +- Ensure CI (tests, linter, codegen) all pass on `master`. + +2. **Determine Version Bump** +- **Major** (`X.0.0`) when you make incompatible changes +- **Minor** (`0.Y.0`) when you add functionality in a backward compatible manner +- **Patch** (`0.0.Z`) when you make backward compatible bug fixes + +3. **Create Git Tag** + ```bash + git tag vX.Y.Z + git push origin vX.Y.Z + ``` + This triggers the `build-and-release` workflow. + +5. **Monitor Draft Release** + - GitHub Actions will: + - Run `go generate ./…` + - Build artifacts with `main.version=vX.Y.Z` + - Zip as `go-mud-release-vX.Y.Z.zip` + - Draft a GitHub Release named `vX.Y.Z` + +6. **Finalize Release Notes** + - Review and adjust the draft on GitHub, then click **Publish release**. + +7. **Announce** + - Share the release link with the team or via configured notifications. + +--- + +### 2. Basic Patch Release (x.y.Z) + +1. **Merge Bug‑Fix PR** + - Once the fix is in `master` and CI is green. + +2. **Determine Patch Bump** + ```bash + # if current version is vX.Y.Z: + git tag vX.Y.(Z+1) + git push origin vX.Y.(Z+1) + ``` + +3. **Tag & Push** + - Pushing the tag triggers the same workflow. + +4. **Publish** + - Review draft release, then click **Publish release**. + +--- + +### FAQ / Guidelines + +- **Does every merge to `master` trigger a release?** + No – only pushing a Git tag matching `v*.*.*` triggers a release. + +- **When should I bump minor vs. patch?** + - **Minor** for new, backward‑compatible features. + - **Patch** for bug fixes or documentation tweaks. + +- **What about `go generate` directives?** + The workflow runs `go generate ./…` automatically before each build. diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 1751589e..4164fbef 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -5,38 +5,46 @@ name: Build and release on: push: - branches: [master] + tags: ['v*.*.*'] permissions: contents: write env: RELEASE_FILENAME: go-mud-release + RELEASE_VERSION: ${{ github.ref_name }} jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Show version + run: echo 'Releasing version $RELEASE_VERSION' - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: - go-version: "1.23" + go-version-file: 'go.mod' + + - name: Run code generation + run: go generate ./... - name: Run tests run: go test ./... build: runs-on: ubuntu-latest - needs: "test" + needs: 'test' steps: - uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: - go-version: "1.23" + go-version-file: 'go.mod' - name: Create bin directory run: mkdir -p bin/ @@ -45,19 +53,19 @@ jobs: run: cp -r _datafiles bin/ - name: Build windows amd64 - run: env GOOS=windows GOARCH=amd64 go build -v -o bin/go-mud-windows_x64.exe . + run: env GOOS=windows GOARCH=amd64 go build -v -ldflags "-X main.version=${{ env.RELEASE_VERSION }}" -o bin/go-mud-windows_x64.exe . - name: Build darwin/arm64 - run: env GOOS=darwin GOARCH=arm64 go build -v -o bin/go-mud-darwin_arm64 . + run: env GOOS=darwin GOARCH=arm64 go build -v -ldflags "-X main.version=${{ env.RELEASE_VERSION }}" -o bin/go-mud-darwin_arm64 . - name: Build darwin/amd64 - run: env GOOS=darwin GOARCH=amd64 go build -v -o bin/go-mud-darwin_x64 . + run: env GOOS=darwin GOARCH=amd64 go build -v -ldflags "-X main.version=${{ env.RELEASE_VERSION }}" -o bin/go-mud-darwin_x64 . - name: Build linux/amd64 - run: env GOOS=linux GOARCH=amd64 go build -v -o bin/go-mud-linux_x64 . + run: env GOOS=linux GOARCH=amd64 go build -v -ldflags "-X main.version=${{ env.RELEASE_VERSION }}" -o bin/go-mud-linux_x64 . - name: Build linux/arm5 - run: env GOOS=linux GOARCH=arm GOARM=5 go build -v -o bin/go-mud-linux_arm5 . + run: env GOOS=linux GOARCH=arm GOARM=5 go build -v -ldflags "-X main.version=${{ env.RELEASE_VERSION }}" -o bin/go-mud-linux_arm5 . - name: Upload bin uses: actions/upload-artifact@v4 @@ -84,22 +92,17 @@ jobs: echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV - name: Archive release - uses: thedoctor0/zip-release@master - id: zip-binaries - with: - type: zip - directory: bin - filename: ${{ env.RELEASE_FILENAME }}-${{ env.COMMIT_SHORT_SHA }}.zip + run: zip -r bin/${{ env.RELEASE_FILENAME }}-${{ env.RELEASE_VERSION }}.zip bin/ - name: Release with notes uses: softprops/action-gh-release@v1 with: - files: bin/${{ env.RELEASE_FILENAME }}-${{ env.COMMIT_SHORT_SHA }}.zip - tag_name: release-${{ env.COMMIT_SHORT_SHA }} + files: bin/${{ env.RELEASE_FILENAME }}-${{ env.RELEASE_VERSION }}.zip + tag_name: ${{ env.RELEASE_VERSION }} fail_on_unmatched_files: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - + message: runs-on: ubuntu-latest steps: @@ -118,6 +121,7 @@ jobs: uses: tsickert/discord-webhook@v7.0.0 with: webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }} - embed-title: "🎉 New update on `master` branch: ${{ fromJson(steps.get_pr_data.outputs.result).title }}" - embed-description: "${{ fromJson(steps.get_pr_data.outputs.result).body }}" - embed-url: "${{ fromJson(steps.get_pr_data.outputs.result).html_url }}" + embed-title: ${{ steps.get_pr_data.outputs.result && fromJson(steps.get_pr_data.outputs.result).title || '🎉 New update on `master` branch' }} + embed-description: ${{ steps.get_pr_data.outputs.result && fromJson(steps.get_pr_data.outputs.result).body || 'No description provided.' }} + embed-url: ${{ steps.get_pr_data.outputs.result && fromJson(steps.get_pr_data.outputs.result).html_url || github.event.compare }} + diff --git a/.github/workflows/docker-package.yml b/.github/workflows/docker-package.yml index ba303a9c..df6e0a1d 100644 --- a/.github/workflows/docker-package.yml +++ b/.github/workflows/docker-package.yml @@ -8,8 +8,7 @@ on: branches: - master tags: - - 'v*' - - 'release-*' + - 'v*.*.*' pull_request: branches: - master @@ -19,6 +18,7 @@ env: REGISTRY: ghcr.io # github.repository as / IMAGE_NAME: ${{ github.repository }} + RELEASE_VERSION: ${{ github.ref_name }} jobs: package: diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 06a09d83..13d6b8f2 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -12,9 +12,12 @@ jobs: - uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: - go-version: "1.23" + go-version-file: 'go.mod' + + - name: Run code generation + run: go generate ./... - name: Run tests run: make test