Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 74b0cc0

Browse files
Update release.yml
1 parent 04050ec commit 74b0cc0

1 file changed

Lines changed: 59 additions & 6 deletions

File tree

.github/workflows/release.yml

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
# is always x86_64-linux regardless of build target);
99
# add windows-arm64 and linux-arm64 matrix entries;
1010
# use actions/checkout@v4 and softprops/action-gh-release@v2.
11+
# v1.1.0 2026-04-11 Add workflow_dispatch input for version (e.g. v0.1.0);
12+
# create-release job now creates the git tag when triggered
13+
# manually so no local git commands are needed — just click
14+
# Actions > release > Run workflow, enter the version, done.
1115
# =============================================================================
1216

1317
name: release
@@ -17,21 +21,68 @@ on:
1721
tags:
1822
- "v*"
1923
workflow_dispatch:
24+
inputs:
25+
version:
26+
description: "Version to release (e.g. v0.1.0)"
27+
required: true
28+
type: string
2029

2130
permissions:
2231
contents: write
2332

2433
jobs:
2534

26-
# ========================= CREATE RELEASE (ONCE ONLY) =========================
35+
# ========================= CREATE TAG + RELEASE (ONCE ONLY) =========================
2736
create-release:
2837
runs-on: ubuntu-latest
2938

39+
outputs:
40+
tag: ${{ steps.resolve-tag.outputs.tag }}
41+
3042
steps:
43+
- name: Checkout
44+
uses: actions/checkout@v4
45+
46+
- name: Resolve tag name
47+
id: resolve-tag
48+
shell: bash
49+
run: |
50+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
51+
TAG="${{ github.event.inputs.version }}"
52+
else
53+
TAG="${{ github.ref_name }}"
54+
fi
55+
56+
# Ensure it starts with v
57+
if [[ "$TAG" != v* ]]; then
58+
echo "❌ Version must start with 'v' (got: $TAG)"
59+
exit 1
60+
fi
61+
62+
echo "tag=$TAG" >> $GITHUB_OUTPUT
63+
echo "Resolved tag: $TAG"
64+
65+
- name: Create and push git tag (workflow_dispatch only)
66+
if: github.event_name == 'workflow_dispatch'
67+
shell: bash
68+
run: |
69+
TAG="${{ steps.resolve-tag.outputs.tag }}"
70+
git config user.name "github-actions[bot]"
71+
git config user.email "github-actions[bot]@users.noreply.github.com"
72+
73+
if git ls-remote --tags origin "$TAG" | grep -q "$TAG"; then
74+
echo "❌ Tag $TAG already exists on remote — pick a different version"
75+
exit 1
76+
fi
77+
78+
git tag "$TAG"
79+
git push origin "$TAG"
80+
echo "✅ Tag $TAG created and pushed"
81+
3182
- name: Create GitHub Release
3283
uses: softprops/action-gh-release@v2
3384
with:
34-
tag_name: ${{ github.ref_name }}
85+
tag_name: ${{ steps.resolve-tag.outputs.tag }}
3586
env:
3687
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3788

@@ -40,6 +91,10 @@ jobs:
4091
runs-on: ${{ matrix.os }}
4192
needs: create-release
4293

94+
env:
95+
TAG: ${{ needs.create-release.outputs.tag }}
96+
EXE_NAME: dua
97+
4398
strategy:
4499
fail-fast: false
45100
matrix:
@@ -70,9 +125,6 @@ jobs:
70125
target: aarch64-pc-windows-msvc
71126
use_cross: false
72127

73-
env:
74-
EXE_NAME: dua
75-
76128
steps:
77129
- name: Checkout
78130
uses: actions/checkout@v4
@@ -150,7 +202,7 @@ jobs:
150202
run: |
151203
set -e
152204
153-
VERSION="${GITHUB_REF_NAME}"
205+
VERSION="${TAG}"
154206
NAME="${{ env.EXE_NAME }}-${VERSION}-${{ matrix.name }}"
155207
mkdir -p "$NAME"
156208
@@ -182,6 +234,7 @@ jobs:
182234
- name: Upload to GitHub Release
183235
uses: softprops/action-gh-release@v2
184236
with:
237+
tag_name: ${{ needs.create-release.outputs.tag }}
185238
files: ${{ env.ASSET }}
186239
env:
187240
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)