Skip to content

Commit

Permalink
[Fix]github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
zerodev1200 committed Nov 9, 2024
1 parent a86a476 commit 4420074
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 57 deletions.
98 changes: 43 additions & 55 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

3 changes: 1 addition & 2 deletions R3Utility.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 4420074

Please sign in to comment.