Skip to content

Change CI (#2)

Change CI (#2) #2

name: Automated build and release
on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
permissions:
contents: write
# discussions: write # Uncomment this line if you want to create discussions
# see https://github.com/softprops/action-gh-release/tree/v2.0.4?tab=readme-ov-file#-customizing
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 👨‍💻 Check-out code
uses: actions/checkout@v4
- name: 👨‍🔧 Setup .NET Core SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: 🔍 Enable problem matchers
run: echo "::add-matcher::.github/matchers/dotnet.json"
- name: 🦸‍♂️ Restore steriods # this is the caching step, remove if you don't think you need it
uses: actions/cache@v4
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{ hashFiles('src/**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget
- name: 🎒 Load packages
run: dotnet restore ./src/Svrooij.PowerShell.DependencyInjection/Svrooij.PowerShell.DependencyInjection.csproj
- name: 🛠️ Build code
shell: pwsh
run: dotnet build ./src/Svrooij.PowerShell.DependencyInjection/Svrooij.PowerShell.DependencyInjection.csproj --configuration Release --no-restore -p:Version=$("${{ github.ref_name }}".Substring(1))
- name: 📦 Package library
shell: pwsh
run: dotnet pack ./src/Svrooij.PowerShell.DependencyInjection/Svrooij.PowerShell.DependencyInjection.csproj --configuration Release --no-build -p:Version=$("${{ github.ref_name }}".Substring(1))
- name: ✈️ Publish package
shell: pwsh
run: dotnet nuget push ./src/Svrooij.PowerShell.DependencyInjection/bin/Release/*.nupkg --api-key $NUGET_API_KEY --source https://api.nuget.org/v3/index.json
env:
NUGET_API_KEY: ${{ secrets.NUGET_TOKEN }}
- name: ✅ Create release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
./src/Svrooij.PowerShell.DependencyInjection/bin/Release/*.nupkg
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
body: |
## Release ${{ github.ref_name }}
This is the release for ${{ github.ref_name }}.
generate_release_notes: true
append_body: true