استفاده از GitHub Actions برای Build و توزیع خودکار پروژههای NET Core.
نویسنده: وحید نصیری
تاریخ: ۱۳۹۸/۰۶/۲۰ ۱۶:۵
آدرس: www.dntips.ir
| مطالب | ۳۶۹۴ |
| نویسندگان | ۲۷۶ |
| گروههای مطالب | ۱۰۲۴ |
| نقشههای راه | ۱۱۹ |
| دورهها | ۱۴ |
| اشتراکها | ۱۷۹۱۴ |
name: .NET Core Build
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.0.100-preview9-014004
- name: Build DNTCaptcha.Core lib
run: dotnet build ./src/DNTCaptcha.Core/DNTCaptcha.Core.csproj --configuration Release
https://github.com/<OWNER>/<REPOSITORY>/workflows/<WORKFLOW_NAME>/badge.svg

name: .NET Core Build
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.0.100-preview9-014004
- name: Build DNTCaptcha.Core lib
run: dotnet build ./src/DNTCaptcha.Core/DNTCaptcha.Core.csproj --configuration Release
- name: Build NuGet Package
run: dotnet pack ./src/DNTCaptcha.Core/DNTCaptcha.Core.csproj --configuration Release
- name: Deploy NuGet Package
run: dotnet nuget push ./src/DNTCaptcha.Core/bin/Release/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json <p align="left">
<a href="https://github.com/actions/setup-java">
<img alt="GitHub Actions status" src="https://github.com/actions/setup-java/workflows/Main%20workflow/badge.svg">
</a>
</p> name: ASP.NET Core CI
on: [push]
jobs:
build_and_test:
runs-on: $
strategy:
matrix:
os: [macOS-latest, ubuntu-latest, windows-latest]
steps:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1.2.0
with:
dotnet-version: 3.0.100
if: matrix.os == 'macOS-latest' || matrix.os == 'ubuntu-latest'
- uses: actions/checkout@v1
- name: Build with dotnet
run: dotnet build ./src/Solution.sln --configuration Release
- name: Test with dotnet
run: dotnet test ./src/Solution.sln --configuration Release name: .NET Core
on:
push:
paths-ignore:
- 'readme.md'
pull_request:
paths-ignore:
- 'readme.md'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.101
- name: Build (Release)
run: dotnet build --configuration Release
- name: Test (Release)
run: dotnet test --configuration Release
- name: Pack (Release)
run: dotnet pack src --configuration Release
- name: Publish (Nuget)
if: github.event_name == 'push'
run: |
if ( "${{github.ref}}" -match "^refs/tags/[0-9]+\.[0-9]+\.[0-9]+$" ) {
dotnet nuget push src\bin\Release\*.nupkg -s nuget.org -k ${{secrets.NUGET_TOKEN}}
} else {
echo "Publish is only enabled by tagging with a release tag."
} refusing to allow an OAuth App to create or update workflow `.github/workflows/dotnetcore.yml` without `workflow` scope
name: Build
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
- name: Build (Release)
run: dotnet build src --configuration Release
- name: Pack (Release)
run: dotnet pack src --configuration Release
- name: Upload Artifact
uses: actions/upload-artifact@v1.0.0
with:
name: Release_Artifacts
path: src\bin\Release
name: Build
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup .NET Core 2.1
uses: actions/setup-dotnet@v1
with:
dotnet-version: 2.1.607
- name: Setup .NET Core 3.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.0.101
- name: .NET Core SxS
run: |
rsync -a ${DOTNET_ROOT/3.0.101/2.1.607}/* $DOTNET_ROOT/
- name: Build (Release - netcoreapp2.1)
run: dotnet build --configuration Release --framework netcoreapp2.1
- name: Build (Release - netcoreapp3.0)
run: dotnet build --configuration Release --framework netcoreapp3.0 steps:
- name: Dump GitHub Context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT" GITHUB_CONTEXT: {
"token": "***",
"ref": "refs/heads/master",
"sha": "3251394ad66ae8419e606fbf78570906ff2f01d3",
"repository": "mjebrahimi/github_actions_test",
"repositoryUrl": "git://github.com/mjebrahimi/github_actions_test.git",
"run_id": "66966756",
"run_number": "17",
"actor": "mjebrahimi",
"workflow": ".NET Core",
"head_ref": "",
"base_ref": "",
"event_name": "push",
"event": {
"after": "3251394ad66ae8419e606fbf78570906ff2f01d3",
"base_ref": null,
"before": "b6c382e8fe74916daf6821a5a71efe480bd98a13",
"commits": [
{
"author": {
"email": "mj.ebrahimi72@gmail.com",
"name": "Mohammad Javad Ebrahimi",
"username": "mjebrahimi"
},
"committer": {
"email": "noreply@github.com",
"name": "GitHub",
"username": "web-flow"
},
"distinct": true,
"id": "3251394ad66ae8419e606fbf78570906ff2f01d3",
"message": "Update dotnetcore.yml",
"timestamp": "2020-03-31T04:48:53+04:30",
"tree_id": "e27a05129010b3b2a7b18b92d91cd73a32babb8f",
"url": "https://github.com/mjebrahimi/github_actions_test/commit/3251394ad66ae8419e606fbf78570906ff2f01d3"
}
],
"compare": "https://github.com/mjebrahimi/github_actions_test/compare/b6c382e8fe74...3251394ad66a",
"created": false,
"deleted": false,
"forced": false,
"head_commit": {
"author": {
"email": "mj.ebrahimi72@gmail.com",
"name": "Mohammad Javad Ebrahimi",
"username": "mjebrahimi"
},
"committer": {
"email": "noreply@github.com",
"name": "GitHub",
"username": "web-flow"
},
"distinct": true,
"id": "3251394ad66ae8419e606fbf78570906ff2f01d3",
"message": "Update dotnetcore.yml",
"timestamp": "2020-03-31T04:48:53+04:30",
"tree_id": "e27a05129010b3b2a7b18b92d91cd73a32babb8f",
"url": "https://github.com/mjebrahimi/github_actions_test/commit/3251394ad66ae8419e606fbf78570906ff2f01d3"
},
"pusher": {
"email": "mj.ebrahimi72@gmail.com",
"name": "mjebrahimi"
},
"ref": "refs/heads/master",
"repository": {
"archive_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/{archive_format}{/ref}",
"archived": false,
"assignees_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/assignees{/user}",
"blobs_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/git/blobs{/sha}",
"branches_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/branches{/branch}",
"clone_url": "https://github.com/mjebrahimi/github_actions_test.git",
"collaborators_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/collaborators{/collaborator}",
"comments_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/comments{/number}",
"commits_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/commits{/sha}",
"compare_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/compare/{base}...{head}",
"contents_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/contents/{+path}",
"contributors_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/contributors",
"created_at": 1585584602,
"default_branch": "master",
"deployments_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/deployments",
"description": null,
"disabled": false,
"downloads_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/downloads",
"events_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/events",
"fork": false,
"forks": 0,
"forks_count": 0,
"forks_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/forks",
"full_name": "mjebrahimi/github_actions_test",
"git_commits_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/git/commits{/sha}",
"git_refs_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/git/tags{/sha}",
"git_url": "git://github.com/mjebrahimi/github_actions_test.git",
"has_downloads": true,
"has_issues": true,
"has_pages": false,
"has_projects": true,
"has_wiki": true,
"homepage": null,
"hooks_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/hooks",
"html_url": "https://github.com/mjebrahimi/github_actions_test",
"id": 251358686,
"issue_comment_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/issues/comments{/number}",
"issue_events_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/issues/events{/number}",
"issues_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/issues{/number}",
"keys_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/keys{/key_id}",
"labels_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/labels{/name}",
"language": "C#",
"languages_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/languages",
"license": null,
"master_branch": "master",
"merges_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/merges",
"milestones_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/milestones{/number}",
"mirror_url": null,
"name": "github_actions_test",
"node_id": "MDEwOlJlcG9zaXRvcnkyNTEzNTg2ODY=",
"notifications_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/notifications{?since,all,participating}",
"open_issues": 0,
"open_issues_count": 0,
"owner": {
"avatar_url": "https://avatars1.githubusercontent.com/u/23256135?v=4",
"email": "mj.ebrahimi72@gmail.com",
"events_url": "https://api.github.com/users/mjebrahimi/events{/privacy}",
"followers_url": "https://api.github.com/users/mjebrahimi/followers",
"following_url": "https://api.github.com/users/mjebrahimi/following{/other_user}",
"gists_url": "https://api.github.com/users/mjebrahimi/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/mjebrahimi",
"id": 23256135,
"login": "mjebrahimi",
"name": "mjebrahimi",
"node_id": "MDQ6VXNlcjIzMjU2MTM1",
"organizations_url": "https://api.github.com/users/mjebrahimi/orgs",
"received_events_url": "https://api.github.com/users/mjebrahimi/received_events",
"repos_url": "https://api.github.com/users/mjebrahimi/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/mjebrahimi/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/mjebrahimi/subscriptions",
"type": "User",
"url": "https://api.github.com/users/mjebrahimi"
},
"private": false,
"pulls_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/pulls{/number}",
"pushed_at": 1585613933,
"releases_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/releases{/id}",
"size": 40,
"ssh_url": "git@github.com:mjebrahimi/github_actions_test.git",
"stargazers": 0,
"stargazers_count": 0,
"stargazers_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/stargazers",
"statuses_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/statuses/{sha}",
"subscribers_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/subscribers",
"subscription_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/subscription",
"svn_url": "https://github.com/mjebrahimi/github_actions_test",
"tags_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/tags",
"teams_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/teams",
"trees_url": "https://api.github.com/repos/mjebrahimi/github_actions_test/git/trees{/sha}",
"updated_at": "2020-03-31T00:01:15Z",
"url": "https://github.com/mjebrahimi/github_actions_test",
"watchers": 0,
"watchers_count": 0
},
"sender": {
"avatar_url": "https://avatars1.githubusercontent.com/u/23256135?v=4",
"events_url": "https://api.github.com/users/mjebrahimi/events{/privacy}",
"followers_url": "https://api.github.com/users/mjebrahimi/followers",
"following_url": "https://api.github.com/users/mjebrahimi/following{/other_user}",
"gists_url": "https://api.github.com/users/mjebrahimi/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/mjebrahimi",
"id": 23256135,
"login": "mjebrahimi",
"node_id": "MDQ6VXNlcjIzMjU2MTM1",
"organizations_url": "https://api.github.com/users/mjebrahimi/orgs",
"received_events_url": "https://api.github.com/users/mjebrahimi/received_events",
"repos_url": "https://api.github.com/users/mjebrahimi/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/mjebrahimi/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/mjebrahimi/subscriptions",
"type": "User",
"url": "https://api.github.com/users/mjebrahimi"
}
},
"workspace": "/home/runner/work/github_actions_test/github_actions_test",
"action": "run1"
} jobs:
build:
if: contains(toJson(github.event.commits), '[SKIP CI]') == false
runs-on: ubuntu-latest
... jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1.0.0
- name: Setup NuGet
uses: nuget/setup-nuget@v1.0.2
- name: Restore NuGet Packages
run: nuget restore src/WebApplication1.sln
- name: Build (Release)
run: msbuild src/WebApplication1.sln /p:Configuration=Release - name: Setup VSTest
uses: Malcolmnixon/Setup-VSTest@v2
- name: VSTest
run: vstest.console ClassLibrary.Test\bin\Debug\ClassLibrary.Test.dll error: File does not exist (src\bin\Release\*.snupkg).
<PropertyGroup> ... <DebugSymbols>true</DebugSymbols> <IncludeSymbols>true</IncludeSymbols> <SymbolPackageFormat>snupkg</SymbolPackageFormat> </PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<TargetFrameworks>netstandard2.0;net462;</TargetFrameworks>
runs-on: windows-2019