Skip to content

Commit

Permalink
automation for publishing / uploading
Browse files Browse the repository at this point in the history
  • Loading branch information
PrzemyslawKlys committed May 12, 2024
1 parent 12fbf48 commit 4d41557
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Build/PublishPackage.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
param (
$SolutionRoot = "$PSScriptRoot\.."
)

$NugetAPI = Get-Content -Raw -LiteralPath "C:\Support\Important\NugetOrg.txt"
#$GitHubAPI = Get-Content -Raw -LiteralPath "C:\Support\Important\GithubAPI.txt"

$ReleasePath = [io.path]::Combine($SolutionRoot, "OfficeIMO.Word", "bin", "Release")
$File = Get-ChildItem -Path $ReleasePath -Recurse -Filter "*.nupkg"

# publish to nuget.org
if ($File.Count -eq 1) {
dotnet nuget push $File.FullName --api-key $NugetAPI --source https://api.nuget.org/v3/index.json

#dotnet nuget add source --username evotecit --password $GitHubAPI --store-password-in-clear-text --name github "https://nuget.pkg.github.com/OWNER/index.json"
#dotnet nuget push $File.FullName --api-key $GitHubAPI --source "github"
}
36 changes: 36 additions & 0 deletions Build/UploadGithub.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
param (
$SolutionRoot = "$PSScriptRoot\.."
)

$GitHubAccessToken = Get-Content -Raw 'C:\Support\Important\GithubAPI.txt'
$UserName = 'EvotecIT'
$GitHubRepositoryName = 'OfficeIMO'

$SolutionPath = [io.path]::Combine($SolutionRoot, 'OfficeImo.sln')
if (-not $SolutionRoot -or -not (Test-Path -Path $SolutionPath)) {
Write-Host -Object "Solution not found at $SolutionPath" -ForegroundColor Red
return
}

$ProjectPath = [io.path]::Combine($SolutionRoot, "OfficeIMO.Word", "OfficeIMO.Word.csproj")

[xml] $XML = Get-Content -Raw $ProjectPath

$Version = $XML.Project.PropertyGroup[0].VersionPrefix

$ZipPath = [io.path]::Combine($SolutionRoot, "OfficeIMO.Word", "bin", "Release", "OfficeIMO.Word.$Version.zip")
$IsPreRelease = $false
$TagName = "v$Version"

if (Test-Path -LiteralPath $ZipPath) {
$sendGitHubReleaseSplat = @{
GitHubUsername = $UserName
GitHubRepositoryName = $GitHubRepositoryName
GitHubAccessToken = $GitHubAccessToken
TagName = $TagName
AssetFilePaths = $ZipPath
IsPreRelease = $IsPreRelease
}
$StatusGithub = Send-GitHubRelease @sendGitHubReleaseSplat
$StatusGithub
}

0 comments on commit 4d41557

Please sign in to comment.