Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
fazelukario committed Apr 20, 2024
2 parents b3a1b78 + 9270fe0 commit 3cb207c
Show file tree
Hide file tree
Showing 2 changed files with 151 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net

name: .NET

on: [push, pull_request]

env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
DOTNET_SDK_VERSION: 8.0

jobs:
build:
strategy:
matrix:
configuration: [Release, Debug]

name: Build and Package
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_SDK_VERSION }}

- name: Verify .NET
run: dotnet --info

- name: Restore dependencies
run: dotnet restore

- name: Build project
run: dotnet build --no-restore -c "${{ matrix.configuration }}" -o "build/${{ matrix.configuration }}"

# - name: Test changes
# run: dotnet test --no-build --verbosity normal

- name: Build and Package Project
run: dotnet pack --include-source -c "${{ matrix.configuration }}" -o "build/nuget/${{ matrix.configuration }}" -p:Commit="${{ github.sha }}"

- name: Upload a Build Artifact
uses: actions/upload-artifact@v4
with:
# Artifact name
name: ${{ github.event.repository.name }}-build-${{ matrix.configuration }}-${{ github.sha }}

# A file, directory or wildcard pattern that describes what to upload
path: ./build/${{ matrix.configuration }}
retention-days: 90

- name: Upload a Nuget Artifact
uses: actions/upload-artifact@v4
with:
# Artifact name
name: ${{ github.event.repository.name }}-nuget-${{ matrix.configuration }}-${{ github.sha }}

# A file, directory or wildcard pattern that describes what to upload
path: ./build/nuget/${{ matrix.configuration }}
retention-days: 90
86 changes: 86 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net

name: Release

on:
release:
types: ["published"]

env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
DOTNET_SDK_VERSION: 8.0

jobs:
build:
strategy:
matrix:
configuration: [Release]

name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_SDK_VERSION }}

- name: Verify .NET
run: dotnet --info

- name: Restore dependencies
run: dotnet restore

- name: Build project
run: dotnet build -c "${{ matrix.configuration }}"

# - name: Test project
# run: dotnet test --no-build --verbosity normal

package:
strategy:
matrix:
configuration: [Release]

name: Package and Publish
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_SDK_VERSION }}

- name: Verify .NET
run: dotnet --info

- name: Build and Package Project
run: dotnet pack -c "${{ matrix.configuration }}" -o "build/${{ matrix.configuration }}"

- name: Publish Nuget package to nuget.org
run: dotnet nuget push "build/${{ matrix.configuration }}/*" --skip-duplicate -k ${{ secrets.NUGET_ORG_API_KEY }} -s https://api.nuget.org/v3/index.json

- name: Publish Nuget package to Github Packages
run: dotnet nuget push "build/${{ matrix.configuration }}/*" --skip-duplicate -k ${{ secrets.PAT_GITHUB }} -s https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json

- name: Upload a Build Artifact
uses: actions/upload-artifact@v4
with:
# Artifact name
name: ${{ github.event.repository.name }}-release-${{ matrix.configuration }}-${{ github.sha }}

# A file, directory or wildcard pattern that describes what to upload
path: ./build/${{ matrix.configuration }}
retention-days: 90

0 comments on commit 3cb207c

Please sign in to comment.