-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (86 loc) · 3.05 KB
/
Copy pathgithub-release.yml
File metadata and controls
106 lines (86 loc) · 3.05 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: GitHub Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Publish releases (es: v1.2.3 o v1.2.3-rc1)"
required: true
type: string
permissions:
contents: write
concurrency:
group: github-release-${{ github.workflow }}-${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }}
cancel-in-progress: false
jobs:
test_unit:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event_name == 'workflow_dispatch' && format('refs/tags/{0}', inputs.tag) || github.ref }}
- name: Validate manual tag input
if: ${{ github.event_name == 'workflow_dispatch' }}
shell: powershell
run: |
if ('${{ inputs.tag }}' -notmatch '^v') {
throw "Input 'tag' must start with 'v' (example: v1.2.3)."
}
git rev-parse --verify "refs/tags/${{ inputs.tag }}" | Out-Null
- name: Install Pester 5
shell: powershell
run: |
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-Module Pester -Scope CurrentUser -Force -SkipPublisherCheck
- name: Run Unit Tests
shell: powershell
run: |
Import-Module Pester -MinimumVersion 5.0.0 -Force
./Tools/Run-Tests.ps1
create_release:
needs: test_unit
# Consenti:
# - v1.2.3
# - v1.2.3-rc1
# Blocca:
# - v1.2.3-beta1
# - v1.2.3-alpha1
# - v1.2.3-test
if: ${{ github.event_name == 'workflow_dispatch' || !contains(github.ref_name, '-') || contains(github.ref_name, '-rc') }}
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event_name == 'workflow_dispatch' && format('refs/tags/{0}', inputs.tag) || github.ref }}
- name: Resolve release metadata
id: meta
shell: powershell
run: |
$Tag = if ('${{ github.event_name }}' -eq 'workflow_dispatch') {
'${{ inputs.tag }}'
}
else {
'${{ github.ref_name }}'
}
if ($Tag -notmatch '^v\d+\.\d+\.\d+(-rc\d+)?$') {
throw "Only stable releases (vX.Y.Z) and release candidates (vX.Y.Z-rcN) are supported."
}
$IsPrerelease = $Tag -match '-rc'
"tag=$Tag" |
Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
"prerelease=$($IsPrerelease.ToString().ToLowerInvariant())" |
Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
- name: Create or update GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.meta.outputs.tag }}
name: ${{ steps.meta.outputs.tag }}
prerelease: ${{ steps.meta.outputs.prerelease }}
generate_release_notes: true