Skip to content

Commit

Permalink
Merge pull request #7 from nutdotnet/6-full-cd
Browse files Browse the repository at this point in the history
Implement CI/CD
  • Loading branch information
gbakeman authored May 1, 2024
2 parents 581ae47 + 520c872 commit b3c311d
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 161 deletions.
22 changes: 22 additions & 0 deletions .github/get-ver.ps1
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"
37 changes: 37 additions & 0 deletions .github/workflows/build-debug.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: build-debug

on:
workflow_dispatch:

# Cause GH to build only for modified code files in a PR, but not when a tag is specified (https://stackoverflow.com/a/71879890/530172)
pull_request:
paths:
- "**.cs"
- "**.csproj"

env:
PRIMARY_FOLDER: AGauge

jobs:
build-debug:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup dotnet
uses: actions/setup-dotnet@v4

- name: Build Project
run: >
dotnet build ${{ env.PRIMARY_FOLDER }}\AGauge.csproj
--nologo
-c Debug
-p:Version=1.0.0.0
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: AGauge-Debug-CIBuild_${{ github.run_number }}
path: ${{ env.PRIMARY_FOLDER }}\bin\Debug
if-no-files-found: error
81 changes: 37 additions & 44 deletions .github/workflows/build-release.yaml
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
Binary file removed AGauge/AGauge.bmp
Binary file not shown.
109 changes: 36 additions & 73 deletions AGauge/AGauge.csproj
Original file line number Diff line number Diff line change
@@ -1,86 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{CBDB1D25-5A95-43D4-A958-BF6AE65C6C3F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>System.Windows.Forms</RootNamespace>
<AssemblyName>AGauge.Classic</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFramework>net472</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AGauge.cs">
<Compile Update="AGauge.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="AGauge.Designer.cs">
<DependentUpon>AGauge.cs</DependentUpon>
</Compile>
<Compile Include="AGaugeLabel.cs" />
<Compile Include="AGaugeLabelCollection.cs" />
<Compile Include="AGaugeNeedleColor.cs" />
<Compile Include="AGaugeRange.cs" />
<Compile Include="AGaugeRangeCollection.cs" />
<Compile Include="Categories.cs" />
<Compile Include="NeedleType.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ValueInRangeChangedEventArgs.cs" />
</ItemGroup>
<ItemGroup>
<None Include=".editorconfig" />
<None Include="AGauge - FxCop.FxCop" />
<None Include="AGauge.nuspec" />
<None Include="..\LICENSE">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="AGauge.bmp" />
<None Update="AGauge.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
<Description>Customizable WinForms gauge control - maintained by the NUTDotNet organization.</Description>
<Authors>A. J. Bauer, with further work by Code Artist and others.</Authors>
<Version />
<Company>NUTDotNet Organization</Company>
<Copyright>Copyright © NUTDotNet 2023-2024</Copyright>
<PackageProjectUrl>https://github.com/nutdotnet/AGauge</PackageProjectUrl>
<PackageIcon>AGauge.png</PackageIcon>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/nutdotnet/AGauge.git</RepositoryUrl>
<PackageTags>gauge, winforms, control</PackageTags>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<IncludeSymbols>True</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PackageId>AGauge.Classic</PackageId>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
6 changes: 3 additions & 3 deletions AGauge/AGauge.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
<metadata>
<!-- Required elements-->
<id>$id$</id>
<version>2.0.5-prerelease.1</version>
<version>$version$</version>
<description>$description$</description>
<authors>$author$</authors>
<readme>docs\README.md</readme>

<!-- Optional elements -->
<readme>docs\README.md</readme>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="expression">MIT</license>
<!-- <icon>AGauge.bmp</icon> -->
<projectUrl>https://github.com/nutdotnet/AGauge</projectUrl>
<releaseNotes>https://github.com/nutdotnet/AGauge/releases</releaseNotes>
<copyright>$copyright$</copyright>
<tags>gauge, winforms, control</tags>
<tags>$tags$</tags>
<title>$title$</title>
</metadata>

Expand Down
Binary file added AGauge/AGauge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 0 additions & 37 deletions AGauge/Properties/AssemblyInfo.cs

This file was deleted.

9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ A customizable, inheritable .Net Framework WinForms Control based on the [initia
## Enhancements
- Dynamic Gauge Label and Gauge Range
- NeedleType Enumeration
- ValueChangedEvent
- Events for changes to different components
- Structural code improvements, make different parts overridable
- Bugfixes and performance improvements

#Package and Download
# Package and Download
- NuGet: [AGauge.Classic](https://www.nuget.org/packages/AGauge.Classic)

See the Releases page for additional distributions.
- See the Releases page for additional information.

0 comments on commit b3c311d

Please sign in to comment.