Skip to content

publish

publish #43

Workflow file for this run

# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: publish
on:
workflow_dispatch:
push:
branches:
- 'main'
release:
types:
- published
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
NuGetDirectory: ${{ github.workspace}}/nuget
defaults:
run:
shell: bash
jobs:
create_nuget:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v5
- run: dotnet pack --configuration Release --output ${{ env.NuGetDirectory }}
working-directory: ./Optify
- uses: actions/upload-artifact@v7
with:
name: nuget
if-no-files-found: error
retention-days: 7
path: ${{ env.NuGetDirectory }}/*.nupkg
deploy:
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
needs: [ create_nuget ]
steps:
- uses: actions/download-artifact@v8
with:
name: nuget
path: ${{ env.NuGetDirectory }}
- name: Setup .NET Core
uses: actions/setup-dotnet@v5
- name: Publish NuGet package
run: |
for file in "${{ env.NuGetDirectory }}"/*.nupkg; do
dotnet nuget push "$file" --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
done