Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify MSBuild and CI #152

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 12 additions & 53 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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:
Expand All @@ -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
37 changes: 12 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -24,15 +18,18 @@ jobs:
name: Build, test, and pack
permissions:
checks: write
with:
libraryVersion: ${{ inputs.libraryVersion }}
secrets: inherit

release:
if: contains('["Swimburger","dprothero","AJLange"]', github.actor)
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:
Expand All @@ -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
41 changes: 1 addition & 40 deletions src/Twilio.AspNet.Common/Twilio.AspNet.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,46 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\Twilio.AspNet.Shared.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>13</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<OutputType>Library</OutputType>
<Version>0.0.0-alpha</Version>
<PackageId>Twilio.AspNet.Common</PackageId>
<PackageVersion>0.0.0-alpha</PackageVersion>
<Authors>Twilio Labs</Authors>
<Description>Twilio request classes for handling Twilio webhooks.</Description>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageReleaseNotes>Refer to the changelog at https://github.com/twilio-labs/twilio-aspnet/blob/main/CHANGELOG.md</PackageReleaseNotes>
<Copyright>Copyright 2024 (c) Twilio, Inc. All rights reserved.</Copyright>
<PackageTags>twilio;twiml;sms;voice;telephony;phone;aspnet</PackageTags>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/twilio/twilio-aspnet</PackageProjectUrl>
<RepositoryUrl>https://github.com/twilio-labs/twilio-aspnet.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageIconUrl>https://s3.amazonaws.com/com.twilio.prod.twilio-docs/images/twilio-icon-64x64.png</PackageIconUrl>
<PackageIcon>icon.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<PropertyGroup Condition="'$(CI)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>
<ItemGroup>
<None Include="..\..\icon.png" Pack="true" PackagePath="\" />
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="PolySharp" Version="1.15.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
47 changes: 9 additions & 38 deletions src/Twilio.AspNet.Core/Twilio.AspNet.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,54 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\Twilio.AspNet.Shared.props" />
<PropertyGroup>
<TargetFrameworks>net7.0;net8.0;net9.0</TargetFrameworks>
<LangVersion>13</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<OutputType>Library</OutputType>
<Version>0.0.0-alpha</Version>
<PackageId>Twilio.AspNet.Core</PackageId>
<PackageVersion>0.0.0-alpha</PackageVersion>
<Authors>Twilio Labs</Authors>
<Title>Twilio helper library for ASP.NET Core</Title>
<Description>Twilio helper library for ASP.NET Core</Description>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageReleaseNotes>Refer to the changelog at https://github.com/twilio-labs/twilio-aspnet/blob/main/CHANGELOG.md</PackageReleaseNotes>
<Copyright>Copyright 2024 (c) Twilio, Inc. All rights reserved.</Copyright>
<PackageTags>twilio;twiml;sms;voice;telephony;phone;aspnet</PackageTags>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/twilio-labs/twilio-aspnet</PackageProjectUrl>
<RepositoryUrl>https://github.com/twilio-labs/twilio-aspnet.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageIconUrl>https://s3.amazonaws.com/com.twilio.prod.twilio-docs/images/twilio-icon-64x64.png</PackageIconUrl>
<PackageIcon>icon.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<PropertyGroup Condition="'$(CI)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="PolySharp" Version="1.15.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Twilio" Version="7.7.0" />
<PackageReference Include="Twilio.AspNet.Common" Version="0.0.0-alpha" />

<!-- Use local project reference for local development, but NuGet package for release -->
<ProjectReference
Condition="'$(Configuration)' == 'Debug'"
Include="..\Twilio.AspNet.Common\Twilio.AspNet.Common.csproj" />
<PackageReference
Condition="'$(Configuration)' != 'Debug'"
Include="Twilio.AspNet.Common"
Version="$(TwilioAspNetCommonVersion)" />
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />

<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

<None Include="..\..\icon.png" Pack="true" PackagePath="\" />
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>Twilio.AspNet.Core.UnitTests</_Parameter1>
</AssemblyAttribute>
Expand Down
Loading
Loading