Skip to content

Commit 8815235

Browse files
committed
add GitHub release step to deploy pipeline. closes abpframework#11313
1 parent 7eab939 commit 8815235

File tree

4 files changed

+142
-37
lines changed

4 files changed

+142
-37
lines changed

deploy/7-new-github-release__NOT_ACTIVE_USE_MANUAL_WAY.ps1

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
param(
2+
[string]$branchName,
3+
[string]$version,
4+
[string]$isRcVersion,
5+
[string]$isDraft,
6+
[string]$gitHubApiKey
7+
)
8+
9+
. ..\nupkg\common.ps1
10+
11+
Write-Info "Publishing GitHub Release..." ## Further info see https://docs.github.com/en/rest/reference/releases
12+
13+
if ($isRcVersion -eq "")
14+
{
15+
$isRcVersion = Read-Host "Is this a RC/Preview version? (y/n)"
16+
}
17+
18+
if ($gitHubApiKey -eq "")
19+
{
20+
$gitHubApiKey = Read-File "github-api-key.txt"
21+
echo "GitHub API Key assigned from github-api-key.txt"
22+
}
23+
24+
if(!$gitHubApiKey)
25+
{
26+
$gitHubApiKey = Read-Host "Enter the GitHub API Key"
27+
}
28+
29+
if ($version -eq "")
30+
{
31+
$version = Get-Current-Version # The version number for this release
32+
}
33+
34+
if ($branchName -eq "")
35+
{
36+
$branchName = Get-Current-Branch # The branch name also the tag name
37+
}
38+
39+
if ($isDraft -eq "")
40+
{
41+
$draft = $FALSE
42+
}
43+
else
44+
{
45+
$draft = [boolean]::Parse($isDraft)
46+
}
47+
48+
##############################################################################
49+
$preRelease = ( ($isRcVersion -eq "true") -or ($isRcVersion -eq "y") -or ($isRcVersion -eq "rc") ) # Set to true to mark this as a pre-release version
50+
$gitHubUsername = 'abpframework' # The github username
51+
$gitHubRepository = 'abp' # The github repository name
52+
$releaseNotes = '' # The notes to accompany this release, uses the commit message in this case
53+
##############################################################################
54+
55+
echo "Current version: $version"
56+
echo "Current branch: $branchName"
57+
echo "Preview version: $preRelease"
58+
echo "Draft: $draft"
59+
60+
##############################################################################
61+
62+
$releaseData = @{
63+
tag_name = $version;
64+
target_commitish = $branchName;
65+
name = $version;
66+
body = $releaseNotes;
67+
draft = $draft;
68+
prerelease = $preRelease;
69+
}
70+
71+
$releaseParams = @{
72+
Uri = "https://api.github.com/repos/$gitHubUsername/$gitHubRepository/releases";
73+
Method = 'POST';
74+
Headers = @{
75+
Authorization = 'Basic ' + [Convert]::ToBase64String(
76+
[Text.Encoding]::ASCII.GetBytes($gitHubApiKey + ":x-oauth-basic"));
77+
}
78+
ContentType = 'application/json';
79+
Body = (ConvertTo-Json $releaseData -Compress)
80+
}
81+
82+
$response = Invoke-RestMethod @releaseParams
83+
84+
echo "---------------------------------------------"
85+
echo "$version has been successfully released."
86+

deploy/_run_all.ps1

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,43 @@
1-
./1-fetch-and-build.ps1
1+
param(
2+
[string]$branch,
3+
[string]$newVersion,
4+
[string]$isRcVersion
5+
)
6+
7+
. ..\nupkg\common.ps1
8+
9+
if (!$branch)
10+
{
11+
$branch = Read-Host "Enter the branch name"
12+
}
13+
14+
if (!$newVersion)
15+
{
16+
$currentVersion = Get-Current-Version
17+
$newVersion = Read-Host "Current version is '$currentVersion'. Enter the new version (empty for no change) "
18+
if($newVersion -eq "")
19+
{
20+
$newVersion = $currentVersion
21+
}
22+
}
23+
24+
if ($isRcVersion -eq "")
25+
{
26+
$isRcVersion = Read-Host "Is this a RC/Preview version? (y/n)"
27+
}
28+
29+
$publishGithubReleaseParams = @{
30+
branchName=$branch
31+
isRcVersion=$isRcVersion
32+
}
33+
34+
35+
./1-fetch-and-build.ps1 $branch $newVersion
236
./2-nuget-pack.ps1
337
./3-nuget-push.ps1
438
./4-npm-publish-mvc.ps1
539
./5-npm-publish-angular.ps1
640
./6-git-commit.ps1
7-
echo "Create a new release on GitHub manually and run the step 8..."
41+
./7-publish-github-release.ps1 @publishGithubReleaseParams
42+
./8-download-release-zip.ps1
43+

nupkg/common.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,24 @@ function Seperator
3838
Write-Host ("_" * 100) -ForegroundColor gray
3939
}
4040

41+
42+
function Read-File {
43+
param(
44+
[Parameter(Mandatory = $true)]
45+
[string]
46+
$filePath
47+
)
48+
49+
$pathExists = Test-Path -Path $filePath -PathType Leaf
50+
if ($pathExists)
51+
{
52+
return Get-Content $filePath
53+
}
54+
else{
55+
Write-Error "$filePath path does not exist!"
56+
}
57+
}
58+
4159
# List of solutions
4260
$solutions = (
4361
"framework",

0 commit comments

Comments
 (0)