Skip to content

Implement automatic release creation #10

Implement automatic release creation

Implement automatic release creation #10

Workflow file for this run

# .github/workflows/build-release.yml
name: Build Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.23.1]
os: [linux, windows, darwin]
arch: [amd64, arm64]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Set up variables
run: |
GITSHA=$(git rev-parse --short HEAD)
echo GITSHA=$GITSHA >>$GITHUB_ENV
echo VERSION=${GITHUB_REF#refs/tags/} >>$GITHUB_ENV
- name: Define the executable name for Linux and macOS
if: ${{ matrix.os != 'windows' }}
run: echo CONFD=confd-${{ matrix.os }}-${{ matrix.arch }} >>$GITHUB_ENV
- name: Define the executable name for Windows
if: ${{ matrix.os == 'windows' }}
run: echo CONFD=confd-${{ matrix.os }}-${{ matrix.arch }}.exe >>$GITHUB_ENV
- name: Build `confd`
env:
CGO_ENABLED: 0
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
run: go build -o bin/$CONFD -ldflags "-s -w -X main.Version=$VERSION -X main.GitSHA=$GITSHA"
- name: Compress `confd`
if: ${{ matrix.os != 'windows' }}
run: upx --brute bin/$CONFD
- name: Upload `confd`
uses: actions/upload-artifact@v4
with:
name: ${{ env.CONFD }}
path: bin/${{ env.CONFD }}
publish:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download `confd`
uses: actions/download-artifact@v4
with:
path: bin
- name: Create release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: bin/*
# vim:set sw=2 ts=2 et: