Skip to content

Commit 14e8f79

Browse files
authored
workflow align (#1)
* Create dotnet.yml
1 parent b0d3e1e commit 14e8f79

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed

.github/workflows/dotnet.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: .NET Core V2
2+
on:
3+
push:
4+
pull_request:
5+
release:
6+
types:
7+
- published
8+
env:
9+
# Stop wasting time caching packages
10+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
11+
# Disable sending usage data to Microsoft
12+
DOTNET_CLI_TELEMETRY_OPTOUT: true
13+
# Project name to pack and publish
14+
PROJECT_NAME: SharpHelpers
15+
# GitHub Packages Feed settings
16+
GITHUB_FEED: https://nuget.pkg.github.com/shaprcode-it/
17+
GITHUB_USER: iscifoni
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
# Official NuGet Feed settings
20+
NUGET_FEED: https://api.nuget.org/v3/index.json
21+
NUGET_KEY: ${{ secrets.NUGET_TOKEN }}
22+
jobs:
23+
build:
24+
runs-on: ${{ matrix.os }}
25+
strategy:
26+
matrix:
27+
os: [ ubuntu-latest, windows-latest ]
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v2
31+
- run: git fetch --unshallow
32+
- name: Setup .NET Core 3.1
33+
uses: actions/setup-dotnet@v1
34+
with:
35+
dotnet-version: 3.1.100
36+
- name: Install GitVersion
37+
uses: gittools/actions/gitversion/setup@v0.9.7
38+
with:
39+
versionSpec: '5.x'
40+
- name: Use GitVersion
41+
id: gitversion # step id used as reference for output values
42+
uses: gittools/actions/gitversion/execute@v0.9.7
43+
- run: |
44+
echo "NuGetVersionV2: ${{ steps.gitversion.outputs.nuGetVersionV2 }}"
45+
echo "NuGetPreReleaseTagV2: ${{ steps.gitversion.outputs.CommitsSinceVersionSourcePadded }}"
46+
- name: Restore
47+
run: dotnet restore ./SharpApi.sln
48+
- name: Build
49+
run: dotnet build -c Release --no-restore ./SharpApi.sln
50+
- name: Test
51+
run: dotnet test ./SharpApi.sln -c Release --no-build
52+
- name: Pack
53+
if: matrix.os == 'ubuntu-latest'
54+
run: dotnet pack -v normal -c Release --no-restore --no-build -p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersionV2 }}-${{ steps.gitversion.outputs.CommitsSinceVersionSourcePadded }} ./SharpApi.sln
55+
- name: Upload Artifact
56+
if: matrix.os == 'ubuntu-latest'
57+
uses: actions/upload-artifact@v2
58+
with:
59+
name: nupkg
60+
path: ./SharpHelpers/${{ env.PROJECT_NAME }}/bin/Release/*.nupkg
61+
prerelease:
62+
needs: build
63+
if: github.ref == 'refs/heads/develop'
64+
runs-on: ubuntu-latest
65+
steps:
66+
- name: Download Artifact
67+
uses: actions/download-artifact@v1
68+
with:
69+
name: nupkg
70+
- name: Push to GitHub Feed
71+
run: |
72+
for f in ./nupkg/*.nupkg
73+
do
74+
echo $f
75+
curl --silent --show-error --fail -vX PUT -u "$GITHUB_USER:$GITHUB_TOKEN" -F package=@$f $GITHUB_FEED
76+
done
77+
deploy:
78+
needs: build
79+
if: github.event_name == 'release' && startsWith(github.ref, 'refs/heads/v')
80+
runs-on: ubuntu-latest
81+
steps:
82+
- uses: actions/checkout@v2
83+
- name: Setup .NET Core
84+
uses: actions/setup-dotnet@v1
85+
with:
86+
dotnet-version: 5.0.100
87+
- name: Create Release NuGet package
88+
run: |
89+
arrTag=(${GITHUB_REF//\// })
90+
VERSION="${arrTag[2]}"
91+
echo Version: $VERSION
92+
VERSION="${VERSION//v}"
93+
echo Clean Version: $VERSION
94+
dotnet pack -v normal -c Release --include-symbols --include-source -p:PackageVersion=$VERSION -o nupkg src/$PROJECT_NAME/$PROJECT_NAME.*proj
95+
- name: Push to GitHub Feed
96+
run: |
97+
for f in ./nupkg/*.nupkg
98+
do
99+
curl -vX PUT -u "$GITHUB_USER:$GITHUB_TOKEN" -F package=@$f $GITHUB_FEED
100+
done
101+
- name: Push to NuGet Feed
102+
run: dotnet nuget push ./nupkg/*.nupkg --source $NUGET_FEED --skip-duplicate --api-key $NUGET_KEY

version.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
{
3+
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
4+
"version": "1.0-beta",
5+
"publicReleaseRefSpec": [
6+
"^refs/heads/master$",
7+
"^refs/heads/v\\d+(?:\\.\\d+)?$"
8+
],
9+
"cloudBuild": {
10+
"buildNumber": {
11+
"enabled": false
12+
}
13+
}
14+
}

0 commit comments

Comments
 (0)