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

CI Setup #2

Merged
merged 3 commits into from
May 17, 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
82 changes: 82 additions & 0 deletions .github/workflows/post-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: "Post-Integration"

on:
push:
branches:
- main
- '!stable'
- '!release'

env:
ATC_EMAIL: '[email protected]'
ATC_NAME: 'Atc-Net'
NUGET_REPO_URL: 'https://nuget.pkg.github.com/atc-net/index.json'

jobs:
merge-to-stable:
runs-on: ubuntu-latest
steps:
- name: 🛒 Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT_WORKFLOWS }}

- name: ⚛️ Sets environment variables - branch-name
uses: nelonoel/[email protected]

- name: ⚛️ Sets environment variables - Nerdbank.GitVersioning
uses: dotnet/nbgv@master
with:
setAllVars: true

- name: ⚙️ Setup dotnet 8.0.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: ⚙️ Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'zulu'

- name: 🧹 Clean
run: dotnet clean -c Release && dotnet nuget locals all --clear

- name: 🔁 Restore packages
run: dotnet restore

- name: 🛠️ Build
run: dotnet build -c Release --no-restore /p:UseSourceLink=true

- name: 🧪 Run unit tests
run: dotnet test -c Release --no-build --filter "Category!=Integration"

- name: 🌩️ SonarCloud install scanner
run: dotnet tool install --global dotnet-sonarscanner

- name: 🌩️ SonarCloud analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: pwsh
run: |
dotnet sonarscanner begin /k:"atc-net_atc-microsoft-graph-client" /o:"atc-net" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
dotnet build -c Release /p:UseSourceLink=true --no-restore
dotnet sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"

- name: ⏩ Merge to stable-branch
run: |
git config --local user.email ${{ env.ATC_EMAIL }}
git config --local user.name ${{ env.ATC_NAME }}
git checkout stable
git merge --ff-only main
git push origin stable

- name: 🗳️ Creating library package for pre-release
run: dotnet pack -c Release --no-restore -o ${GITHUB_WORKSPACE}/packages -p:RepositoryBranch=$BRANCH_NAME

- name: 📦 Push packages to GitHub Package Registry
run: |
dotnet nuget push ${GITHUB_WORKSPACE}/packages/'Atc.Microsoft.Graph.Client.'${NBGV_NuGetPackageVersion}'.nupkg' -k ${{ secrets.GITHUB_TOKEN }} -s ${{ env.NUGET_REPO_URL }} --skip-duplicate
58 changes: 58 additions & 0 deletions .github/workflows/pre-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: "Pre-Integration"

on:
pull_request:
types:
- opened
- synchronize
- reopened

jobs:
dotnet-build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: 🛒 Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: ⚙️ Setup dotnet 8.0.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: 🧹 Clean
run: dotnet clean -c Release && dotnet nuget locals all --clear

- name: 🔁 Restore packages
run: dotnet restore

- name: 🛠️ Building library in release mode
run: dotnet build -c Release --no-restore

dotnet-test:
runs-on: ubuntu-latest
needs:
- dotnet-build
steps:
- name: 🛒 Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: ⚙️ Setup dotnet 8.0.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: 🔁 Restore packages
run: dotnet restore

- name: 🛠️ Build
run: dotnet build -c Release --no-restore /p:UseSourceLink=true

- name: 🧪 Run unit tests
run: dotnet test -c Release --no-build --filter "Category!=Integration"
57 changes: 57 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: "Release"

on:
workflow_dispatch:

env:
ATC_EMAIL: '[email protected]'
ATC_NAME: 'Atc-Net'
NUGET_REPO_URL: 'https://api.nuget.org/v3/index.json'

jobs:
release:
if: github.ref == 'refs/heads/stable'
runs-on: ubuntu-latest
steps:
- name: 🛒 Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT_WORKFLOWS }}

- name: ⚛️ Sets environment variables - branch-name
uses: nelonoel/[email protected]

- name: ⚛️ Sets environment variables - Nerdbank.GitVersioning
uses: dotnet/nbgv@master
with:
setAllVars: true

- name: ⚙️ Setup dotnet 8.0.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: 🧹 Clean
run: dotnet clean -c Release && dotnet nuget locals all --clear

