Skip to content

Commit 365ed4e

Browse files
authored
Merge pull request #82 from paulushub/master
Reworked the GitHub Actions
2 parents 4c35a00 + 8996633 commit 365ed4e

File tree

4 files changed

+210
-28
lines changed

4 files changed

+210
-28
lines changed

.github/workflows/dotnet.yml

Lines changed: 121 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
name: .NET
22

33
on:
4+
workflow_dispatch: # Allow running the workflow manually from the GitHub UI
45
push:
56
branches: [ master ]
6-
pull_request:
7-
branches: [ master ]
87

8+
defaults:
9+
run:
10+
shell: bash
11+
912
jobs:
1013
build:
1114
runs-on: windows-latest
@@ -14,36 +17,132 @@ jobs:
1417
- name: Checkout
1518
uses: actions/checkout@v3
1619
with:
17-
submodules: false
1820
fetch-depth: 0
1921

20-
- name: Install .NET 8.0
21-
uses: actions/setup-dotnet@v3
22-
with:
23-
dotnet-version: '8.0.x'
24-
25-
- name: Restore dependencies
26-
run: dotnet restore ./Source/SVGImage/DotNetProjects.SVGImage.csproj
27-
28-
- name: GitVersion
29-
id: gitversion # step id used as reference for output values
30-
uses: roryprimrose/set-vs-sdk-project-version@v1.0.6
22+
- name: Install GitVersion
23+
uses: gittools/actions/gitversion/setup@v0
3124
with:
32-
projectFilter: './Source/SVGImage/*.SVGImage.csproj'
33-
version: '5.0.118'
25+
versionSpec: '5.x'
26+
27+
- name: Use GitVersion
28+
id: gitversion # step id used as reference for output values
29+
uses: gittools/actions/gitversion/execute@v0
30+
31+
- name: Display GitVersion outputs (step output)
32+
run: |
33+
echo "Major: ${{ steps.gitversion.outputs.major }}"
34+
echo "Minor: ${{ steps.gitversion.outputs.minor }}"
35+
echo "Patch: ${{ steps.gitversion.outputs.patch }}"
36+
echo "PreReleaseTag: ${{ steps.gitversion.outputs.preReleaseTag }}"
37+
echo "PreReleaseTagWithDash: ${{ steps.gitversion.outputs.preReleaseTagWithDash }}"
38+
echo "PreReleaseLabel: ${{ steps.gitversion.outputs.preReleaseLabel }}"
39+
echo "PreReleaseNumber: ${{ steps.gitversion.outputs.preReleaseNumber }}"
40+
echo "WeightedPreReleaseNumber: ${{ steps.gitversion.outputs.weightedPreReleaseNumber }}"
41+
echo "BuildMetaData: ${{ steps.gitversion.outputs.buildMetaData }}"
42+
echo "BuildMetaDataPadded: ${{ steps.gitversion.outputs.buildMetaDataPadded }}"
43+
echo "FullBuildMetaData: ${{ steps.gitversion.outputs.fullBuildMetaData }}"
44+
echo "MajorMinorPatch: ${{ steps.gitversion.outputs.majorMinorPatch }}"
45+
echo "SemVer: ${{ steps.gitversion.outputs.semVer }}"
46+
echo "LegacySemVer: ${{ steps.gitversion.outputs.legacySemVer }}"
47+
echo "LegacySemVerPadded: ${{ steps.gitversion.outputs.legacySemVerPadded }}"
48+
echo "AssemblySemVer: ${{ steps.gitversion.outputs.assemblySemVer }}"
49+
echo "AssemblySemFileVer: ${{ steps.gitversion.outputs.assemblySemFileVer }}"
50+
echo "FullSemVer: ${{ steps.gitversion.outputs.fullSemVer }}"
51+
echo "InformationalVersion: ${{ steps.gitversion.outputs.informationalVersion }}"
52+
echo "BranchName: ${{ steps.gitversion.outputs.branchName }}"
53+
echo "EscapedBranchName: ${{ steps.gitversion.outputs.escapedBranchName }}"
54+
echo "Sha: ${{ steps.gitversion.outputs.sha }}"
55+
echo "ShortSha: ${{ steps.gitversion.outputs.shortSha }}"
56+
echo "NuGetVersionV2: ${{ steps.gitversion.outputs.nuGetVersionV2 }}"
57+
echo "NuGetVersion: ${{ steps.gitversion.outputs.nuGetVersion }}"
58+
echo "NuGetPreReleaseTagV2: ${{ steps.gitversion.outputs.nuGetPreReleaseTagV2 }}"
59+
echo "NuGetPreReleaseTag: ${{ steps.gitversion.outputs.nuGetPreReleaseTag }}"
60+
echo "VersionSourceSha: ${{ steps.gitversion.outputs.versionSourceSha }}"
61+
echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.commitsSinceVersionSource }}"
62+
echo "CommitsSinceVersionSourcePadded: ${{ steps.gitversion.outputs.commitsSinceVersionSourcePadded }}"
63+
echo "UncommittedChanges: ${{ steps.gitversion.outputs.uncommittedChanges }}"
64+
echo "CommitDate: ${{ steps.gitversion.outputs.commitDate }}"
3465
3566
- name: Update project version
3667
uses: roryprimrose/set-vs-sdk-project-version@v1.0.6
3768
with:
3869
projectFilter: './Source/SVGImage/*.SVGImage.csproj'
39-
version: '5.0.118'
40-
# version: ${{ steps.gitversion.outputs.NuGetVersionV2 }}
70+
version: ${{ steps.gitversion.outputs.NuGetVersionV2 }}
4171
assemblyVersion: ${{ steps.gitversion.outputs.AssemblySemVer }}
4272
fileVersion: ${{ steps.gitversion.outputs.MajorMinorPatch }}
4373
informationalVersion: ${{ steps.gitversion.outputs.InformationalVersion }}
4474

