From 58cbb92e99f1b939514217fdfc93b138029ca348 Mon Sep 17 00:00:00 2001 From: YaKun9 <131952790+YaKun9@users.noreply.github.com> Date: Wed, 12 Jun 2024 15:57:21 +0800 Subject: [PATCH] Update push to nuget.yml --- .gitea/workflows/push to nuget.yml | 58 +++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/.gitea/workflows/push to nuget.yml b/.gitea/workflows/push to nuget.yml index 6792265..cc7f5dd 100644 --- a/.gitea/workflows/push to nuget.yml +++ b/.gitea/workflows/push to nuget.yml @@ -1,19 +1,61 @@ -name: Simple Workflow +name: Build and Publish to NuGet on: push: - branches: - - master + tags: + - 'v*.*.*' jobs: build: - runs-on: one-runner + runs-on: ubuntu-latest steps: - - name: Set up Node.js - uses: actions/setup-node@v2 + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up .NET + uses: actions/setup-dotnet@v2 with: - node-version: '14' + dotnet-version: '5.0.x' + + - name: Get version from tag + id: get_version + run: echo "##[set-output name=VERSION;]${GITHUB_REF#refs/tags/v}" + + - name: Restore dependencies + run: dotnet restore SageTools/SageTools.csproj + - name: Build project + run: dotnet build SageTools/SageTools.csproj --configuration Release --no-restore /p:Version=${{ steps.get_version.outputs.VERSION }} + + - name: Run tests + run: dotnet test SageTools/SageTools.csproj --no-build --verbosity normal + + publish: + needs: build + runs-on: ubuntu-latest + + steps: - name: Checkout code - uses: actions/checkout@v2 \ No newline at end of file + uses: actions/checkout@v2 + + - name: Set up .NET + uses: actions/setup-dotnet@v2 + with: + dotnet-version: '5.0.x' + + - name: Get version from tag + id: get_version + run: echo "##[set-output name=VERSION;]${GITHUB_REF#refs/tags/v}" + + - name: Restore dependencies + run: dotnet restore SageTools/SageTools.csproj + + - name: Build project + run: dotnet build SageTools/SageTools.csproj --configuration Release --no-restore /p:Version=${{ steps.get_version.outputs.VERSION }} + + - name: Pack project + run: dotnet pack SageTools/SageTools.csproj --configuration Release --no-build --output ./output /p:Version=${{ steps.get_version.outputs.VERSION }} + + - name: Publish to NuGet + run: dotnet nuget push ./output/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json