Want to release a new binary on Github for every new git tag (e.g. v1.2.7
)? Here is a simple Github Actions yaml config file that should get you started.
This script will automatically checkout your code, setup the correct version of go as defined in your go.mod
file
and build your go binary (in this case using a Makefile
default target), then upload it to a new Github Release.
# .github/workflows/release.yml
name: Build and release Go Project
on:
push:
tags:
- "v*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
- name: Build project
run: make # or 'go build .' etc...
- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
bin/server
# more file here...
Feel free to extend by changing your build command, or specifying more files to include in the release, say
your README.md
and release notes.