Skip to content

Commit 4e2f6f4

Browse files
committed
Fix release workflow for manual dispatch
1 parent 0ae4253 commit 4e2f6f4

1 file changed

Lines changed: 27 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ on:
55
tags:
66
- 'v*'
77
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: 'Version tag (e.g. v1.0.3)'
11+
required: true
12+
default: 'v1.0.3'
813

914
jobs:
1015
create-release:
@@ -13,20 +18,40 @@ jobs:
1318
runs-on: ubuntu-latest
1419
outputs:
1520
release_id: ${{ steps.create-release.outputs.result }}
21+
tag_name: ${{ steps.get-tag.outputs.tag }}
1622

1723
steps:
1824
- uses: actions/checkout@v4
1925

26+
- name: Get tag name
27+
id: get-tag
28+
run: |
29+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
30+
echo "tag=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
31+
else
32+
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
33+
fi
34+
35+
- name: Create tag if manual dispatch
36+
if: github.event_name == 'workflow_dispatch'
37+
run: |
38+
git config user.name "github-actions[bot]"
39+
git config user.email "github-actions[bot]@users.noreply.github.com"
40+
git tag ${{ steps.get-tag.outputs.tag }} || true
41+
git push origin ${{ steps.get-tag.outputs.tag }} || true
42+
2043
- name: Create release
2144
id: create-release
2245
uses: actions/github-script@v7
46+
env:
47+
TAG_NAME: ${{ steps.get-tag.outputs.tag }}
2348
with:
2449
script: |
2550
const { data } = await github.rest.repos.createRelease({
2651
owner: context.repo.owner,
2752
repo: context.repo.repo,
28-
tag_name: context.ref.replace('refs/tags/', '') || `v${Date.now()}`,
29-
name: `Lotshot Autoplay ${context.ref.replace('refs/tags/', '') || 'Latest'}`,
53+
tag_name: process.env.TAG_NAME,
54+
name: `Lotshot Autoplay ${process.env.TAG_NAME}`,
3055
body: 'Download the installer for your platform below.',
3156
draft: true,
3257
prerelease: false

0 commit comments

Comments
 (0)