Skip to content

Commit

Permalink
Introduce CI GitHub Action
Browse files Browse the repository at this point in the history
  • Loading branch information
jerone committed Aug 17, 2024
1 parent 98e6bb4 commit 5e8dc8e
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: .NET Build, Test, and Publish Nuget Package

on:
push:
branches:
- "**"
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
pull_request:
branches:
- "**"
env:
VERSION: 0.0.1

defaults:
run:
working-directory: "Jvw.DevToys.SemverCalculator"

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set Version Variable
if: ${{ github.ref_type == 'tag' }}
env:
TAG: ${{ github.ref_name }}
run: echo "VERSION=${TAG#v}" >> $GITHUB_ENV

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8"

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore /p:Version=$VERSION

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

- name: pack nuget packages
run: dotnet pack --output nupkgs --no-restore --no-build /p:PackageVersion=$VERSION

- name: upload nuget package
if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v')
run: dotnet nuget push nupkgs/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json

0 comments on commit 5e8dc8e

Please sign in to comment.