Skip to content

Commit 05c0a69

Browse files
committed
Add manual release option to build workflow
1 parent 7de7486 commit 05c0a69

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

.github/workflows/build-release.yml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ on:
77
tags:
88
- "v*"
99
workflow_dispatch:
10+
inputs:
11+
release:
12+
description: "Create a release (will create and push a version tag)"
13+
required: false
14+
default: false
15+
type: boolean
1016

1117
jobs:
1218
prepare:
@@ -29,7 +35,7 @@ jobs:
2935
VERSION="${GITHUB_REF#refs/tags/v}"
3036
IS_SNAPSHOT="false"
3137
else
32-
# Snapshot build from main branch or workflow_dispatch
38+
# Get last tag and calculate next version
3339
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
3440
LAST_VERSION="${LAST_TAG#v}"
3541
@@ -38,15 +44,30 @@ jobs:
3844
NEXT_PATCH=$((PATCH + 1))
3945
NEXT_VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}"
4046
41-
SHORT_SHA=$(git rev-parse --short HEAD)
42-
VERSION="${NEXT_VERSION}-${SHORT_SHA}-SNAPSHOT"
43-
IS_SNAPSHOT="true"
47+
if [[ "${{ github.event.inputs.release }}" == "true" ]]; then
48+
# Manual release requested
49+
VERSION="${NEXT_VERSION}"
50+
IS_SNAPSHOT="false"
51+
else
52+
# Snapshot build from main branch or workflow_dispatch
53+
SHORT_SHA=$(git rev-parse --short HEAD)
54+
VERSION="${NEXT_VERSION}-${SHORT_SHA}-SNAPSHOT"
55+
IS_SNAPSHOT="true"
56+
fi
4457
fi
4558
4659
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
4760
echo "IS_SNAPSHOT=${IS_SNAPSHOT}" >> $GITHUB_OUTPUT
4861
echo "Determined version: ${VERSION} (snapshot: ${IS_SNAPSHOT})"
4962
63+
- name: Create and push release tag
64+
if: github.event.inputs.release == 'true'
65+
run: |
66+
git config user.name "github-actions[bot]"
67+
git config user.email "github-actions[bot]@users.noreply.github.com"
68+
git tag -a "v${{ steps.version.outputs.VERSION }}" -m "Release v${{ steps.version.outputs.VERSION }}"
69+
git push origin "v${{ steps.version.outputs.VERSION }}"
70+
5071
build-binaries:
5172
name: Build binaries (${{ matrix.goos }}/${{ matrix.goarch }})
5273
runs-on: ${{ matrix.os }}

0 commit comments

Comments
 (0)