45-
- name: Build, Test, Pack, Publish
46-
shell: bash
75+
- name: Install .NET 8.0
76+
uses: actions/setup-dotnet@v3
77+
with:
78+
dotnet-version: '8.0.x'
79+
80+
- name: Restore dependencies
81+
run: dotnet restore ./Source/SVGImage/DotNetProjects.SVGImage.csproj
82+
83+
- name: Build
84+
run: dotnet build --configuration Release DotNetProjects.SVGImage.csproj
85+
working-directory: ./Source/SVGImage
86+
87+
- name: Generate nuget package.
88+
run: dotnet pack DotNetProjects.SVGImage.csproj --configuration Release -o nupkg
89+
working-directory: ./Source/SVGImage
90+
91+
- name: Publish to nuget
92+
# run: find . -type f -name *.nupkg -print0 | xargs -0 -I pkg dotnet nuget push pkg -k $nuget_api_key -s "https://api.nuget.org/v3/index.json" --skip-duplicate
4793
run: |
48-
dotnet tool install -g dotnet-releaser
49-
dotnet-releaser run --nuget-token "${{secrets.NUGET_API_KEY}}" --github-token "${{secrets.GITHUB_TOKEN}}" Source/dotnet-releaser.toml
94+
find . -type f -name *.nupkg -print0 | xargs -0 -I pkg dotnet nuget push pkg -k $nuget_api_key -s "https://api.nuget.org/v3/index.json" --skip-duplicate
95+
env:
96+
nuget_api_key: ${{ secrets.NUGET_API_KEY }}
97+
working-directory: ./Source/SVGImage/nupkg
98+
99+
- name: "Create release"
100+
uses: "actions/github-script@v6"
101+
id: createrelease
102+
with:
103+
github-token: "${{ secrets.GITHUB_TOKEN }}"
104+
script: |
105+
try {
106+
const response = await github.rest.repos.createRelease({
107+
draft: false,
108+
generate_release_notes: true,
109+
name: "Release ${{ steps.gitversion.outputs.semVer }}",
110+
owner: context.repo.owner,
111+
prerelease: false,
112+
repo: context.repo.repo,
113+
tag_name: "${{ steps.gitversion.outputs.semVer }}",
114+
});
115+
116+
core.exportVariable('RELEASE_ID', response.data.id);
117+
core.exportVariable('RELEASE_UPLOAD_URL', response.data.upload_url);
118+
} catch (error) {
119+
core.setFailed(error.message);
120+
}
121+
122+
- name: Upload release artifacts
123+
uses: actions/github-script@v6
124+
env:
125+
releaseId: ${{ env.RELEASE_ID }}
126+
workingDirectory: ./Source/SVGImage/nupkg
127+
with:
128+
github-token: ${{ secrets.GITHUB_TOKEN }}
129+
script: |
130+
const releaseId = process.env.releaseId;
131+
const workingDirectory = process.env.workingDirectory;
132+
const fs = require('fs');
133+
const dirPath = workingDirectory;
134+
const path = require('path');
135+
fs.readdir(dirPath, async (err,list) => {
136+
if (err) throw err;
137+
for (var i = 0; i < list.length; i++) {
138+
if (path.extname(list[i]) === '.nupkg' || path.extname(list[i]) === '.snupkg') {
139+
const uploadAssetResponse = await github.rest.repos.uploadReleaseAsset({
140+
owner: context.repo.owner,
141+
repo: context.repo.repo,
142+
release_id: releaseId,
143+
name: list[i],
144+
data: fs.readFileSync(path.join(dirPath, list[i]))
145+
});
146+
}
147+
}
148+
});

