forked from Code-Artist/AGauge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving workflows over to dotnet build system
- Removing msbuild helper action - Disable debug build from running during a release - Added semver extractor (ignore the v character) - Ensured metadata is correct with currently published NuGet package - Automatic NuGet package publishing for (pre)releases - Create a draft GitHub release
- Loading branch information
Showing
6 changed files
with
76 additions
and
124 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,22 @@ | ||
# Verify valid semver from Ref string, and provide it along with an AssemblyVersion-compatible string as outputs. | ||
|
||
# Set to the value provided by github.ref | ||
param([string]$ghRef) | ||
|
||
$semVerRegex = "(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$" | ||
$matchInfo = [regex]::Match($ghRef, $semVerRegex) | ||
|
||
if (!($matchInfo.Success)) { | ||
Write-Host "Could not find valid semver within ref. string. Given: $ghRef" | ||
Exit 1 | ||
} | ||
|
||
$verRes = "ASMVER={0}.{1}.{2}" -f $matchInfo.Groups["major"], $matchInfo.Groups["minor"], $matchInfo.Groups["patch"] | ||
$semVerRes = "SEMVER=" + $matchInfo.Value | ||
$isPr = "ISPRERELEASE=" + $matchInfo.Groups.ContainsKey("prerelease") | ||
|
||
echo $verRes >> $env:GITHUB_OUTPUT | ||
echo $semVerRes >> $env:GITHUB_OUTPUT | ||
echo $isPr >> $env:GITHUB_OUTPUT | ||
|
||
Write-Host "Result: $verRes, $semVerRes, $isPr" |
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 |
---|---|---|
@@ -1,60 +1,53 @@ | ||
# name: build-release-$(git rev-parse --short "$GITHUB_SHA") | ||
run-name: Build-Release Num. ${{ github.run_number }} | ||
name: build-release | ||
|
||
on: | ||
workflow_dispatch: | ||
# inputs: | ||
# configuration: | ||
# description: 'Compiler configuration preset' | ||
# required: false | ||
# default: 'Debug' | ||
# pull_request: | ||
# branches: [ main ] | ||
# paths: | ||
# - '**.vb' | ||
# - '**.vbproj' | ||
# - '**.cs' | ||
# - '**.csproj' | ||
# - '**.resx' | ||
push: | ||
tags: "v*" | ||
branches: "main" | ||
|
||
env: | ||
DOTNET_VERSION: '4.7.2' # The .NET SDK version to use | ||
SLN_FILE: AGauge/AGauge.sln | ||
OUTPUT: AGauge/bin/Release | ||
CONFIG: Release | ||
PRIMARY_FOLDER: AGauge | ||
NUGET_API_URL: https://api.nuget.org/v3/index.json | ||
|
||
jobs: | ||
build: | ||
|
||
name: debug-build-${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [windows-latest] # Should have MSBuild. | ||
runs-on: windows-latest | ||
steps: | ||
# Make MSBuild available from $PATH. | ||
- name: setup-msbuild | ||
uses: microsoft/setup-msbuild@v1 | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
- name: Extract version info | ||
id: exVer | ||
run: .\.github\get-ver.ps1 ${{ github.ref }} | ||
|
||
# - name: Restore Packages | ||
# run: msbuild -t:restore | ||
- name: Setup dotnet | ||
uses: actions/setup-dotnet@v4 | ||
|
||
- name: Build solution | ||
run: msbuild $env:SLN_FILE -p:Configuration=$env:CONFIG | ||
- name: Build Project | ||
run: > | ||
dotnet build ${{ env.PRIMARY_FOLDER }}\AGauge.csproj | ||
--nologo | ||
-c Release | ||
-p:Version=${{ steps.exVer.outputs.ASMVER }} | ||
-p:PackageVersion=${{ steps.exVer.outputs.SEMVER }} | ||
- name: Get AssemblyVersion generated by msbuild | ||
id: getversion | ||
uses: berglie/assembly-version/get@v1 | ||
with: | ||
directory: ${{ env.OUTPUT }} | ||
- name: Push to NuGet | ||
run: > | ||
dotnet nuget push | ||
${{ env.PRIMARY_FOLDER }}\bin\Release\*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source ${{ env.NUGET_API_URL }} | ||
- name: Upload Artifact | ||
uses: actions/upload-artifact@v3 | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ format('AGauge-v{0}', steps.getversion.outputs.version) }} | ||
name: AGauge-Release-CIBuild_${{ github.run_number }} | ||
path: ${{ env.PRIMARY_FOLDER }}\bin\Release | ||
if-no-files-found: error | ||
path: ${{ env.OUTPUT }} | ||
|
||
|
||
- name: Create GH Release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
draft: true | ||
prerelease: ${{ steps.exVer.outputs.ISPRERELEASE }} | ||
files: ${{ env.PRIMARY_FOLDER }}/bin/Release/* | ||
fail_on_unmatched_files: true | ||
generate_release_notes: true |
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