Skip to content

Instantly share code, notes, and snippets.

@danawoodman
Last active February 7, 2024 07:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save danawoodman/af83d7b9a632c5df6fe14196b16e6e27 to your computer and use it in GitHub Desktop.
Save danawoodman/af83d7b9a632c5df6fe14196b16e6e27 to your computer and use it in GitHub Desktop.
Create a Go app release for every git version tag using Github Actions

Release golang apps using Github Actions

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment