Skip to content

Commit

Permalink
ci: add github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
perkops committed May 17, 2024
1 parent f297230 commit dccb08c
Show file tree
Hide file tree
Showing 3 changed files with 197 additions and 0 deletions.
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

0 comments on commit dccb08c

Please sign in to comment.