Skip to content

Commit 39f075c

Browse files
authored
feat(ci): Add option for manual release version (#325)
* feat(ci): Add option for manual release * Improve
1 parent bfa4d5c commit 39f075c

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

.github/workflows/docker-build.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
images: ${{ inputs.image }}
6868
tags: |
6969
type=raw,value=latest
70-
type=sha,format=short,prefix=
70+
type=sha,format=long,prefix=
7171
${{ inputs.tag_with_version && format('type=raw,value=v{0}', inputs.version) || '' }}
7272
7373
- name: Build and Push Image
@@ -85,8 +85,9 @@ jobs:
8585
run: |
8686
IMAGE="${{ inputs.image }}"
8787
NAME="${IMAGE##*/}"
88-
SHORT_SHA="${GITHUB_SHA::7}"
89-
TAGS="latest, ${SHORT_SHA}"
88+
# Derive SHA from the checked-out ref to ensure correctness.
89+
FULL_SHA=$(git rev-parse HEAD)
90+
TAGS="latest, ${FULL_SHA}"
9091
if [ "${{ inputs.tag_with_version }}" = "true" ] && [ -n "${{ inputs.version }}" ]; then
9192
TAGS="${TAGS}, v${{ inputs.version }}"
9293
fi

.github/workflows/prepare-release.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ on:
1515
- minor
1616
- major
1717
default: patch
18+
release:
19+
description: "Manual release version (e.g. 1.2.3). Overrides bump."
20+
type: string
21+
required: false
22+
default: ""
1823

1924
permissions:
2025
contents: write
@@ -38,9 +43,23 @@ jobs:
3843
- name: Install cargo-edit
3944
run: cargo install cargo-edit --locked
4045

41-
- name: Bump Workspace Versions
46+
- name: Set Workspace Version (manual or bump)
47+
shell: bash
4248
run: |
43-
cargo set-version --workspace --bump "${{ inputs.bump }}"
49+
set -euo pipefail
50+
MANUAL_RELEASE="${{ inputs.release }}"
51+
if [[ -n "${MANUAL_RELEASE}" ]]; then
52+
# Validate SemVer (strict X.Y.Z numeric to align with repo conventions).
53+
if [[ ! "${MANUAL_RELEASE}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
54+
echo "Provided release '${MANUAL_RELEASE}' is not a valid SemVer (expected X.Y.Z)." >&2
55+
exit 1
56+
fi
57+
echo "Setting workspace version to ${MANUAL_RELEASE} (manual)."
58+
cargo set-version --workspace "${MANUAL_RELEASE}"
59+
else
60+
echo "Bumping workspace version by '${{ inputs.bump }}'."
61+
cargo set-version --workspace --bump "${{ inputs.bump }}"
62+
fi
4463
4564
- name: Read New Version
4665
id: ver

0 commit comments

Comments
 (0)