-
-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (63 loc) · 2.6 KB
/
prepare-release.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
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
name: 🚁Prepare Release
defaults:
run:
shell: pwsh
on:
workflow_dispatch:
inputs:
release-type:
description: The type of release. Choose 'Preview' or 'Production'.
required: true
type: choice
options: [Preview, Production]
release-version:
required: true
description: The version of the release to prepare.
type: string
jobs:
print_validate_workflow:
name: Print & Validate Prepare Release Workflow
runs-on: ubuntu-latest
steps:
- name: Print Environment Variables
run: Get-ChildItem -Path Env:* | Sort-Object Name
- name: Validate Workflow Inputs
run: |
$releaseType = "${{ inputs.release-type }}".ToLower();
if ("${{ vars.PROJECT_NAME }}".Trim() -eq "") {
Write-Host "::error::The project name input cannot be empty.";
exit 1;
}
if ($releaseType -eq "") {
Write-Host "::error::The release type input cannot be empty.";
exit 1;
}
if ($releaseType -ne 'preview' -and $releaseType -ne 'production') {
Write-Host "::error::The release type input must be either 'Preview' or 'Production'.";
exit 1;
}
$releaseVersion = "${{ inputs.release-version }}".Trim().ToLower();
if ($releaseVersion -eq "") {
Write-Host "::error::The 'release-version' workflow input cannot be empty.";
exit 1;
}
$prodVersionRegex = "v[0-9]+\.[0-9]+\.[0-9]+";
$prevVersionRegex = "v[0-9]+\.[0-9]+\.[0-9]+-preview\.[0-9]+";
# Verify that the version has valid syntax
if (($releaseVersion -match $prodVersionRegex) -or ($releaseVersion -match $prevVersionRegex)) {
Write-Host "::notice::The 'release-version' workflow input is valid.";
} else {
$versionSyntax = $releaseType == "production" ? "v#.#.#" : "v#.#.#-preview.#";
Write-Host "::error::The 'release-version' workflow input is not valid. Expected format: '$versionSyntax";
exit 1;
}
prepare_release:
name: Prepare ${{ inputs.release-type }} Release Of ${{ vars.PROJECT_NAME }}
needs: print_validate_workflow
uses: KinsonDigital/Infrastructure/.github/workflows/[email protected]
with:
project-name: ${{ vars.PROJECT_NAME }}
release-type: ${{ inputs.release-type }}
release-version: ${{ inputs.release-version }}
secrets:
cicd-pat: ${{ secrets.CICD_TOKEN }}