-
Notifications
You must be signed in to change notification settings - Fork 2
45 lines (40 loc) · 1.07 KB
/
create-release-tag.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
name: Create Release Tag
on:
workflow_dispatch:
inputs:
git_ref:
description: 'Git ref'
type: string
required: false
default: 'main'
semver:
description: 'Semantic Version (defaults to 0.0.0-commit)'
type: string
required: false
default: ''
jobs:
create-tag:
name: Create Tag
runs-on: windows-2022
timeout-minutes: 5
permissions:
contents:
write # Create tag and release
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.git_ref }}
- name: Create Tag
shell: pwsh
run: |
$SemVer = "${{ github.event.inputs.semver }}"
if ($SemVer -eq "") {
$ShortCommit = (& git rev-parse --short "${{ github.event.inputs.git_ref }}" | Out-String).Trim()
$SemVer = "0.0.0-$ShortCommit"
}
if (-not $SemVer -match "^v\d+\.\d+\.\d+(-\w+)?$") {
throw "Unexpected SemVer format: $SemVer"
}
$Tag = "v$SemVer"
& git tag $Tag
& git push origin $Tag