Skip to content

Commit ea3b6ce

Browse files
authored
Merge pull request #1 from Agalar-Development/copilot/run-release-yml
Add workflow_dispatch trigger to release.yml too many commits from copilot but that was cool tbh lol
2 parents 310fbd7 + 55629c5 commit ea3b6ce

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

.github/workflows/release.yml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ on:
44
push:
55
tags:
66
- 'v*'
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: 'Version to release (e.g., v0.1.0)'
11+
required: true
12+
default: 'v0.1.0'
713

814
env:
915
CARGO_TERM_COLOR: always
@@ -15,14 +21,39 @@ jobs:
1521
outputs:
1622
upload_url: ${{ steps.create_release.outputs.upload_url }}
1723
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
29+
- name: Set version from tag
30+
if: startsWith(github.ref, 'refs/tags/')
31+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
32+
33+
- name: Set version from input
34+
if: github.event_name == 'workflow_dispatch'
35+
run: echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
36+
37+
- name: Create tag for manual release
38+
if: github.event_name == 'workflow_dispatch'
39+
run: |
40+
git config user.name "github-actions[bot]"
41+
git config user.email "github-actions[bot]@users.noreply.github.com"
42+
if git tag -l "${{ github.event.inputs.version }}" | grep -q .; then
43+
echo "Tag ${{ github.event.inputs.version }} already exists!"
44+
exit 1
45+
fi
46+
git tag -a "${{ github.event.inputs.version }}" -m "Release ${{ github.event.inputs.version }}"
47+
git push origin "${{ github.event.inputs.version }}"
48+
1849
- name: Create Release
1950
id: create_release
2051
uses: actions/create-release@v1
2152
env:
2253
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2354
with:
24-
tag_name: ${{ github.ref }}
25-
release_name: Release ${{ github.ref }}
55+
tag_name: ${{ env.VERSION }}
56+
release_name: Release ${{ env.VERSION }}
2657
draft: false
2758
prerelease: false
2859

0 commit comments

Comments
 (0)