From 44200742af9b6dbfcbfd3331dde1b0d291edc4e8 Mon Sep 17 00:00:00 2001 From: zerodev1200 <42404360+zerodev1200@users.noreply.github.com> Date: Sat, 9 Nov 2024 18:41:06 +0900 Subject: [PATCH] [Fix]github actions --- .github/workflows/release.yml | 98 +++++++++++++++-------------------- R3Utility.sln | 3 +- 2 files changed, 44 insertions(+), 57 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3f4c8f6..5619bc2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,63 +15,51 @@ jobs: outputs: version: ${{ steps.set-version.outputs.version }} steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: ${{ env.DOTNET_VERSION }} - - - name: Verify commit exists in origin/main - run: | - git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* - git branch --remote --contains | grep origin/main - - - name: Set VERSION variable from tag - id: set-version - run: | - $version = $env:GITHUB_REF -replace 'refs/tags/v','' - echo "version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append - echo "VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Append - - - name: Build - run: dotnet build --configuration Release /p:Version=${VERSION} - - - name: Test - run: dotnet test --configuration Release /p:Version=${VERSION} --no-build - - - name: Pack - run: dotnet pack --configuration Release /p:Version=${VERSION} --no-build --output ./publish + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - name: Verify commit exists in origin/main + run: | + git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* + git branch --remote --contains | grep origin/main + + - name: Set VERSION variable from tag + id: set-version + run: | + $version = $env:GITHUB_REF -replace 'refs/tags/v','' + echo "version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append + echo "VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Append + + - name: Build + run: dotnet build --configuration Release -p:Version=${{ env.VERSION }} + + - name: Test + run: dotnet test --configuration Release -p:Version=${{ env.VERSION }} --no-build + + - name: Pack + run: dotnet pack --configuration Release -p:Version=${{ env.VERSION }} --no-build --output ./publish + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: nuget-package + path: ./publish publish: needs: build runs-on: windows-latest steps: - - name: Push to NuGet - run: dotnet nuget push "./publish/*.nupkg" --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${NUGET_API_KEY} - env: - NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} - - create-release: - needs: [build, publish] - runs-on: windows-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Get Full Changelog - id: changelog - run: | - git fetch --prune --unshallow - CHANGELOG=$(git log --oneline --decorate --pretty=format:"- %s by %an" origin/main..HEAD) - echo "changelog=$CHANGELOG" >> $GITHUB_ENV - - - name: Create Release - uses: softprops/action-gh-release@v1 - with: - name: Release ${{ needs.build.outputs.version }} - body: | - ## Full Change Log - ${{ env.changelog }} - token: ${{ secrets.RELEASE_CREATE_GITHUB_KEY }} + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: nuget-package + path: ./publish + + - name: Push to NuGet + run: dotnet nuget push **/*.nupkg --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} + \ No newline at end of file diff --git a/R3Utility.sln b/R3Utility.sln index 3a9dcf4..a051b55 100644 --- a/R3Utility.sln +++ b/R3Utility.sln @@ -7,7 +7,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "R3Utility", "src\R3Utility. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WpfApp1", "sandbox\WpfApp1\WpfApp1.csproj", "{F1DD744B-A892-4D96-ADDB-E5865DD79C11}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "R3Utility.Tests", "Tests\R3Utility.Tests\R3Utility.Tests.csproj", "{1D084A39-4771-4D34-A302-B13BB4DDA8C3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "R3Utility.Tests", "Tests\R3Utility.Tests\R3Utility.Tests.csproj", "{1D084A39-4771-4D34-A302-B13BB4DDA8C3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -22,7 +22,6 @@ Global {F1DD744B-A892-4D96-ADDB-E5865DD79C11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F1DD744B-A892-4D96-ADDB-E5865DD79C11}.Debug|Any CPU.Build.0 = Debug|Any CPU {F1DD744B-A892-4D96-ADDB-E5865DD79C11}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F1DD744B-A892-4D96-ADDB-E5865DD79C11}.Release|Any CPU.Build.0 = Release|Any CPU {1D084A39-4771-4D34-A302-B13BB4DDA8C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1D084A39-4771-4D34-A302-B13BB4DDA8C3}.Debug|Any CPU.Build.0 = Debug|Any CPU {1D084A39-4771-4D34-A302-B13BB4DDA8C3}.Release|Any CPU.ActiveCfg = Release|Any CPU