Skip to content

Commit 00da3f5

Browse files
authored
Use YoloDev.Sdk (#63)
1 parent 1b2acba commit 00da3f5

File tree

13 files changed

+246
-193
lines changed

13 files changed

+246
-193
lines changed

.github/workflows/ci.yml

Lines changed: 47 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -5,66 +5,8 @@ on:
55
- pull_request
66

77
jobs:
8-
build:
9-
name: Build
10-
runs-on: ubuntu-latest
11-
12-
env:
13-
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: "true"
14-
DOTNET_CLI_TELEMETRY_OPTOUT: "1"
15-
16-
steps:
17-
- name: Setup dotnet 2.1
18-
uses: actions/setup-dotnet@v1
19-
with:
20-
dotnet-version: "2.1.805"
21-
22-
- name: Setup dotnet 5.0
23-
uses: actions/setup-dotnet@v1
24-
with:
25-
dotnet-version: "5.0.101"
26-
27-
- name: Setup side by side .NET SDKs on *nix
28-
run: |
29-
rsync -a ${DOTNET_ROOT/${{ matrix.dotnet }}/2.1.805}/* $DOTNET_ROOT/
30-
31-
- name: Print dotnet info
32-
run: dotnet --info
33-
34-
- uses: actions/checkout@master
35-
36-
- name: Fetch all history for all tags and branches
37-
run: git fetch --prune --unshallow
38-
39-
- name: Restore
40-
run: dotnet msbuild build/build.proj -target:Restore
41-
42-
- name: Build
43-
run: dotnet msbuild build/build.proj -target:Build -p:NoRestore=true
44-
45-
- name: Test
46-
run: dotnet msbuild build/build.proj -target:Test -p:NoRestore=true -p:VSTestNoBuild=true
47-
48-
- name: Pack
49-
run: dotnet msbuild build/build.proj -target:Pack
50-
51-
- name: Write version to artifact
52-
run: find artifacts -name '*.nupkg' | grep -oP '\d+\.\d+\.\d+(.*?)(?=.nupkg)' > artifacts/VERSION
53-
54-
- name: Upload artifact
55-
uses: actions/upload-artifact@v2
56-
with:
57-
name: package
58-
retention-days: 5
59-
path: |
60-
artifacts/*.nupkg
61-
artifacts/*.snupkg
62-
artifacts/VERSION
63-
648
test:
659
name: Test
66-
needs:
67-
- build
6810
runs-on: ${{ matrix.os }}
6911
strategy:
7012
fail-fast: false
@@ -73,69 +15,68 @@ jobs:
7315
- macos-latest
7416
- windows-latest
7517
- ubuntu-latest
76-
tfm:
77-
- "netcoreapp2.1"
78-
- "netcoreapp3.1"
79-
- "net5.0"
80-
include:
81-
- tfm: "netcoreapp3.1"
82-
dotnet: "3.1.404"
8318

8419
env:
20+
DOTNET_NOLOGO: "true"
21+
DOTNET_CLI_TELEMETRY_OPTOUT: "true"
8522
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: "true"
86-
DOTNET_CLI_TELEMETRY_OPTOUT: "1"
8723

8824
steps:
89-
- name: Setup dotnet 2.1
25+
- name: ⏬ Checkout
26+
uses: actions/checkout@v2
27+
with:
28+
fetch-depth: 0
29+
30+
- name: 🔽 Setup dotnet 2.1
9031
uses: actions/setup-dotnet@v1
9132
with:
92-
dotnet-version: "2.1.805"
33+
dotnet-version: "2.1.x"
9334

94-
- name: Setup dotnet ${{ matrix.dotnet }}
95-
if: ${{ matrix.dotnet }} != ''
35+
- name: 🔽 Setup dotnet 3.1
9636
uses: actions/setup-dotnet@v1
9737
with:
98-
dotnet-version: ${{ matrix.dotnet }}
38+
dotnet-version: "3.1.x"
9939

100-
- name: Setup dotnet 5.0
40+
- name: 🔽 Setup dotnet from global.json
10141
uses: actions/setup-dotnet@v1
42+
43+
- name: 🔽 Install GitVersion
44+
uses: gittools/actions/gitversion/[email protected]
10245
with:
103-
dotnet-version: "5.0.101"
46+
versionSpec: "5.x"
10447

105-
- name: Print dotnet info
48+
- name: 🔍 Print dotnet info
10649
run: dotnet --info
10750

108-
- uses: actions/checkout@master
51+
- name: 🔍 Determine Version
52+
id: gitversion
53+
uses: gittools/actions/gitversion/[email protected]
54+
with:
55+
useConfigFile: true
56+
57+
- name: 🔽 Restore
58+
run: dotnet restore -p:Configuration=Release
59+
60+
- name: 🔨 Build
61+
run: dotnet build --configuration Release
62+
63+
- name: 🧪 Test
64+
run: dotnet test --no-build --configuration Release
65+
66+
- name: 📦 Pack
67+
run: dotnet pack --configuration Release --no-build
68+
if: ${{ matrix.os == 'ubuntu-latest' }}
10969

110-
- name: Download package
111-
uses: actions/download-artifact@v2
70+
- name: 🔼 Upload packages as artifact
71+
uses: actions/upload-artifact@v2
72+
if: ${{ matrix.os == 'ubuntu-latest' }}
73+
with:
74+
name: nuget
75+
path: artifacts/nuget/
76+
77+
- name: 🔼 Upload global.json as artifact
78+
uses: actions/upload-artifact@v2
79+
if: ${{ matrix.os == 'ubuntu-latest' }}
11280
with:
113-
name: package
114-
path: ~/packages/YoloDev.Expecto.TestSdk
115-
116-
- name: Set version env var
117-
run: |
118-
VERSION=$(<~/packages/YoloDev.Expecto.TestSdk/VERSION)
119-
echo "TEST_VERSION=$VERSION" >>$GITHUB_ENV
120-
shell: bash
121-
122-
- name: Display structure of downloaded files
123-
run: ls -R ~/packages/YoloDev.Expecto.TestSdk
124-
shell: pwsh
125-
126-
- name: Restore test project with local package
127-
run: |
128-
$local = Resolve-Path ~/packages/YoloDev.Expecto.TestSdk
129-
dotnet nuget add source $local -n local-packages
130-
# Write-Host $local
131-
# Write-Host $remote
132-
dotnet restore test/Sample.Test -p:CiTestTfm=${{ matrix.tfm }} -p:CiTestVersion=${{ env.TEST_VERSION }}
133-
shell: pwsh
134-
135-
- name: Build test project
136-
run: dotnet build --no-restore test/Sample.Test -p:CiTestTfm=${{ matrix.tfm }} -p:CiTestVersion=${{ env.TEST_VERSION }}
137-
shell: pwsh
138-
139-
- name: Test project
140-
run: dotnet test --no-build --no-restore test/Sample.Test -p:CiTestTfm=${{ matrix.tfm }} -p:CiTestVersion=${{ env.TEST_VERSION }}
141-
shell: pwsh
81+
name: global-json
82+
path: global.json

.github/workflows/release.yml

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
name: Release
2+
3+
on:
4+
workflow_run:
5+
workflows: [CI]
6+
branches: [main]
7+
types: [completed]
8+
9+
jobs:
10+
build:
11+
name: Build
12+
runs-on: ubuntu-latest
13+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
14+
15+
steps:
16+
- name: ⏬ Checkout
17+
uses: actions/checkout@v2
18+
with:
19+
fetch-depth: 0
20+
ref: ${{ github.event.workflow_run.head_sha }}
21+
22+
- name: 🔧 Setup git
23+
run: git branch -D main || true; git checkout -b main
24+
25+
- name: 🔽 Install dotnet
26+
uses: actions/setup-dotnet@v1
27+
28+
- name: 🔽 Install GitVersion
29+
uses: gittools/actions/gitversion/[email protected]
30+
with:
31+
versionSpec: "5.x"
32+
33+
- name: 🔍 Print dotnet info
34+
run: dotnet --info
35+
36+
- name: 🔍 Determine Version
37+
id: gitversion
38+
uses: gittools/actions/gitversion/[email protected]
39+
with:
40+
useConfigFile: true
41+
42+
- name: 🔽 Restore
43+
run: dotnet restore -p:Configuration=Release
44+
45+
- name: 🔨 Build
46+
run: dotnet build --configuration Release
47+
48+
- name: 📦 Pack
49+
run: dotnet pack --configuration Release --no-build
50+
51+
- name: 🔼 Upload packages as artifact
52+
uses: actions/upload-artifact@v2
53+
with:
54+
name: nuget
55+
path: artifacts/nuget/
56+
57+
- name: 🔼 Upload global.json as artifact
58+
uses: actions/upload-artifact@v2
59+
with:
60+
name: global-json
61+
path: global.json
62+
63+
outputs:
64+
version: ${{ steps.gitversion.outputs.fullSemVer }}
65+
66+
release:
67+
name: Create Release
68+
runs-on: ubuntu-latest
69+
permissions:
70+
contents: write
71+
environment: release
72+
concurrency:
73+
group: release
74+
cancel-in-progress: true
75+
needs:
76+
- build
77+
78+
steps:
79+
- name: 🏷️ Create GitHub Tag
80+
uses: actions/github-script@v4
81+
with:
82+
script: |
83+
github.git.createRef({
84+
owner: context.repo.owner,
85+
repo: context.repo.repo,
86+
ref: "refs/tags/v${{ needs.build.outputs.version }}",
87+
sha: "${{ github.event.workflow_run.head_sha }}",
88+
});
89+
90+
- name: ⏬ Checkout
91+
uses: actions/checkout@v2
92+
with:
93+
ref: refs/tags/v${{ needs.build.outputs.version }}
94+
95+
- name: 📝 Create changelog
96+
id: changelog
97+
uses: mikepenz/release-changelog-builder-action@v2
98+
env:
99+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100+
101+
- name: 🔽 Download nuget artifact
102+
uses: actions/download-artifact@v2
103+
with:
104+
name: nuget
105+
path: nuget
106+
107+
- name: 🖃 Create GitHub Release
108+
uses: softprops/action-gh-release@v1
109+
with:
110+
prerelease: false
111+
tag_name: v${{ needs.build.outputs.version }}
112+
body: ${{ needs.build.outputs.changelog }}
113+
files: |
114+
nuget/*.nupkg
115+
env:
116+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117+
118+
githubpkg:
119+
name: Push to GitHub Packages
120+
runs-on: ubuntu-latest
121+
permissions:
122+
packages: write
123+
needs:
124+
- build
125+
- release
126+
127+
steps:
128+
- name: 🔽 Download nuget artifact
129+
uses: actions/download-artifact@v2
130+
with:
131+
name: nuget
132+
path: nuget
133+
134+
- name: 🔽 Download global-json artifact
135+
uses: actions/download-artifact@v2
136+
with:
137+
name: global-json
138+
139+
- name: 🔽 Install dotnet
140+
uses: actions/setup-dotnet@v1
141+
142+
- name: 🔼 Publish package to nuget
143+
run: dotnet nuget push --force-english-output --api-key '${{ secrets.GITHUB_TOKEN }}' --source 'https://nuget.pkg.github.com/YoloDev/index.json' --skip-duplicate "nuget/*.nupkg"
144+
145+
nuget:
146+
name: Push to Nuget
147+
runs-on: ubuntu-latest
148+
environment: nuget
149+
needs:
150+
- build
151+
- release
152+
- githubpkg
153+
154+
steps:
155+
- name: 🔽 Download nuget artifact
156+
uses: actions/download-artifact@v2
157+
with:
158+
name: nuget
159+
path: nuget
160+
161+
- name: 🔽 Download global-json artifact
162+
uses: actions/download-artifact@v2
163+
with:
164+
name: global-json
165+
166+
- name: 🔽 Install dotnet
167+
uses: actions/setup-dotnet@v1
168+
169+
- name: 🔼 Publish package to nuget
170+
run: dotnet nuget push --force-english-output --api-key '${{ secrets.NUGET_API_KEY }}' --source '${{ secrets.NUGET_FEED }}' --skip-duplicate "nuget/*.nupkg"

Directory.Build.props

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
<RepositoryType>git</RepositoryType>
1010
<RepositoryRoot>$(MSBuildThisFileDirectory)</RepositoryRoot>
1111
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
12-
<NoWarn>$(NoWarn);NU5125</NoWarn>
12+
<NoWarn>$(NoWarn);NU5125;NU5128;SA0001</NoWarn>
1313
<DebugType>embedded</DebugType>
1414
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
15-
<GitVersionBaseDirectory>$(MSBuildThisFileDirectory)</GitVersionBaseDirectory>
1615
</PropertyGroup>
1716

1817
</Project>

Directory.Packages.props

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
11
<Project>
22

3-
<PropertyGroup>
4-
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
5-
</PropertyGroup>
6-
73
<ItemGroup>
84
<PackageVersion Include="Expecto" Version="[9.0, 10.0)" />
95
<PackageVersion Include="FSharp.Core" Version="[4.6.0,)" />
106
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
11-
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.0.0" />
127
<PackageVersion Include="Microsoft.TestPlatform.ObjectModel" Version="16.10.0" />
138
<PackageVersion Include="System.Collections.Immutable" Version="[1.5.0, 5.1)" />
149
</ItemGroup>
1510

16-
<ItemGroup>
17-
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.4.220" />
18-
<PackageVersion Include="YoloDev.Expecto.TestSdk" Version="$(CiTestVersion)" Condition="'$(CiTestTfm)' != ''" />
19-
</ItemGroup>
20-
2111
</Project>

GitVersion.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
mode: Mainline
2+
major-version-bump-message: 'SemVer:\s(breaking|major)'
3+
minor-version-bump-message: 'SemVer:\s(feature|minor)'
4+
patch-version-bump-message: 'SemVer:\s(fix|patch)'
5+
no-bump-message: '\SemVer:\s(none|skip)'

0 commit comments

Comments
 (0)