Skip to content

Commit 2fd0cdb

Browse files
committed
fix: adding commit id as input for github release
1 parent 31f8af1 commit 2fd0cdb

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ on:
1010
description: 'Version tag (e.g., v1.0.0)'
1111
required: true
1212
type: string
13+
branch:
14+
description: 'Branch to build from (default: main)'
15+
required: false
16+
type: string
17+
default: 'main'
18+
commit_id:
19+
description: 'Specific commit SHA to build (overrides branch if set)'
20+
required: false
21+
type: string
1322
compare_from:
1423
description: 'Compare from tag (optional, auto-detects if empty)'
1524
required: false
@@ -41,6 +50,7 @@ jobs:
4150
- name: Checkout code
4251
uses: actions/checkout@v4
4352
with:
53+
ref: ${{ github.event.inputs.commit_id || github.event.inputs.branch || '' }}
4454
fetch-depth: 0
4555

4656
- name: Get version
@@ -72,13 +82,19 @@ jobs:
7282
git config --local user.name "GitHub Action"
7383
7484
VERSION=${{ steps.version.outputs.version }}
85+
COMMIT_REF="${{ github.event.inputs.commit_id }}"
86+
if [ -z "$COMMIT_REF" ]; then
87+
COMMIT_REF="HEAD"
88+
fi
89+
echo "Tagging commit: $COMMIT_REF"
90+
7591
if git tag --list | grep -q "^${VERSION}$"; then
7692
echo "Tag $VERSION already exists, deleting it first"
7793
git tag -d $VERSION || true
7894
git push --delete origin $VERSION || true
7995
fi
8096
81-
git tag -a $VERSION -m "Release $VERSION"
97+
git tag -a $VERSION $COMMIT_REF -m "Release $VERSION"
8298
git push origin $VERSION
8399
84100
- name: Build static binary via Docker
@@ -127,6 +143,7 @@ jobs:
127143
- name: Checkout code
128144
uses: actions/checkout@v4
129145
with:
146+
ref: ${{ github.event.inputs.commit_id || github.event.inputs.branch || '' }}
130147
fetch-depth: 0
131148

132149
- name: Get version
@@ -199,6 +216,7 @@ jobs:
199216
- name: Checkout code
200217
uses: actions/checkout@v4
201218
with:
219+
ref: ${{ github.event.inputs.commit_id || github.event.inputs.branch || '' }}
202220
fetch-depth: 0
203221

204222
- name: Get version
@@ -396,6 +414,7 @@ jobs:
396414
- name: Checkout code
397415
uses: actions/checkout@v4
398416
with:
417+
ref: ${{ github.event.inputs.commit_id || github.event.inputs.branch || '' }}
399418
fetch-depth: 0
400419

401420
- name: Get version

0 commit comments

Comments
 (0)