From 03cf59310e8cd207072a58abf4cbf8919607f60f Mon Sep 17 00:00:00 2001
From: Niels Swimberghe <3382717+Swimburger@users.noreply.github.com>
Date: Fri, 6 Dec 2024 12:27:12 -0500
Subject: [PATCH] Simplify MSBuild and CI - introduce shared props file - store
library version in props file - simplify ci/release yml
---
.github/workflows/ci.yml | 65 ++--------
.github/workflows/release.yml | 37 ++----
.../Twilio.AspNet.Common.csproj | 41 +------
.../Twilio.AspNet.Core.csproj | 47 ++-----
.../Twilio.AspNet.Mvc.csproj | 115 +++++++-----------
src/Twilio.AspNet.Shared.props | 47 +++++++
src/Twilio.AspNet.sln | 1 -
version_bump.ps1 | 56 ---------
8 files changed, 124 insertions(+), 285 deletions(-)
create mode 100644 src/Twilio.AspNet.Shared.props
delete mode 100755 version_bump.ps1
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 2b65ed3..f3c6061 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1,14 +1,7 @@
name: CI Build
on:
- workflow_dispatch:
- inputs:
- libraryVersion:
- description: 'The version of the library to use when compiling and packaging.'
- default: 0.0.0-alpha
- required: false
- type: string
-
+ workflow_dispatch: {}
push:
branches: [ "main" ]
paths:
@@ -23,17 +16,11 @@ on:
- '.github/workflows/*'
- '.github/actions/*'
- workflow_call:
- inputs:
- libraryVersion:
- type: string
- description: 'The version of the library to use when compiling and packaging.'
- required: true
-
env:
CI: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_NOLOGO: true
+ MSBUILDTERMINALLOGGER: off
jobs:
build:
@@ -49,117 +36,89 @@ jobs:
with:
dotnet-version: 9.x
- - name: Update project versions
- run: |
- Get-ChildItem **/*.csproj -Recurse | ForEach-Object {
- $FileContent = Get-Content $_
- $NewVersion = '${{ inputs.libraryVersion }}'
- if($NewVersion -eq '') { Return }
- If($FileContent -like '*0.0.0-alpha*')
- {
- $FileContent -replace '0.0.0-alpha',$NewVersion | Set-Content -Path $_
- }
- }
- shell: pwsh
-
# Build and pack Twilio.AspNet.Common
- name: (Twilio.AspNet.Common) Restore
run: dotnet restore
working-directory: src/Twilio.AspNet.Common/
- shell: pwsh
- name: (Twilio.AspNet.Common) Build
run: dotnet build --no-restore --configuration Release
working-directory: src/Twilio.AspNet.Common/
- shell: pwsh
- name: (Twilio.AspNet.Common) Pack
- run: dotnet pack -c Release -o ..\..\
+ run: dotnet pack --no-restore --no-build --configuration Release --output ..\..\
working-directory: src/Twilio.AspNet.Common/
- shell: pwsh
- name: (Twilio.AspNet.Common) Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: Twilio.AspNet.Common NuGet Package
path: |
- Twilio.AspNet.Common.${{ inputs.libraryVersion || '0.0.0-alpha' }}.nupkg
- Twilio.AspNet.Common.${{ inputs.libraryVersion || '0.0.0-alpha' }}.snupkg
+ Twilio.AspNet.Common.*.nupkg
+ Twilio.AspNet.Common.*.snupkg
# Build, test, and pack Twilio.AspNet.Core
- name: (Twilio.AspNet.Core) Restore
run: dotnet restore
working-directory: src/Twilio.AspNet.Core/
- shell: pwsh
- name: (Twilio.AspNet.Core) Build
run: dotnet build --no-restore --configuration Release
working-directory: src/Twilio.AspNet.Core/
- shell: pwsh
- name: (Twilio.AspNet.Core.UnitTests) Restore
run: dotnet restore
working-directory: src/Twilio.AspNet.Core.UnitTests/
- shell: pwsh
- name: (Twilio.AspNet.Core.UnitTests) Build
run: dotnet build --no-restore
working-directory: src/Twilio.AspNet.Core.UnitTests/
- shell: pwsh
- name: (Twilio.AspNet.Core.UnitTests) Test
- run: dotnet test --no-build --no-restore
+ run: dotnet test --no-restore --no-build
working-directory: src/Twilio.AspNet.Core.UnitTests/
- shell: pwsh
- name: (Twilio.AspNet.Core) Pack
- run: dotnet pack --no-build --no-restore -c Release -o ..\..\
+ run: dotnet pack --no-restore --no-build --configuration Release --output ..\..\
working-directory: src/Twilio.AspNet.Core/
- shell: pwsh
- name: (Twilio.AspNet.Core) Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: Twilio.AspNet.Core NuGet Package
path: |
- Twilio.AspNet.Core.${{ inputs.libraryVersion || '0.0.0-alpha' }}.nupkg
- Twilio.AspNet.Core.${{ inputs.libraryVersion || '0.0.0-alpha' }}.snupkg
+ Twilio.AspNet.Core.*.nupkg
+ Twilio.AspNet.Core.*.snupkg
# Build, test, and pack Twilio.AspNet.Mvc
- name: (Twilio.AspNet.Mvc) Restore
run: dotnet restore
working-directory: src/Twilio.AspNet.Mvc/
- shell: pwsh
- name: (Twilio.AspNet.Mvc) Build
run: dotnet build --no-restore --configuration Release
working-directory: src/Twilio.AspNet.Mvc/
- shell: pwsh
- name: (Twilio.AspNet.Mvc.UnitTests) Restore
run: dotnet restore
working-directory: src/Twilio.AspNet.Mvc.UnitTests/
- shell: pwsh
- name: (Twilio.AspNet.Mvc.UnitTests) Build
run: dotnet build --no-restore
working-directory: src/Twilio.AspNet.Mvc.UnitTests/
- shell: pwsh
- name: (Twilio.AspNet.Mvc.UnitTests) Test
run: dotnet test --no-build --no-restore
working-directory: src/Twilio.AspNet.Mvc.UnitTests/
- shell: pwsh
- name: (Twilio.AspNet.Mvc) Pack
- run: dotnet pack --no-build --no-restore -c Release -o ..\..\
+ run: dotnet pack --no-build --no-restore --configuration Release --output ..\..\
working-directory: src/Twilio.AspNet.Mvc/
- shell: pwsh
- name: (Twilio.AspNet.Mvc) Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: Twilio.AspNet.Mvc NuGet Package
path: |
- Twilio.AspNet.Mvc.${{ inputs.libraryVersion || '0.0.0-alpha' }}.nupkg
- Twilio.AspNet.Mvc.${{ inputs.libraryVersion || '0.0.0-alpha' }}.snupkg
+ Twilio.AspNet.Mvc.*.nupkg
+ Twilio.AspNet.Mvc.*.snupkg
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 98b9d4c..e4c8e18 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -1,21 +1,15 @@
name: Release
on:
- workflow_dispatch:
- inputs:
- libraryVersion:
- description: 'The version of the library to use when compiling and packaging.'
- required: true
- type: string
- prerelease:
- description: 'Is this a prerelease (alpha/beta/rc)?'
- required: true
- type: boolean
+ workflow_dispatch: {}
+ release:
+ types: [published]
env:
CI: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_NOLOGO: true
+ MSBUILDTERMINALLOGGER: off
jobs:
build:
@@ -24,8 +18,6 @@ jobs:
name: Build, test, and pack
permissions:
checks: write
- with:
- libraryVersion: ${{ inputs.libraryVersion }}
secrets: inherit
release:
@@ -33,6 +25,11 @@ jobs:
runs-on: ubuntu-latest
needs: [build]
steps:
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v4
+ with:
+ dotnet-version: 9.x
+
- uses: actions/download-artifact@v4
name: Download Twilio.AspNet.Common NuGet Package
with:
@@ -47,31 +44,21 @@ jobs:
name: Download Twilio.AspNet.Mvc NuGet Package
with:
name: Twilio.AspNet.Mvc NuGet Package
-
- - uses: ncipollo/release-action@v1
- name: Create GitHub Release and Tag
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- with:
- tag: ${{ inputs.libraryVersion }}
- artifacts: "*.nupkg,*.snupkg"
- token: ${{ secrets.GITHUB_TOKEN }}
- prerelease: ${{ inputs.prerelease }}
- name: (Twilio.AspNet.Common) Push to NuGet
run: |
- dotnet nuget push 'Twilio.AspNet.Common.${{ inputs.libraryVersion }}.nupkg' \
+ dotnet nuget push 'Twilio.AspNet.Common.*.nupkg' \
--api-key ${{ secrets.NUGET_API_KEY }} \
--source https://api.nuget.org/v3/index.json
- name: (Twilio.AspNet.Core) Push to NuGet
run: |
- dotnet nuget push 'Twilio.AspNet.Core.${{ inputs.libraryVersion }}.nupkg' \
+ dotnet nuget push 'Twilio.AspNet.Core.*.nupkg' \
--api-key ${{ secrets.NUGET_API_KEY }} \
--source https://api.nuget.org/v3/index.json
- name: (Twilio.AspNet.Mvc) Push to NuGet
run: |
- dotnet nuget push 'Twilio.AspNet.Mvc.${{ inputs.libraryVersion }}.nupkg' \
+ dotnet nuget push 'Twilio.AspNet.Mvc.*.nupkg' \
--api-key ${{ secrets.NUGET_API_KEY }} \
--source https://api.nuget.org/v3/index.json
diff --git a/src/Twilio.AspNet.Common/Twilio.AspNet.Common.csproj b/src/Twilio.AspNet.Common/Twilio.AspNet.Common.csproj
index 65e4604..bcf8e34 100644
--- a/src/Twilio.AspNet.Common/Twilio.AspNet.Common.csproj
+++ b/src/Twilio.AspNet.Common/Twilio.AspNet.Common.csproj
@@ -1,46 +1,7 @@
+
netstandard2.0
- 13
- enable
- enable
- Library
- 0.0.0-alpha
- Twilio.AspNet.Common
- 0.0.0-alpha
- Twilio Labs
Twilio request classes for handling Twilio webhooks.
- false
- Refer to the changelog at https://github.com/twilio-labs/twilio-aspnet/blob/main/CHANGELOG.md
- Copyright 2024 (c) Twilio, Inc. All rights reserved.
- twilio;twiml;sms;voice;telephony;phone;aspnet
- Apache-2.0
- https://github.com/twilio/twilio-aspnet
- https://github.com/twilio-labs/twilio-aspnet.git
- git
- https://s3.amazonaws.com/com.twilio.prod.twilio-docs/images/twilio-icon-64x64.png
- icon.png
- README.md
- true
- true
- true
- snupkg
-
- true
-
-
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
\ No newline at end of file
diff --git a/src/Twilio.AspNet.Core/Twilio.AspNet.Core.csproj b/src/Twilio.AspNet.Core/Twilio.AspNet.Core.csproj
index 7d56dae..4d2dea1 100644
--- a/src/Twilio.AspNet.Core/Twilio.AspNet.Core.csproj
+++ b/src/Twilio.AspNet.Core/Twilio.AspNet.Core.csproj
@@ -1,54 +1,25 @@
+
net7.0;net8.0;net9.0
- 13
- enable
- enable
- Library
- 0.0.0-alpha
Twilio.AspNet.Core
- 0.0.0-alpha
- Twilio Labs
Twilio helper library for ASP.NET Core
Twilio helper library for ASP.NET Core
- false
- Refer to the changelog at https://github.com/twilio-labs/twilio-aspnet/blob/main/CHANGELOG.md
- Copyright 2024 (c) Twilio, Inc. All rights reserved.
- twilio;twiml;sms;voice;telephony;phone;aspnet
- Apache-2.0
- https://github.com/twilio-labs/twilio-aspnet
- https://github.com/twilio-labs/twilio-aspnet.git
- git
- https://s3.amazonaws.com/com.twilio.prod.twilio-docs/images/twilio-icon-64x64.png
- icon.png
- README.md
- true
- true
- true
- snupkg
-
-
- true
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
+
+
+
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
<_Parameter1>Twilio.AspNet.Core.UnitTests
diff --git a/src/Twilio.AspNet.Mvc/Twilio.AspNet.Mvc.csproj b/src/Twilio.AspNet.Mvc/Twilio.AspNet.Mvc.csproj
index 3d5f583..16b765a 100644
--- a/src/Twilio.AspNet.Mvc/Twilio.AspNet.Mvc.csproj
+++ b/src/Twilio.AspNet.Mvc/Twilio.AspNet.Mvc.csproj
@@ -1,75 +1,46 @@
-
- Library
- net462
- 13
- enable
- enable
- 0.0.0-alpha
- Twilio.AspNet.Mvc
- 0.0.0-alpha
- Twilio Labs
- Twilio helper library for ASP.NET MVC
- Twilio helper library for ASP.NET MVC on .NET Framework.
- false
- Refer to the changelog at https://github.com/twilio-labs/twilio-aspnet/blob/main/CHANGELOG.md
- Copyright 2024 (c) Twilio, Inc. All rights reserved.
- twilio;twiml;sms;voice;telephony;phone;aspnet
- Apache-2.0
- https://github.com/twilio-labs/twilio-aspnet
- https://github.com/twilio-labs/twilio-aspnet.git
- git
- https://s3.amazonaws.com/com.twilio.prod.twilio-docs/images/twilio-icon-64x64.png
- icon.png
- README.md
- true
- true
- true
- snupkg
-
-
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
- all
-
-
-
-
- <_Parameter1>Twilio.AspNet.Mvc.UnitTests
-
-
+
+
+ net462
+ Twilio.AspNet.Mvc
+ Twilio helper library for ASP.NET MVC
+ Twilio helper library for ASP.NET MVC on .NET Framework.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ all
+
+
+
+
+ <_Parameter1>Twilio.AspNet.Mvc.UnitTests
+
+
diff --git a/src/Twilio.AspNet.Shared.props b/src/Twilio.AspNet.Shared.props
new file mode 100644
index 0000000..b70fa80
--- /dev/null
+++ b/src/Twilio.AspNet.Shared.props
@@ -0,0 +1,47 @@
+
+
+ Twilio Labs
+ Copyright 2024 (c) Twilio, Inc. All rights reserved.
+ false
+ Refer to the changelog at https://github.com/twilio-labs/twilio-aspnet/blob/main/CHANGELOG.md
+ twilio;twiml;sms;voice;telephony;phone;aspnet
+ Apache-2.0
+ https://github.com/twilio-labs/twilio-aspnet
+ https://github.com/twilio-labs/twilio-aspnet.git
+ git
+ https://s3.amazonaws.com/com.twilio.prod.twilio-docs/images/twilio-icon-64x64.png
+ icon.png
+ README.md
+ true
+ true
+ true
+ snupkg
+ 8.1.1
+ $(Version)
+ $(Version)
+ $(Version)
+ $(Version)
+ 13
+ enable
+ enable
+ Library
+ true
+
+
+ true
+
+
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
\ No newline at end of file
diff --git a/src/Twilio.AspNet.sln b/src/Twilio.AspNet.sln
index 386ed3b..3558d82 100644
--- a/src/Twilio.AspNet.sln
+++ b/src/Twilio.AspNet.sln
@@ -19,7 +19,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
..\LICENSE = ..\LICENSE
..\nuget.config = ..\nuget.config
..\README.md = ..\README.md
- ..\version_bump.ps1 = ..\version_bump.ps1
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Twilio.AspNet.Core", "Twilio.AspNet.Core\Twilio.AspNet.Core.csproj", "{0BFC96B4-9E96-499D-B6E3-C8D17BCF869F}"
diff --git a/version_bump.ps1 b/version_bump.ps1
deleted file mode 100755
index 7692645..0000000
--- a/version_bump.ps1
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/usr/bin/env pwsh
-function updateStandardCsproj() {
- Param($inputFileNameRelative, $targetVersion)
-
- Write-Host "Updating : $inputFileNameRelative"
-
- $inputFileName = Join-Path $PSScriptRoot $inputFileNameRelative
- $fileContent = [xml](Get-Content $inputFileName)
- if ($fileContent.Project.PropertyGroup.Version) {
- $fileContent.Project.PropertyGroup.Version = $targetVersion.ToString()
- }
- if ($fileContent.Project.PropertyGroup.PackageVersion) {
- $fileContent.Project.PropertyGroup.PackageVersion = $targetVersion.ToString()
- }
-
- $fileContent.Project.ItemGroup `
- | Where-Object { $_.PackageReference -ne $Null } `
- | Select-Object -ExpandProperty PackageReference `
- | Where-Object { $_.Include -ne $Null -and $_.Include.StartsWith("Twilio") } `
- | ForEach-Object {
- $_.Version = $targetVersion.ToString()
- }
-
- $fileContent.Save($inputFileName)
-}
-
-$currentVersion = [version]([xml](Get-Content src/Twilio.AspNet.Common/Twilio.AspNet.Common.csproj)).Project.PropertyGroup.PackageVersion
-
-$twilioPackageInfo = (Invoke-WebRequest https://www.nuget.org/packages/Twilio/latest).Content
-$maxVersion = [version]"0.0.0"
-
-if ($twilioPackageInfo -match "\| Twilio (\d+\.\d+\.\d+)") {
- $maxVersion = [version]$matches[1]
-}
-
-Write-Host "Current Version: $currentVersion"
-Write-Host "Latest Twilio package version: $maxVersion"
-
-# if ($currentVersion -ge $maxVersion) {
-# Throw "Current version is >= Twilio package version. No automation for this case."
-# }
-
-Write-Host "Bump version to match Twilio package?" -ForegroundColor Yellow
-$userInput = Read-Host " ( y / N ) "
-
-if (-not ($userInput -ieq 'y')) {
- Throw "Aborted."
-}
-
-Write-Host "Let's do this!"
-
-updateStandardCsproj "src/Twilio.AspNet.Common/Twilio.AspNet.Common.csproj" $maxVersion
-updateStandardCsproj "src/Twilio.AspNet.Core/Twilio.AspNet.Core.csproj" $maxVersion
-updateStandardCsproj "src/Twilio.AspNet.Core.UnitTests/Twilio.AspNet.Core.UnitTests.csproj" $maxVersion
-updateStandardCsproj "src/Twilio.AspNet.Mvc/Twilio.AspNet.Mvc.csproj" $maxVersion
-updateStandardCsproj "src/Twilio.AspNet.Mvc.UnitTests/Twilio.AspNet.Mvc.UnitTests.csproj" $maxVersion
\ No newline at end of file