Skip to content

Commit 13f451d

Browse files
Add files via upload
1 parent 1e5d90d commit 13f451d

File tree

4 files changed

+195
-0
lines changed

4 files changed

+195
-0
lines changed

.github/workflows/build-and-test.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# This workflow will build a .NET project
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
3+
4+
name: build-and-test (reusable workflow)
5+
6+
on:
7+
workflow_call:
8+
inputs:
9+
dotnet-version:
10+
description: "required dotnet version. The default is '8.0.x'."
11+
required: true
12+
type: string
13+
default: '8.0.x'
14+
dotnet-framework:
15+
description: "target framework for dotnet test. The default is 'net8.0'."
16+
required: true
17+
type: string
18+
default: 'net8.0'
19+
configuration:
20+
description: "The configuration to use for building the package. The default is 'Release'."
21+
required: true
22+
type: string
23+
default: 'Release'
24+
25+
jobs:
26+
build-and-test:
27+
runs-on: ubuntu-latest
28+
env:
29+
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
30+
steps:
31+
- run: echo "The inputs.dotnet version is ${{ inputs.dotnet-version }}, framework is ${{ inputs.dotnet-framework }}."
32+
- run: echo "The inputs.configuration is ${{ inputs.configuration }}."
33+
- run: echo "The job was automatically triggered by a ${{ github.event_name }} event."
34+
- run: echo "This job is now running on a ${{ runner.os }} server hosted by GitHub!"
35+
- run: echo "The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
36+
37+
- name: Check out repository code
38+
uses: actions/checkout@v4
39+
- run: echo "The ${{ github.repository }} repository has been cloned to the runner."
40+
- run: echo "The workflow is now ready to test your code on the runner."
41+
- name: List files in the repository
42+
run: |
43+
ls -la ${{ github.workspace }}
44+
45+
- name: Setup dotnet
46+
uses: actions/setup-dotnet@v4
47+
with:
48+
dotnet-version: ${{ inputs.dotnet-version }}
49+
global-json-file: global.json
50+
cache: false
51+
- name: Display dotnet version
52+
run: dotnet --version
53+
54+
- name: Install dependencies
55+
run: dotnet restore
56+
- name: Build
57+
run: dotnet build --no-restore --configuration ${{ inputs.configuration }}
58+
59+
- name: Test with the dotnet CLI
60+
run: dotnet test --no-build --framework ${{ inputs.dotnet-framework }} --configuration ${{ inputs.configuration }} --verbosity normal --logger trx --results-directory "TestResults-${{ inputs.configuration }}-${{ inputs.dotnet-framework }}"
61+
- name: Upload dotnet test results
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: dontet-results-${{ inputs.configuration }}-${{ inputs.dotnet-framework }}
65+
path: TestResults-${{ inputs.configuration }}-${{ inputs.dotnet-framework }}
66+
if: ${{ always() }}
67+
68+
- run: echo "This job's status is ${{ job.status }}."
69+
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# This workflow will build a .NET project
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
3+
4+
name: pack-and-publish (reusable workflow)
5+
6+
on:
7+
workflow_call:
8+
secrets:
9+
NUGET_TOKEN:
10+
description: 'A nuget token to publish to nuget.org'
11+
required: true
12+
13+
jobs:
14+
pack-and-publish:
15+
runs-on: ubuntu-latest
16+
env:
17+
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
18+
CONFIGURATION: 'Release'
19+
steps:
20+
- run: echo "The job was automatically triggered by a ${{ github.event_name }} event."
21+
- run: echo "This job is now running on a ${{ runner.os }} server hosted by GitHub!"
22+
- run: echo "The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
23+
24+
- name: Check out repository code
25+
uses: actions/checkout@v4
26+
- run: echo "The ${{ github.repository }} repository has been cloned to the runner."
27+
- run: echo "The workflow is now ready to pack your code on the runner."
28+
- name: List files in the repository
29+
run: |
30+
ls -la ${{ github.workspace }}
31+
32+
- name: Setup dotnet
33+
uses: actions/setup-dotnet@v4
34+
with:
35+
global-json-file: global.json
36+
cache: false
37+
- name: Display dotnet version
38+
run: dotnet --version
39+
40+
- name: Install dependencies
41+
run: dotnet restore
42+
- name: Build
43+
run: dotnet build --no-restore --configuration ${{ env.CONFIGURATION }}
44+
45+
- name: Create the NuGet package (.nupkg)
46+
run: dotnet pack --configuration Release
47+
- name: Publish the NuGet package to nuget.org
48+
run: dotnet nuget push "**/bin/Release/*.nupkg" -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json --skip-duplicate
49+
env:
50+
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }}
51+
# You should create this repository secret on https://github.com/myvas/AspNetCore.Email/settings/secrets/actions
52+
53+
- run: echo "This job's status is ${{ job.status }}."
54+

.github/workflows/publish.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# This workflow will publish NuGet packages to nuget.org
2+
# For more information see: https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/about-packaging-with-github-actions
3+
4+
name: publish
5+
6+
on:
7+
workflow_dispatch:
8+
release:
9+
types: [ published ]
10+
11+
jobs:
12+
build-and-test:
13+
strategy:
14+
matrix:
15+
dotnet:
16+
- version: '6.0.x'
17+
framework: 'net6.0'
18+
- version: '7.0.x'
19+
framework: 'net7.0'
20+
- version: '8.0.x'
21+
framework: 'net8.0'
22+
- version: '9.0.x'
23+
framework: 'net9.0'
24+
configuration: [ 'Release' ]
25+
uses: ./.github/workflows/build-and-test.yml
26+
with:
27+
dotnet-version: ${{ matrix.dotnet.version }}
28+
dotnet-framework: ${{ matrix.dotnet.framework }}
29+
configuration: ${{ matrix.configuration }}
30+
31+
pack-and-publish:
32+
needs: [ 'build-and-test' ]
33+
uses: ./.github/workflows/pack-and-publish.yml
34+
secrets:
35+
NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}

.github/workflows/test.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This workflow will build a .NET project
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
3+
4+
name: test
5+
on:
6+
workflow_dispatch:
7+
push:
8+
branches: [ master ]
9+
paths-ignore:
10+
- "*.md"
11+
- ".github/**"
12+
pull_request:
13+
branches: [ master ]
14+
paths-ignore:
15+
- "*.md"
16+
- ".github/**"
17+
18+
jobs:
19+
build-and-test:
20+
strategy:
21+
matrix:
22+
dotnet:
23+
- version: '6.0.x'
24+
framework: 'net6.0'
25+
- version: '7.0.x'
26+
framework: 'net7.0'
27+
- version: '8.0.x'
28+
framework: 'net8.0'
29+
- version: '9.0.x'
30+
framework: 'net9.0'
31+
configuration: [ 'Debug', 'Release' ]
32+
uses: ./.github/workflows/build-and-test.yml
33+
with:
34+
dotnet-version: ${{ matrix.dotnet.version }}
35+
dotnet-framework: ${{ matrix.dotnet.framework }}
36+
configuration: ${{ matrix.configuration }}
37+

0 commit comments

Comments
 (0)