Skip to content

Upgrade CI/CD

Upgrade CI/CD #3

Workflow file for this run

name: Release
on:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
- name: Setup .NET
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 #v5.2.0
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore src/MinimalCli.sln
- name: Build Minimal Command Line
run: dotnet build src/MinimalCli.sln -c Release --no-restore
- name: Run tests
run: dotnet test src/MinimalCli.sln -c Release --no-build
- name: Set package version from tag
shell: bash
run: |
VERSION="${{ github.event.release.tag_name }}"
VERSION="${VERSION#v}"
echo "Using release tag: $VERSION"
echo "PACKAGE_VERSION=$VERSION" >> "$GITHUB_ENV"
- name: Pack NuGet packages
shell: bash
run: |
mkdir -p packages
dotnet pack src/MinimalCli.sln -c Release --no-build -p:PackageVersion=${PACKAGE_VERSION} -o ./packages
- name: Publish artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a #v7.0.1
with:
name: Nugets
path: packages/*.nupkg
deploy:
needs: build
runs-on: ubuntu-22.04
environment:
name: ${{ contains(github.event.release.tag_name, '-') && 'Integration' || 'Production' }}
permissions:
id-token: write
contents: read
steps:
- name: Download nugets
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c #v8.0.1
with:
name: Nugets
path: ./packages
- name: nuget-logon
uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 #v1.2.0
id: login
with:
user: dotnetKyle
- name: Push NuGet packages
run: dotnet nuget push ./packages/*.nupkg --api-key ${{steps.login.outputs.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json --skip-duplicate