Skip to content

Version bump

Version bump #340

Workflow file for this run

# Copyright the version-bump contributors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Go
on:
push:
branches:
- 'main'
- 'feature/**'
tags:
- 'v*.*.*'
pull_request:
branches: [ main ]
permissions:
contents: read
jobs:
build:
name: Build
runs-on: ubuntu-latest
env:
RELEASE_GO_VER: "1.26"
steps:
- name: "Set up Go ${{ env.RELEASE_GO_VER }}"
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version: "${{ env.RELEASE_GO_VER }}"
check-latest: true
id: go
- name: Check out code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- 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
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'
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'
id: release_create
uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b # v3.0.1
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'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: binaries
path: ./artifacts/
retention-days: 7