From 2b2c832538c15b791c5baf4a484b4d2565195918 Mon Sep 17 00:00:00 2001 From: chopin-fan Date: Fri, 3 Jan 2025 13:58:04 +0800 Subject: [PATCH] Add myget config --- .github/workflows/myget-publish.yml | 59 +++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/myget-publish.yml diff --git a/.github/workflows/myget-publish.yml b/.github/workflows/myget-publish.yml new file mode 100644 index 0000000..77454e4 --- /dev/null +++ b/.github/workflows/myget-publish.yml @@ -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 \ No newline at end of file