Skip to content

Commit

Permalink
Add the CI pipeline (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
f1x3d authored Oct 21, 2023
1 parent 70427ae commit 17c9bf2
Showing 1 changed file with 97 additions and 0 deletions.
97 changes: 97 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: CI

on:
push:
branches: [ 'main' ]
pull_request:
branches: [ '*' ]
release:
types: [ 'released' ]

env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
DOTNET_VERSION: 6.x
DOTNET_QUALITY: ga

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
dotnet-quality: ${{ env.DOTNET_QUALITY }}

- name: Restore dependencies
run: dotnet restore *.sln

- name: Build project
run: dotnet build *.sln --no-restore -c Release

- name: Pack
run: dotnet pack *.sln --no-build -c Release

- name: Publish build artifacts
uses: actions/upload-artifact@v3
with:
name: build
path: ${{ github.workspace }}
if-no-files-found: error

# test:
# name: Test
# needs: [ build ]
# runs-on: ubuntu-latest
# steps:
# - name: Download build artifacts
# uses: actions/download-artifact@v3
# with:
# name: build
# path: ${{ github.workspace }}

# - name: Run tests
# run: dotnet test *.sln --no-build -c Release

publish:
name: Publish
if: github.event_name == 'release'
# needs: [ test ]
needs: [ build ]
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build
path: ${{ github.workspace }}

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
dotnet-quality: ${{ env.DOTNET_QUALITY }}

- name: Publish to NuGet.org
run: dotnet nuget push **/*.nupkg -k $NUGET_API_KEY -s https://api.nuget.org/v3/index.json --skip-duplicate
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}

- name: Add the GitHub Packages source
run: dotnet nuget add source --username $GITHUB_USERNAME --password $GITHUB_TOKEN --store-password-in-clear-text --name github "$FEED_SOURCE"
env:
GITHUB_USERNAME: ${{ github.repository_owner }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FEED_SOURCE: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json

- name: Publish to GitHub Packages
run: dotnet nuget push **/*.nupkg -k $GITHUB_TOKEN -s "github" --skip-duplicate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 17c9bf2

Please # to comment.