|
8 | 8 | # is always x86_64-linux regardless of build target); |
9 | 9 | # add windows-arm64 and linux-arm64 matrix entries; |
10 | 10 | # 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. |
11 | 15 | # ============================================================================= |
12 | 16 |
|
13 | 17 | name: release |
|
17 | 21 | tags: |
18 | 22 | - "v*" |
19 | 23 | workflow_dispatch: |
| 24 | + inputs: |
| 25 | + version: |
| 26 | + description: "Version to release (e.g. v0.1.0)" |
| 27 | + required: true |
| 28 | + type: string |
20 | 29 |
|
21 | 30 | permissions: |
22 | 31 | contents: write |
23 | 32 |
|
24 | 33 | jobs: |
25 | 34 |
|
26 | | - # ========================= CREATE RELEASE (ONCE ONLY) ========================= |
| 35 | + # ========================= CREATE TAG + RELEASE (ONCE ONLY) ========================= |
27 | 36 | create-release: |
28 | 37 | runs-on: ubuntu-latest |
29 | 38 |
|
| 39 | + outputs: |
| 40 | + tag: ${{ steps.resolve-tag.outputs.tag }} |
| 41 | + |
30 | 42 | 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 | +
|
31 | 82 | - name: Create GitHub Release |
32 | 83 | uses: softprops/action-gh-release@v2 |
33 | 84 | with: |
34 | | - tag_name: ${{ github.ref_name }} |
| 85 | + tag_name: ${{ steps.resolve-tag.outputs.tag }} |
35 | 86 | env: |
36 | 87 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
37 | 88 |
|
|
40 | 91 | runs-on: ${{ matrix.os }} |
41 | 92 | needs: create-release |
42 | 93 |
|
| 94 | + env: |
| 95 | + TAG: ${{ needs.create-release.outputs.tag }} |
| 96 | + EXE_NAME: dua |
| 97 | + |
43 | 98 | strategy: |
44 | 99 | fail-fast: false |
45 | 100 | matrix: |
|
70 | 125 | target: aarch64-pc-windows-msvc |
71 | 126 | use_cross: false |
72 | 127 |
|
73 | | - env: |
74 | | - EXE_NAME: dua |
75 | | - |
76 | 128 | steps: |
77 | 129 | - name: Checkout |
78 | 130 | uses: actions/checkout@v4 |
@@ -150,7 +202,7 @@ jobs: |
150 | 202 | run: | |
151 | 203 | set -e |
152 | 204 |
|
153 | | - VERSION="${GITHUB_REF_NAME}" |
| 205 | + VERSION="${TAG}" |
154 | 206 | NAME="${{ env.EXE_NAME }}-${VERSION}-${{ matrix.name }}" |
155 | 207 | mkdir -p "$NAME" |
156 | 208 |
|
@@ -182,6 +234,7 @@ jobs: |
182 | 234 | - name: Upload to GitHub Release |
183 | 235 | uses: softprops/action-gh-release@v2 |
184 | 236 | with: |
| 237 | + tag_name: ${{ needs.create-release.outputs.tag }} |
185 | 238 | files: ${{ env.ASSET }} |
186 | 239 | env: |
187 | 240 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments