Skip to content

Commit

Permalink
Add myget config
Browse files Browse the repository at this point in the history
  • Loading branch information
chopin-fan committed Jan 3, 2025
1 parent 5c477ee commit 2b2c832
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/myget-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Publish MyGet Package

on:
push:
tags:
- "v*.*.*"

run-name: Publish MyGet Package from ${{ github.ref }}

env:
DOTNET_INSTALL_DIR: "./.dotnet"

concurrency:
group: workflow-${{ github.ref }}
cancel-in-progress: true

jobs:
publish:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'

- name: Cache NuGet Packages
id: nuget-packages
uses: actions/cache@v4
env:
cache-name: nuget-package-cache
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-${{ env.cache-name }}

- name: Restore dependencies
run: dotnet restore

- name: Get the version from git tags
id: get_version
run: |
TAG=$(git describe --tags --abbrev=0)
VERSION=${TAG#v}
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Build the project
run: dotnet build --configuration Release --no-restore

- name: Pack the MyGet package
run: dotnet pack --configuration Release --no-build --output ./nupkg -p:PackageVersion=${{ env.VERSION }}

- name: Publish the MyGet package
env:
MYGET_URL: ${{ secrets.MYGET_URL }}
MYGET_API_KEY: ${{ secrets.MYGET_API_KEY }}
run: dotnet nuget push ./nupkg/*.nupkg --api-key $MYGET_API_KEY --source $MYGET_URL

0 comments on commit 2b2c832

Please sign in to comment.