Skip to content

Commit

Permalink
feat: support automatic semantic-release (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
dacongda authored Feb 17, 2024
1 parent 38bfa86 commit 4879705
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 3 deletions.
69 changes: 68 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ jobs:
run-semantic-release:
runs-on: ubuntu-latest
needs: build
if: github.repository_owner == 'casbin' && github.event_name == 'push'

steps:
- name: Checkout
Expand All @@ -90,5 +91,71 @@ jobs:
- name: Run semantic-release
run: |
export PATH=$PATH:$(yarn global bin)
yarn global add semantic-release@17.4.3
yarn global add semantic-release@19.0.2
semantic-release
push-packages:
runs-on: windows-latest
needs: run-semantic-release
if: github.repository_owner == 'casdoor' && github.event_name == 'push'

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Git fetch tags
run: git fetch --tags

- name: Check tags
run: git tag -l -n

- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
8.0.x
include-prerelease: true

- name: Check .NET info
run: dotnet --info

- name: Install dependencies
run: dotnet restore

- name: Build solution
run: dotnet build -c Release --no-restore

- name: Pack packages
run: |
$LastTag = git describe --tags (git rev-list --tags --max-count=1);
echo "Last tag is: $LastTag";
$Version = ($LastTag).TrimStart('v');
echo "Publishing version: $Version";
dotnet pack -c Release -o packages /p:PackageVersion=$Version /p:Version=$Version;
if($LastExitCode -ne 0)
{
Write-Warning -Message "Pack packages warming, last exit code is ${LastExitCode}."
$LastExitCode = 0;
}
- name: Upload packages artefacts
uses: actions/[email protected]
with:
name: "drop-ci-packages"
path: './packages'

- name: Add github nuget source
run: dotnet nuget add source https://nuget.pkg.github.com/casbin/index.json --name github.com --username casbin --password $env:GITHUB_TOKEN

- name: Push packages to github.com
run: dotnet nuget push .\packages\*.nupkg -s github.com --skip-duplicate;

- name: Push packages to nuget.org
run: dotnet nuget push .\packages\*.nupkg -s nuget.org -k $env:NUGET_API_TOKEN --skip-duplicate
2 changes: 1 addition & 1 deletion Casbin.UnitTests/Casbin.UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net7.0;net6.0;net5.0;netcoreapp3.1;net461;net452</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;net5.0;netcoreapp3.1;net461;</TargetFrameworks>
<DebugType>full</DebugType>
<IsPackable>false</IsPackable>
<LangVersion>10.0</LangVersion>
Expand Down
2 changes: 1 addition & 1 deletion Casbin/Casbin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net7.0;net6.0;net5.0;netcoreapp3.1;netstandard2.1;netstandard2.0;net462;net461;net452;</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;net5.0;netcoreapp3.1;net462;net461;</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591;CS0618</NoWarn>
<LangVersion>11</LangVersion>
</PropertyGroup>
Expand Down

0 comments on commit 4879705

Please sign in to comment.