-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Setup semantic-release to auto release new version
Signed-off-by: Sagilio <Sagilio@outlook.com>
- Loading branch information
Showing
7 changed files
with
249 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Always validate the PR title AND all the commits | ||
titleAndCommits: true | ||
# Require at least one commit to be valid | ||
# this is only relevant when using commitsOnly: true or titleAndCommits: true, | ||
# which validate all commits by default | ||
anyCommit: true | ||
# Allow use of Merge commits (eg on github: "Merge branch 'master' into feature/ride-unicorns") | ||
# this is only relevant when using commitsOnly: true (or titleAndCommits: true) | ||
allowMergeCommits: false | ||
# Allow use of Revert commits (eg on github: "Revert "feat: ride unicorns"") | ||
# this is only relevant when using commitsOnly: true (or titleAndCommits: true) | ||
allowRevertCommits: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,215 @@ | ||
name: Build and Release | ||
|
||
on: [push, pull_request] | ||
|
||
env: | ||
SHA: ${{ GITHUB.SHA }} | ||
REF: ${{ GITHUB.REF }} | ||
RUN_ID: ${{ GITHUB.RUN_ID }} | ||
RUN_NUMBER: ${{ GITHUB.RUN_NUMBER }} | ||
BUILD_RUN_NUMBER: build.${{ GITHUB.RUN_NUMBER }} | ||
GITHUB_TOKEN: ${{ SECRETS.GITHUB_TOKEN }} | ||
MYGET_API_TOKEN: ${{ SECRETS.MYGET_API_TOKEN }} | ||
NUGET_API_TOKEN: ${{ SECRETS.NUGET_API_KEY }} | ||
COVERALLS_REPO_TOKEN: ${{ SECRETS.COVERALLS_REPO_TOKEN }} | ||
|
||
jobs: | ||
build: | ||
runs-on: windows-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup .NET Core 3.1.x SDK | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: 3.1.x | ||
|
||
- name: Setup .NET 5.0.x SDK | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: 5.0.x | ||
|
||
- name: Check .NET info | ||
run: dotnet --info | ||
|
||
- name: Install dependencies | ||
run: nuget restore | ||
|
||
- name: Build solution | ||
run: dotnet build -c Release --no-restore | ||
|
||
- name: Test solution | ||
run: dotnet test -c Release --no-build --no-restore --verbosity normal -r test-results --collect:"XPlat Code Coverage" ` | ||
-- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=json,cobertura,lcov,teamcity,opencover | ||
|
||
- name: Upload coverage | ||
if: github.repository_owner == 'casbin' && github.event_name == 'push' | ||
run: | | ||
dotnet tool install coveralls.net --version 2.0.0-beta0002 --tool-path tools; | ||
$CommitAuthor = git show -s --pretty=format:"%cn"; | ||
echo "Coomit author is: $CommitAuthor"; | ||
$CommitAuthorEmail = git show -s --pretty=format:"%ce"; | ||
echo "Coomit author email is: $CommitAuthorEmail"; | ||
$CommitMessage = git show -s --pretty=format:"%s"; | ||
echo "Coomit message is: $CommitMessage"; | ||
cp test-results/**/*.opencover.xml test-results | ||
tools/csmacnz.Coveralls --opencover -i test-results/coverage.opencover.xml --repoToken $env:COVERALLS_REPO_TOKEN ` | ||
--commitId $env:SHA --commitBranch $env:REF --commitAuthor "$CommitAuthor" ` | ||
--commitEmail "$CommitAuthorEmail" --commitMessage "$CommitMessage" ` | ||
--jobId $env:RUN_NUMBER --serviceName github-actions --useRelativePaths; | ||
if($LastExitCode -ne 0) | ||
{ | ||
Write-Warning -Message "Can not upload coverage, laat exit code is ${LastExitCode}." | ||
$LastExitCode = 0; | ||
} | ||
- name: Upload test results artefacts | ||
uses: actions/upload-artifact@v1.0.0 | ||
with: | ||
name: "drop-ci-test-results" | ||
path: './test-results' | ||
|
||
run-semantic-release: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
if: github.repository_owner == 'casbin-net' && github.event_name == 'push' | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Dry-run semantic-release | ||
run: | | ||
export PATH=$PATH:$(yarn global bin) | ||
yarn global add semantic-release@17.2.4 | ||
semantic-release -d | ||
release-build-version: | ||
runs-on: windows-latest | ||
needs: run-semantic-release | ||
if: github.repository_owner == 'casbin-net' && 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 Core 3.1.x SDK | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: 3.1.x | ||
|
||
- name: Setup .NET 5.0.x SDK | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: 5.0.x | ||
|
||
- name: Check .NET info | ||
run: dotnet --info | ||
|
||
- name: Install dependencies | ||
run: nuget 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"; | ||
$NowBranchName = git rev-parse --abbrev-ref HEAD; | ||
echo "Now branch name: $NowBranchName"; | ||
$PackageVersion = ($LastTag).TrimStart('v') + "-" + $env:BUILD_RUN_NUMBER + "." + $NowBranchName + "." + $env:SHA.SubString(0, 7); | ||
echo "Publishing package version: ${PackageVersion}"; | ||
dotnet pack -c Release -o packages /p:PackageVersion=$PackageVersion /p:Version=$Version --no-build; | ||
- name: Upload packages artefacts | ||
uses: actions/upload-artifact@v1.0.0 | ||
with: | ||
name: "drop-ci-build-packages" | ||
path: './packages' | ||
|
||
- name: Add myget nuget source | ||
run: dotnet nuget add source https://www.myget.org/F/casbin-net/api/v2/package --name myget.org | ||
|
||
- name: Push develop packages to myget.org | ||
run: dotnet nuget push .\packages\*.nupkg -s myget.org -k $env:MYGET_API_TOKEN --skip-duplicate | ||
|
||
release: | ||
runs-on: windows-latest | ||
needs: release-build-version | ||
if: github.repository_owner == 'casbin-net' && github.event_name == 'push' && github.ref == 'refs/heads/master' | ||
|
||
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 Core 3.1.x SDK | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: 3.1.x | ||
|
||
- name: Setup .NET 5.0.x SDK | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: 5.0.x | ||
|
||
- name: Check .NET info | ||
run: dotnet --info | ||
|
||
- name: Install dependencies | ||
run: nuget 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 --no-build; | ||
- name: Upload packages artefacts | ||
uses: actions/upload-artifact@v1.0.0 | ||
with: | ||
name: "drop-ci-packages" | ||
path: './packages' | ||
|
||
- name: Add myget nuget source | ||
run: dotnet nuget add source https://www.myget.org/F/casbin-net/api/v2/package --name myget.org | ||
|
||
- name: Push packages to myget.org | ||
run: dotnet nuget push .\packages\*.nupkg -s myget.org -k $env:MYGET_API_TOKEN --skip-duplicate | ||
|
||
- name: Add github nuget source | ||
run: dotnet nuget add source https://nuget.pkg.github.com/casbin-net/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 |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"debug": true, | ||
"branches": [ | ||
"+([0-9])?(.{+([0-9]),x}).x", | ||
"master", | ||
{ | ||
"name": "alpha", | ||
"prerelease": true | ||
} | ||
], | ||
"plugins": [ | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator", | ||
"@semantic-release/github" | ||
] | ||
} |
Oops, something went wrong.