- name: 🔁 Restore packages
run: dotnet restore

- name: 🛠️ Building library in release mode
run: dotnet build -c Release --no-restore /p:UseSourceLink=true

- name: ⏩ Merge to release-branch
run: |
git config --local user.email ${{ env.ATC_EMAIL }}
git config --local user.name ${{ env.ATC_NAME }}
git checkout release
git merge --ff-only stable
git push origin release

- name: 🗳️ Creating library package for release
run: dotnet pack -c Release --no-restore -o ${GITHUB_WORKSPACE}/packages -p:RepositoryBranch=$BRANCH_NAME /p:PublicRelease=true

- name: 📦 Push packages to NuGet
run: |
dotnet nuget push ${GITHUB_WORKSPACE}/packages/'Atc.Microsoft.Graph.Client.'${NBGV_NuGetPackageVersion}'.nupkg' -k ${{ secrets.NUGET_KEY }} -s ${{ env.NUGET_REPO_URL }} --skip-duplicate --no-symbols
15 changes: 15 additions & 0 deletions Atc.Microsoft.Graph.Client.sln
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,25 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{58BC6728-1
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample", "sample", "{67FE0C20-D944-47C5-A64E-AC05F7438940}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Atc.Microsoft.Graph.Client", "src\Atc.Microsoft.Graph.Client\Atc.Microsoft.Graph.Client.csproj", "{E0C8319E-49CC-4A55-B356-986320EBF055}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E0C8319E-49CC-4A55-B356-986320EBF055}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E0C8319E-49CC-4A55-B356-986320EBF055}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E0C8319E-49CC-4A55-B356-986320EBF055}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E0C8319E-49CC-4A55-B356-986320EBF055}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{E0C8319E-49CC-4A55-B356-986320EBF055} = {69C84246-AA75-43E8-94B2-66FD555B18B0}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {04120463-05C5-417B-8D7A-2D7D35B71A07}
EndGlobalSection
Expand Down
15 changes: 15 additions & 0 deletions src/Atc.Microsoft.Graph.Client/Atc.Microsoft.Graph.Client.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<PackageId>Atc.Microsoft.Graph.Client</PackageId>
<PackageTags>microsoft-graph;microsoft-graph-api;microsoft-graph-client</PackageTags>
<Description>Atc.Microsoft.Graph.Client provides a convenient abstraction layer over the Microsoft Graph SDK, simplifying interactions with Microsoft Graph APIs. By wrapping the Microsoft Graph SDK, the library offers a consistent and simplified interface, handling complexities like paging and error handling for you.</Description>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\README.md" Link="README.md" Pack="true" PackagePath="\" />
</ItemGroup>

</Project>
39 changes: 38 additions & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@
-->
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory).., Directory.Build.props))\Directory.Build.props" />

<!-- Global nuget package configurations that should not be needed to change -->
<PropertyGroup Label="Global Nuget Package metadata">
<RepositoryUrl>https://github.com/$(OrganizationName)/$(RepositoryName)</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/$(OrganizationName)/$(RepositoryName)</PackageProjectUrl>
<PackageIcon>icon.png</PackageIcon>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\images\icon.png" Pack="true" PackagePath="\" Visible="false" />
</ItemGroup>

<PropertyGroup Label="Build instructions">
<OutputType>Library</OutputType>
<!-- Creates a regular package and a symbols package -->
Expand All @@ -19,5 +33,28 @@
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<!-- Recommended: Embed symbols containing Source Link in the main file (exe/dll) -->
<DebugType>embedded</DebugType>
<!-- Will generate nuget packages for each project -->
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<!-- Web projects aren't packable by default. To override the default behavior, add the following -->
<IsPackable>true</IsPackable>
</PropertyGroup>
</Project>

<!--
By default builds are non-deterministic, meaning there is no guarantee that building the same code twice(on the same or different machines)
will produce exactly the same binary output. Deterministic builds are important as they enable verification that the resulting
binary was built from the specified source and provides traceability.

To enable deterministic builds a property should be set to through: ContinuousIntegrationBuild.

Important: This property should not be enabled during local development as the debugger won't be able to find the local source files.
-->
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.133" PrivateAssets="All" />
</ItemGroup>

</Project>