-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(actions): build and release tools + attributes
- Loading branch information
Showing
6 changed files
with
419 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,15 @@ on: | |
required: false | ||
type: boolean | ||
default: false | ||
packages_to_release: | ||
description: "Packages to release" | ||
required: false | ||
type: choice | ||
options: | ||
- "DisCatSharp" | ||
- "DisCatSharp.Attributes" | ||
- "DisCatSharp.Tools" | ||
|
||
|
||
env: | ||
DOTNET_NOLOGO: true | ||
|
@@ -48,20 +57,43 @@ jobs: | |
dotnet-version: | | ||
8.0.100 | ||
7.0.404 | ||
- name: Restore dependencies | ||
- name: Restore dependencies (DisCatSharp) | ||
if: ${{ github.event.inputs.packages_to_release }} == 'DisCatSharp' | ||
run: dotnet restore --no-cache -f -v minimal DisCatSharp.sln | ||
- name: Build library as full release | ||
- name: Restore dependencies (DisCatSharp.Attributes) | ||
if: ${{ github.event.inputs.packages_to_release }} == 'DisCatSharp.Attributes' | ||
run: dotnet restore --no-cache -f -v minimal DisCatSharp.Attributes/DisCatSharp.Attributes.csproj | ||
- name: Restore dependencies (DisCatSharp.Tools) | ||
if: ${{ github.event.inputs.packages_to_release }} == 'DisCatSharp.Tools' | ||
run: dotnet restore --no-cache -f -v minimal DisCatSharp.Tools/DisCatSharp.Tools.sln | ||
- name: Build DisCatSharp as full release | ||
if: ${{!inputs.release_as_prerelease}} | ||
shell: pwsh | ||
run: ./DisCatSharp.Tools/rebuild-lib.ps1 -ArtifactLocation ./dcs-artifacts -Configuration Release | ||
env: | ||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | ||
- name: Build library as pre-release | ||
- name: Build DisCatSharp as pre-release | ||
if: ${{inputs.release_as_prerelease}} | ||
shell: pwsh | ||
run: ./DisCatSharp.Tools/rebuild-lib.ps1 -ArtifactLocation ./dcs-artifacts -Configuration Release -VersionSuffix ${{github.event.inputs.version_suffix}} | ||
env: | ||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | ||
- name: Build DisCatSharp.Attributes as full release | ||
if: ${{!inputs.release_as_prerelease}} && ${{ github.event.inputs.packages_to_release }} == 'DisCatSharp.Attributes' | ||
shell: pwsh | ||
run: ./DisCatSharp.Tools/rebuild-attributes.ps1 -ArtifactLocation ./dcs-artifacts -Configuration Release | ||
- name: Build DisCatSharp.Attributes as pre-release | ||
if: ${{inputs.release_as_prerelease}} && ${{ github.event.inputs.packages_to_release }} == 'DisCatSharp.Attributes' | ||
shell: pwsh | ||
run: ./DisCatSharp.Tools/rebuild-attributes.ps1 -ArtifactLocation ./dcs-artifacts -Configuration Release -VersionSuffix ${{github.event.inputs.version_suffix}} | ||
- name: Build DisCatSharp.Tools as full release | ||
if: ${{!inputs.release_as_prerelease}} && ${{ github.event.inputs.packages_to_release }} == 'DisCatSharp.Tools' | ||
shell: pwsh | ||
run: ./DisCatSharp.Tools/rebuild-tools.ps1 -ArtifactLocation ./dcs-artifacts -Configuration Release | ||
- name: Build DisCatSharp.Tools as pre-release | ||
if: ${{inputs.release_as_prerelease}} && ${{ github.event.inputs.packages_to_release }} == 'DisCatSharp.Tools' | ||
shell: pwsh | ||
run: ./DisCatSharp.Tools/rebuild-tools.ps1 -ArtifactLocation ./dcs-artifacts -Configuration Release -VersionSuffix ${{github.event.inputs.version_suffix}} | ||
- name: Remove invalid packages | ||
shell: pwsh | ||
run: rm *.symbols.* | ||
|
@@ -75,19 +107,20 @@ jobs: | |
run: dotnet nuget push --source https://nuget.pkg.github.com/Aiko-IT-Systems/index.json -k ${{secrets.NYUW_TOKEN_GH}} * | ||
working-directory: ./dcs-artifacts | ||
- name: Set outputs | ||
if: ${{ github.event.inputs.packages_to_release }} == 'DisCatSharp' | ||
id: vars | ||
run: | | ||
echo "version=10.6.0" >> $GITHUB_OUTPUT | ||
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT | ||
- name: "Create Sentry prod release" | ||
if: ${{!inputs.release_as_prerelease}} | ||
if: ${{!inputs.release_as_prerelease}} && ${{ github.event.inputs.packages_to_release }} == 'DisCatSharp' | ||
uses: getsentry/[email protected] | ||
with: | ||
environment: prod | ||
ignore_missing: true | ||
version: DisCatSharp@${{ steps.vars.outputs.version }}+${{ steps.vars.outputs.sha }} | ||
- name: "Create Sentry dev release" | ||
if: ${{inputs.release_as_prerelease}} | ||
if: ${{inputs.release_as_prerelease}} && ${{ github.event.inputs.packages_to_release }} == 'DisCatSharp' | ||
uses: getsentry/[email protected] | ||
with: | ||
environment: dev | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
#!/usr/bin/env pwsh | ||
# Rebuild-lib | ||
# | ||
# Rebuilds the entire DisCatSharp project, and places artifacts in specified directory. | ||
# | ||
# Author: Emzi0767 | ||
# Version: 2018-08-30 14:41 | ||
# | ||
# Arguments: | ||
# .\rebuild-lib.ps1 <output path> <configuration> [version suffix] [build number] | ||
# | ||
# Run as: | ||
# .\rebuild-lib.ps1 .\path\to\artifact\location Debug/Release version-suffix build-number | ||
# | ||
# or | ||
# .\rebuild-lib.ps1 .\path\to\artifact\location Debug/Release | ||
|
||
param | ||
( | ||
[parameter(Mandatory = $true)] | ||
[string] $ArtifactLocation, | ||
|
||
[parameter(Mandatory = $true)] | ||
[string] $Configuration, | ||
|
||
[parameter(Mandatory = $false)] | ||
[string] $VersionSuffix, | ||
|
||
[parameter(Mandatory = $false)] | ||
[int] $BuildNumber = -1 | ||
) | ||
|
||
# Check if configuration is valid | ||
if ($Configuration -ne "Debug" -and $Configuration -ne "Release") | ||
{ | ||
Write-Host "Invalid configuration specified. Must be Release or Debug." | ||
Exit 1 | ||
} | ||
|
||
# Restores the environment | ||
function Restore-Environment() | ||
{ | ||
Write-Host "Restoring environment" | ||
Remove-Item ./NuGet.config | ||
} | ||
|
||
# Prepares the environment | ||
function Prepare-Environment([string] $target_dir_path) | ||
{ | ||
# Prepare the environment | ||
Copy-Item ./.nuget/NuGet.config ./ | ||
|
||
# Check if the target directory exists | ||
# If it does, remove it | ||
if (Test-Path "$target_dir_path") | ||
{ | ||
Write-Host "Target directory exists, deleting" | ||
Remove-Item -recurse -force "$target_dir_path" | ||
} | ||
|
||
# Create target directory | ||
$dir = New-Item -type directory "$target_dir_path" | ||
} | ||
|
||
# Builds everything | ||
function Build-All([string] $target_dir_path, [string] $version_suffix, [string] $build_number, [string] $bcfg) | ||
{ | ||
# Form target path | ||
$dir = Get-Item "$target_dir_path" | ||
$target_dir = $dir.FullName | ||
Write-Host "Will place packages in $target_dir" | ||
|
||
# Clean previous build results | ||
Write-Host "Cleaning previous build" | ||
& dotnet clean -v minimal -c "$bcfg" DisCatSharp.Tools/DisCatSharp.Tools.sln | Out-Host | ||
if ($LastExitCode -ne 0) | ||
{ | ||
Write-Host "Cleanup failed" | ||
Return $LastExitCode | ||
} | ||
|
||
# Restore nuget packages | ||
Write-Host "Restoring NuGet packages" | ||
& dotnet restore --no-cache -f -v minimal DisCatSharp.Tools/DisCatSharp.Tools.sln | Out-Host | ||
if ($LastExitCode -ne 0) | ||
{ | ||
Write-Host "Restoring packages failed" | ||
Return $LastExitCode | ||
} | ||
|
||
# Create build number string | ||
if (-not $build_number) | ||
{ | ||
$build_number_string = "" | ||
} | ||
else | ||
{ | ||
$build_number_string = [int]::Parse($build_number).ToString("00000") | ||
} | ||
|
||
# Build in specified configuration | ||
Write-Host "Building everything" | ||
if (-not $version_suffix) | ||
{ | ||
& dotnet build --no-restore -v minimal -c "$bcfg" DisCatSharp.Attributes/DisCatSharp.Attributes.csproj | Out-Host | ||
} | ||
elseif (-not $build_number_string) | ||
{ | ||
& dotnet build --no-restore -v minimal -c "$bcfg" --version-suffix "$version_suffix" DisCatSharp.Attributes/DisCatSharp.Attributes.csproj | Out-Host | ||
} | ||
else | ||
{ | ||
& dotnet build --no-restore -v minimal -c "$bcfg" --version-suffix "$version_suffix" -p:BuildNumber="$build_number_string" DisCatSharp.Attributes/DisCatSharp.Attributes.csproj | Out-Host | ||
} | ||
if ($LastExitCode -ne 0) | ||
{ | ||
Write-Host "Build failed" | ||
Return $LastExitCode | ||
} | ||
|
||
# Package for NuGet | ||
Write-Host "Creating NuGet packages" | ||
if (-not $version_suffix) | ||
{ | ||
& dotnet pack -v minimal -c "$bcfg" --no-restore --no-build -o "$target_dir" --include-symbols DisCatSharp.Attributes/DisCatSharp.Attributes.csproj | Out-Host | ||
} | ||
elseif (-not $build_number_string) | ||
{ | ||
& dotnet pack -v minimal -c "$bcfg" --no-restore --version-suffix "$version_suffix" --no-build -o "$target_dir" --include-symbols DisCatSharp.Attributes/DisCatSharp.Attributes.csproj | Out-Host | ||
} | ||
else | ||
{ | ||
& dotnet pack -v minimal -c "$bcfg" --no-restore --version-suffix "$version_suffix" -p:BuildNumber="$build_number_string" --no-build -o "$target_dir" --include-symbols DisCatSharp.Attributes/DisCatSharp.Attributes.csproj | Out-Host | ||
} | ||
if ($LastExitCode -ne 0) | ||
{ | ||
Write-Host "Packaging failed" | ||
Return $LastExitCode | ||
} | ||
|
||
Return 0 | ||
} | ||
|
||
# Check if building a pre-production package | ||
if ($VersionSuffix -and $BuildNumber -ge 0) | ||
{ | ||
Write-Host "Building pre-production package with version suffix of `"$VersionSuffix-$($BuildNumber.ToString("00000"))`"" | ||
} | ||
elseif ($VersionSuffix -and (-not $BuildNumber -or $BuildNumber -lt 0)) | ||
{ | ||
Write-Host "Building pre-production package with version suffix of `"$VersionSuffix`"" | ||
Remove-Variable BuildNumber | ||
$BuildNumber = $null | ||
} | ||
|
||
# Prepare environment | ||
Prepare-Environment "$ArtifactLocation" | ||
|
||
# Build everything | ||
$BuildResult = Build-All "$ArtifactLocation" "$VersionSuffix" "$BuildNumber" "$Configuration" | ||
|
||
# Restore environment | ||
Restore-Environment | ||
|
||
# Check if there were any errors | ||
if ($BuildResult -ne 0) | ||
{ | ||
Write-Host "Build failed with code $BuildResult" | ||
$host.SetShouldExit($BuildResult) | ||
Exit $BuildResult | ||
} | ||
else | ||
{ | ||
Exit 0 | ||
} |
Oops, something went wrong.