add GitHub release step to deploy pipeline. closes #11313

pull/11314/head
Alper Ebicoglu 4 years ago
parent 7eab93929c
commit 8815235ab3

@ -1,35 +0,0 @@
#THIS IS NOT BEING USED CURRENTLY. RELEASE GITHUB MANUALLY
# Import the module dynamically from the PowerShell Gallery. Use CurrentUser scope to avoid having to run as admin.
Import-Module -Name new-github-release-function.psm1
# Specify the parameters required to create the release. Do it as a hash table for easier readability.
$newGitHubReleaseParameters =
@{
GitHubUsername = 'abpframework'
GitHubRepositoryName = 'abp'
GitHubAccessToken = '*******************'
ReleaseName = "5.0.0-rc.2"
TagName = "5.0.0-rc.2"
ReleaseNotes = "N/A"
#AssetFilePaths = @('C:\MyProject\Installer.exe','C:\MyProject\Documentation.md')
IsPreRelease = $true
IsDraft = $true # Set to true when testing so we don't publish a real release (visible to everyone) by accident.
}
# Try to create the Release on GitHub and save the results.
$result = New-GitHubRelease @newGitHubReleaseParameters
# Provide some feedback to the user based on the results.
if ($result.Succeeded -eq $true)
{
Write-Output "Release published successfully! View it at $($result.ReleaseUrl)"
}
elseif ($result.ReleaseCreationSucceeded -eq $false)
{
Write-Error "The release was not created. Error message is: $($result.ErrorMessage)"
}
elseif ($result.AllAssetUploadsSucceeded -eq $false)
{
Write-Error "The release was created, but not all of the assets were uploaded to it. View it at $($result.ReleaseUrl). Error message is: $($result.ErrorMessage)"
}

@ -0,0 +1,86 @@
param(
[string]$branchName,
[string]$version,
[string]$isRcVersion,
[string]$isDraft,
[string]$gitHubApiKey
)
. ..\nupkg\common.ps1
Write-Info "Publishing GitHub Release..." ## Further info see https://docs.github.com/en/rest/reference/releases
if ($isRcVersion -eq "")
{
$isRcVersion = Read-Host "Is this a RC/Preview version? (y/n)"
}
if ($gitHubApiKey -eq "")
{
$gitHubApiKey = Read-File "github-api-key.txt"
echo "GitHub API Key assigned from github-api-key.txt"
}
if(!$gitHubApiKey)
{
$gitHubApiKey = Read-Host "Enter the GitHub API Key"
}
if ($version -eq "")
{
$version = Get-Current-Version # The version number for this release
}
if ($branchName -eq "")
{
$branchName = Get-Current-Branch # The branch name also the tag name
}
if ($isDraft -eq "")
{
$draft = $FALSE
}
else
{
$draft = [boolean]::Parse($isDraft)
}
##############################################################################
$preRelease = ( ($isRcVersion -eq "true") -or ($isRcVersion -eq "y") -or ($isRcVersion -eq "rc") ) # Set to true to mark this as a pre-release version
$gitHubUsername = 'abpframework' # The github username
$gitHubRepository = 'abp' # The github repository name
$releaseNotes = '' # The notes to accompany this release, uses the commit message in this case
##############################################################################
echo "Current version: $version"
echo "Current branch: $branchName"
echo "Preview version: $preRelease"
echo "Draft: $draft"
##############################################################################
$releaseData = @{
tag_name = $version;
target_commitish = $branchName;
name = $version;
body = $releaseNotes;
draft = $draft;
prerelease = $preRelease;
}
$releaseParams = @{
Uri = "https://api.github.com/repos/$gitHubUsername/$gitHubRepository/releases";
Method = 'POST';
Headers = @{
Authorization = 'Basic ' + [Convert]::ToBase64String(
[Text.Encoding]::ASCII.GetBytes($gitHubApiKey + ":x-oauth-basic"));
}
ContentType = 'application/json';
Body = (ConvertTo-Json $releaseData -Compress)
}
$response = Invoke-RestMethod @releaseParams
echo "---------------------------------------------"
echo "$version has been successfully released."

@ -1,7 +1,43 @@
./1-fetch-and-build.ps1
param(
[string]$branch,
[string]$newVersion,
[string]$isRcVersion
)
. ..\nupkg\common.ps1
if (!$branch)
{
$branch = Read-Host "Enter the branch name"
}
if (!$newVersion)
{
$currentVersion = Get-Current-Version
$newVersion = Read-Host "Current version is '$currentVersion'. Enter the new version (empty for no change) "
if($newVersion -eq "")
{
$newVersion = $currentVersion
}
}
if ($isRcVersion -eq "")
{
$isRcVersion = Read-Host "Is this a RC/Preview version? (y/n)"
}
$publishGithubReleaseParams = @{
branchName=$branch
isRcVersion=$isRcVersion
}
./1-fetch-and-build.ps1 $branch $newVersion
./2-nuget-pack.ps1
./3-nuget-push.ps1
./4-npm-publish-mvc.ps1
./5-npm-publish-angular.ps1
./6-git-commit.ps1
echo "Create a new release on GitHub manually and run the step 8..."
./7-publish-github-release.ps1 @publishGithubReleaseParams
./8-download-release-zip.ps1

@ -38,6 +38,24 @@ function Seperator
Write-Host ("_" * 100) -ForegroundColor gray
}
function Read-File {
param(
[Parameter(Mandatory = $true)]
[string]
$filePath
)
$pathExists = Test-Path -Path $filePath -PathType Leaf
if ($pathExists)
{
return Get-Content $filePath
}
else{
Write-Error "$filePath path does not exist!"
}
}
# List of solutions
$solutions = (
"framework",

Loading…
Cancel
Save