.github/workflows/dotnetpull.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: .NET
2+
3+
on:
4+
pull_request:
5+
branches: [ master ]
6+
7+
defaults:
8+
run:
9+
shell: bash
10+
11+
jobs:
12+
build:
13+
runs-on: windows-latest
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Install GitVersion
22+
uses: gittools/actions/gitversion/setup@v0
23+
with:
24+
versionSpec: '5.x'
25+
26+
- name: Use GitVersion
27+
id: gitversion # step id used as reference for output values
28+
uses: gittools/actions/gitversion/execute@v0
29+
30+
- name: Display GitVersion outputs (step output)
31+
run: |
32+
echo "Major: ${{ steps.gitversion.outputs.major }}"
33+
echo "Minor: ${{ steps.gitversion.outputs.minor }}"
34+
echo "Patch: ${{ steps.gitversion.outputs.patch }}"
35+
echo "PreReleaseTag: ${{ steps.gitversion.outputs.preReleaseTag }}"
36+
echo "PreReleaseTagWithDash: ${{ steps.gitversion.outputs.preReleaseTagWithDash }}"
37+
echo "PreReleaseLabel: ${{ steps.gitversion.outputs.preReleaseLabel }}"
38+
echo "PreReleaseNumber: ${{ steps.gitversion.outputs.preReleaseNumber }}"
39+
echo "WeightedPreReleaseNumber: ${{ steps.gitversion.outputs.weightedPreReleaseNumber }}"
40+
echo "BuildMetaData: ${{ steps.gitversion.outputs.buildMetaData }}"
41+
echo "BuildMetaDataPadded: ${{ steps.gitversion.outputs.buildMetaDataPadded }}"
42+
echo "FullBuildMetaData: ${{ steps.gitversion.outputs.fullBuildMetaData }}"
43+
echo "MajorMinorPatch: ${{ steps.gitversion.outputs.majorMinorPatch }}"
44+
echo "SemVer: ${{ steps.gitversion.outputs.semVer }}"
45+
echo "LegacySemVer: ${{ steps.gitversion.outputs.legacySemVer }}"
46+
echo "LegacySemVerPadded: ${{ steps.gitversion.outputs.legacySemVerPadded }}"
47+
echo "AssemblySemVer: ${{ steps.gitversion.outputs.assemblySemVer }}"
48+
echo "AssemblySemFileVer: ${{ steps.gitversion.outputs.assemblySemFileVer }}"
49+
echo "FullSemVer: ${{ steps.gitversion.outputs.fullSemVer }}"
50+
echo "InformationalVersion: ${{ steps.gitversion.outputs.informationalVersion }}"
51+
echo "BranchName: ${{ steps.gitversion.outputs.branchName }}"
52+
echo "EscapedBranchName: ${{ steps.gitversion.outputs.escapedBranchName }}"
53+
echo "Sha: ${{ steps.gitversion.outputs.sha }}"
54+
echo "ShortSha: ${{ steps.gitversion.outputs.shortSha }}"
55+
echo "NuGetVersionV2: ${{ steps.gitversion.outputs.nuGetVersionV2 }}"
56+
echo "NuGetVersion: ${{ steps.gitversion.outputs.nuGetVersion }}"
57+
echo "NuGetPreReleaseTagV2: ${{ steps.gitversion.outputs.nuGetPreReleaseTagV2 }}"
58+
echo "NuGetPreReleaseTag: ${{ steps.gitversion.outputs.nuGetPreReleaseTag }}"
59+
echo "VersionSourceSha: ${{ steps.gitversion.outputs.versionSourceSha }}"
60+
echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.commitsSinceVersionSource }}"
61+
echo "CommitsSinceVersionSourcePadded: ${{ steps.gitversion.outputs.commitsSinceVersionSourcePadded }}"
62+
echo "UncommittedChanges: ${{ steps.gitversion.outputs.uncommittedChanges }}"
63+
echo "CommitDate: ${{ steps.gitversion.outputs.commitDate }}"
64+
65+
- name: Update project version
66+
uses: roryprimrose/set-vs-sdk-project-version@v1.0.6
67+
with:
68+
projectFilter: './Source/SVGImage/*.SVGImage.csproj'
69+
version: ${{ steps.gitversion.outputs.NuGetVersionV2 }}
70+
assemblyVersion: ${{ steps.gitversion.outputs.AssemblySemVer }}
71+
fileVersion: ${{ steps.gitversion.outputs.MajorMinorPatch }}
72+
informationalVersion: ${{ steps.gitversion.outputs.InformationalVersion }}
73+
74+
- name: Install .NET 8.0
75+
uses: actions/setup-dotnet@v3
76+
with:
77+
dotnet-version: '8.0.x'
78+
79+
- name: Restore dependencies
80+
run: dotnet restore ./Source/SVGImage/DotNetProjects.SVGImage.csproj
81+
82+
- name: Build
83+
run: dotnet build --configuration Release DotNetProjects.SVGImage.csproj
84+
working-directory: ./Source/SVGImage
85+
86+
- name: Generate nuget package.
87+
run: dotnet pack DotNetProjects.SVGImage.csproj --configuration Release -o nupkg
88+
working-directory: ./Source/SVGImage

GitVersion.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
next-version: 5.0.118

Source/dotnet-releaser.toml

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)