Skip to content

Merge pull request #84 from sudo-bmitch/pr-update-20241027 #176

Merge pull request #84 from sudo-bmitch/pr-update-20241027

Merge pull request #84 from sudo-bmitch/pr-update-20241027 #176

Workflow file for this run

name: Go
on:
push:
branches:
- 'main'
- 'feature/**'
tags:
- 'v*.*.*'
pull_request:
branches: [ main ]
jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
gover: ["1.21", "1.22", "1.23"]
env:
RELEASE_GO_VER: "1.23"
steps:
- name: "Set up Go ${{ matrix.gover }}"
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: "${{ matrix.gover }}"
check-latest: true
id: go
- name: Check out code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Verify go fmt
run: test -z "$(go fmt ./...)"
- name: Verify go vet
run: test -z "$(go vet ./...)"
- name: Test
env:
GITHUB_TOKEN: ${{ secrets.GH_RO_TOKEN }}
run: make test
- name: Linting
if: matrix.gover == env.RELEASE_GO_VER
run: make lint
- name: Build artifacts
if: startsWith( github.ref, 'refs/tags/v' ) || github.ref == 'refs/heads/main'
run: make artifacts
- name: Gather release details
if: startsWith( github.ref, 'refs/tags/v' ) && github.repository_owner == 'sudo-bmitch' && matrix.gover == env.RELEASE_GO_VER
id: release_details
run: |
VERSION=${GITHUB_REF#refs/tags/}
VALID_RELEASE=false
if [ -f "release.md" ] && grep -q "Release $VERSION" release.md; then
VALID_RELEASE=true
fi
RELEASE_NOTES=$(cat release.md || echo release notes unavailable)
# escape % and linefeeds
RELEASE_NOTES="${RELEASE_NOTES//'%'/'%25'}"
RELEASE_NOTES="${RELEASE_NOTES//$'\n'/'%0A'}"
RELEASE_NOTES="${RELEASE_NOTES//$'\r'/'%0D'}"
echo "valid=${VALID_RELEASE}" >>$GITHUB_OUTPUT
echo "version=${VERSION}" >>$GITHUB_OUTPUT
echo "release_notes=${RELEASE_NOTES}" >>$GITHUB_OUTPUT
- name: Create release
if: steps.release_details.outputs.valid == 'true' && matrix.gover == env.RELEASE_GO_VER
id: release_create
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.release_details.outputs.version }}
body: ${{ steps.release_details.outputs.release_notes }}
draft: false
prerelease: false
files: |
./artifacts/version-bump-darwin-amd64
./artifacts/version-bump-linux-amd64
./artifacts/version-bump-linux-arm64
./artifacts/version-bump-linux-ppc64le
./artifacts/version-bump-linux-s390x
./artifacts/version-bump-windows-amd64.exe
- name: Save artifacts
if: github.ref == 'refs/heads/main' && matrix.gover == env.RELEASE_GO_VER
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: binaries
path: ./artifacts/
retention-days: 7