-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from paulushub/master
Reworked the GitHub Actions
- Loading branch information
Showing
4 changed files
with
210 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
name: .NET | ||
|
||
on: | ||
workflow_dispatch: # Allow running the workflow manually from the GitHub UI | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
build: | ||
runs-on: windows-latest | ||
|
@@ -14,36 +17,132 @@ jobs: | |
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: false | ||
fetch-depth: 0 | ||
|
||
- name: Install .NET 8.0 | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: '8.0.x' | ||
|
||
- name: Restore dependencies | ||
run: dotnet restore ./Source/SVGImage/DotNetProjects.SVGImage.csproj | ||
|
||
- name: GitVersion | ||
id: gitversion # step id used as reference for output values | ||
uses: roryprimrose/[email protected] | ||
- name: Install GitVersion | ||
uses: gittools/actions/gitversion/setup@v0 | ||
with: | ||
projectFilter: './Source/SVGImage/*.SVGImage.csproj' | ||
version: '5.0.118' | ||
versionSpec: '5.x' | ||
|
||
- name: Use GitVersion | ||
id: gitversion # step id used as reference for output values | ||
uses: gittools/actions/gitversion/execute@v0 | ||
|
||
- name: Display GitVersion outputs (step output) | ||
run: | | ||
echo "Major: ${{ steps.gitversion.outputs.major }}" | ||
echo "Minor: ${{ steps.gitversion.outputs.minor }}" | ||
echo "Patch: ${{ steps.gitversion.outputs.patch }}" | ||
echo "PreReleaseTag: ${{ steps.gitversion.outputs.preReleaseTag }}" | ||
echo "PreReleaseTagWithDash: ${{ steps.gitversion.outputs.preReleaseTagWithDash }}" | ||
echo "PreReleaseLabel: ${{ steps.gitversion.outputs.preReleaseLabel }}" | ||
echo "PreReleaseNumber: ${{ steps.gitversion.outputs.preReleaseNumber }}" | ||
echo "WeightedPreReleaseNumber: ${{ steps.gitversion.outputs.weightedPreReleaseNumber }}" | ||
echo "BuildMetaData: ${{ steps.gitversion.outputs.buildMetaData }}" | ||
echo "BuildMetaDataPadded: ${{ steps.gitversion.outputs.buildMetaDataPadded }}" | ||
echo "FullBuildMetaData: ${{ steps.gitversion.outputs.fullBuildMetaData }}" | ||
echo "MajorMinorPatch: ${{ steps.gitversion.outputs.majorMinorPatch }}" | ||
echo "SemVer: ${{ steps.gitversion.outputs.semVer }}" | ||
echo "LegacySemVer: ${{ steps.gitversion.outputs.legacySemVer }}" | ||
echo "LegacySemVerPadded: ${{ steps.gitversion.outputs.legacySemVerPadded }}" | ||
echo "AssemblySemVer: ${{ steps.gitversion.outputs.assemblySemVer }}" | ||
echo "AssemblySemFileVer: ${{ steps.gitversion.outputs.assemblySemFileVer }}" | ||
echo "FullSemVer: ${{ steps.gitversion.outputs.fullSemVer }}" | ||
echo "InformationalVersion: ${{ steps.gitversion.outputs.informationalVersion }}" | ||
echo "BranchName: ${{ steps.gitversion.outputs.branchName }}" | ||
echo "EscapedBranchName: ${{ steps.gitversion.outputs.escapedBranchName }}" | ||
echo "Sha: ${{ steps.gitversion.outputs.sha }}" | ||
echo "ShortSha: ${{ steps.gitversion.outputs.shortSha }}" | ||
echo "NuGetVersionV2: ${{ steps.gitversion.outputs.nuGetVersionV2 }}" | ||
echo "NuGetVersion: ${{ steps.gitversion.outputs.nuGetVersion }}" | ||
echo "NuGetPreReleaseTagV2: ${{ steps.gitversion.outputs.nuGetPreReleaseTagV2 }}" | ||
echo "NuGetPreReleaseTag: ${{ steps.gitversion.outputs.nuGetPreReleaseTag }}" | ||
echo "VersionSourceSha: ${{ steps.gitversion.outputs.versionSourceSha }}" | ||
echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.commitsSinceVersionSource }}" | ||
echo "CommitsSinceVersionSourcePadded: ${{ steps.gitversion.outputs.commitsSinceVersionSourcePadded }}" | ||
echo "UncommittedChanges: ${{ steps.gitversion.outputs.uncommittedChanges }}" | ||
echo "CommitDate: ${{ steps.gitversion.outputs.commitDate }}" | ||
- name: Update project version | ||
uses: roryprimrose/[email protected] | ||
with: | ||
projectFilter: './Source/SVGImage/*.SVGImage.csproj' | ||
version: '5.0.118' | ||
# version: ${{ steps.gitversion.outputs.NuGetVersionV2 }} | ||
version: ${{ steps.gitversion.outputs.NuGetVersionV2 }} | ||
assemblyVersion: ${{ steps.gitversion.outputs.AssemblySemVer }} | ||
fileVersion: ${{ steps.gitversion.outputs.MajorMinorPatch }} | ||
informationalVersion: ${{ steps.gitversion.outputs.InformationalVersion }} | ||
|
||
- name: Build, Test, Pack, Publish | ||
shell: bash | ||
- name: Install .NET 8.0 | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: '8.0.x' | ||
|
||
- name: Restore dependencies | ||
run: dotnet restore ./Source/SVGImage/DotNetProjects.SVGImage.csproj | ||
|
||
- name: Build | ||
run: dotnet build --configuration Release DotNetProjects.SVGImage.csproj | ||
working-directory: ./Source/SVGImage | ||
|
||
- name: Generate nuget package. | ||
run: dotnet pack DotNetProjects.SVGImage.csproj --configuration Release -o nupkg | ||
working-directory: ./Source/SVGImage | ||
|
||
- name: Publish to nuget | ||
# 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 | ||
run: | | ||
dotnet tool install -g dotnet-releaser | ||
dotnet-releaser run --nuget-token "${{secrets.NUGET_API_KEY}}" --github-token "${{secrets.GITHUB_TOKEN}}" Source/dotnet-releaser.toml | ||
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 | ||
env: | ||
nuget_api_key: ${{ secrets.NUGET_API_KEY }} | ||
working-directory: ./Source/SVGImage/nupkg | ||
|
||
- name: "Create release" | ||
uses: "actions/github-script@v6" | ||
id: createrelease | ||
with: | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
script: | | ||
try { | ||
const response = await github.rest.repos.createRelease({ | ||
draft: false, | ||
generate_release_notes: true, | ||
name: "Release ${{ steps.gitversion.outputs.semVer }}", | ||
owner: context.repo.owner, | ||
prerelease: false, | ||
repo: context.repo.repo, | ||
tag_name: "${{ steps.gitversion.outputs.semVer }}", | ||
}); | ||
core.exportVariable('RELEASE_ID', response.data.id); | ||
core.exportVariable('RELEASE_UPLOAD_URL', response.data.upload_url); | ||
} catch (error) { | ||
core.setFailed(error.message); | ||
} | ||
- name: Upload release artifacts | ||
uses: actions/github-script@v6 | ||
env: | ||
releaseId: ${{ env.RELEASE_ID }} | ||
workingDirectory: ./Source/SVGImage/nupkg | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const releaseId = process.env.releaseId; | ||
const workingDirectory = process.env.workingDirectory; | ||
const fs = require('fs'); | ||
const dirPath = workingDirectory; | ||
const path = require('path'); | ||
fs.readdir(dirPath, async (err,list) => { | ||
if (err) throw err; | ||
for (var i = 0; i < list.length; i++) { | ||
if (path.extname(list[i]) === '.nupkg' || path.extname(list[i]) === '.snupkg') { | ||
const uploadAssetResponse = await github.rest.repos.uploadReleaseAsset({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
release_id: releaseId, | ||
name: list[i], | ||
data: fs.readFileSync(path.join(dirPath, list[i])) | ||
}); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
name: .NET | ||
|
||
on: | ||
pull_request: | ||
branches: [ master ] | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
build: | ||
runs-on: windows-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install GitVersion | ||
uses: gittools/actions/gitversion/setup@v0 | ||
with: | ||
versionSpec: '5.x' | ||
|
||
- name: Use GitVersion | ||
id: gitversion # step id used as reference for output values | ||
uses: gittools/actions/gitversion/execute@v0 | ||
|
||
- name: Display GitVersion outputs (step output) | ||
run: | | ||
echo "Major: ${{ steps.gitversion.outputs.major }}" | ||
echo "Minor: ${{ steps.gitversion.outputs.minor }}" | ||
echo "Patch: ${{ steps.gitversion.outputs.patch }}" | ||
echo "PreReleaseTag: ${{ steps.gitversion.outputs.preReleaseTag }}" | ||
echo "PreReleaseTagWithDash: ${{ steps.gitversion.outputs.preReleaseTagWithDash }}" | ||
echo "PreReleaseLabel: ${{ steps.gitversion.outputs.preReleaseLabel }}" | ||
echo "PreReleaseNumber: ${{ steps.gitversion.outputs.preReleaseNumber }}" | ||
echo "WeightedPreReleaseNumber: ${{ steps.gitversion.outputs.weightedPreReleaseNumber }}" | ||
echo "BuildMetaData: ${{ steps.gitversion.outputs.buildMetaData }}" | ||
echo "BuildMetaDataPadded: ${{ steps.gitversion.outputs.buildMetaDataPadded }}" | ||
echo "FullBuildMetaData: ${{ steps.gitversion.outputs.fullBuildMetaData }}" | ||
echo "MajorMinorPatch: ${{ steps.gitversion.outputs.majorMinorPatch }}" | ||
echo "SemVer: ${{ steps.gitversion.outputs.semVer }}" | ||
echo "LegacySemVer: ${{ steps.gitversion.outputs.legacySemVer }}" | ||
echo "LegacySemVerPadded: ${{ steps.gitversion.outputs.legacySemVerPadded }}" | ||
echo "AssemblySemVer: ${{ steps.gitversion.outputs.assemblySemVer }}" | ||
echo "AssemblySemFileVer: ${{ steps.gitversion.outputs.assemblySemFileVer }}" | ||
echo "FullSemVer: ${{ steps.gitversion.outputs.fullSemVer }}" | ||
echo "InformationalVersion: ${{ steps.gitversion.outputs.informationalVersion }}" | ||
echo "BranchName: ${{ steps.gitversion.outputs.branchName }}" | ||
echo "EscapedBranchName: ${{ steps.gitversion.outputs.escapedBranchName }}" | ||
echo "Sha: ${{ steps.gitversion.outputs.sha }}" | ||
echo "ShortSha: ${{ steps.gitversion.outputs.shortSha }}" | ||
echo "NuGetVersionV2: ${{ steps.gitversion.outputs.nuGetVersionV2 }}" | ||
echo "NuGetVersion: ${{ steps.gitversion.outputs.nuGetVersion }}" | ||
echo "NuGetPreReleaseTagV2: ${{ steps.gitversion.outputs.nuGetPreReleaseTagV2 }}" | ||
echo "NuGetPreReleaseTag: ${{ steps.gitversion.outputs.nuGetPreReleaseTag }}" | ||
echo "VersionSourceSha: ${{ steps.gitversion.outputs.versionSourceSha }}" | ||
echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.commitsSinceVersionSource }}" | ||
echo "CommitsSinceVersionSourcePadded: ${{ steps.gitversion.outputs.commitsSinceVersionSourcePadded }}" | ||
echo "UncommittedChanges: ${{ steps.gitversion.outputs.uncommittedChanges }}" | ||
echo "CommitDate: ${{ steps.gitversion.outputs.commitDate }}" | ||
- name: Update project version | ||
uses: roryprimrose/[email protected] | ||
with: | ||
projectFilter: './Source/SVGImage/*.SVGImage.csproj' | ||
version: ${{ steps.gitversion.outputs.NuGetVersionV2 }} | ||
assemblyVersion: ${{ steps.gitversion.outputs.AssemblySemVer }} | ||
fileVersion: ${{ steps.gitversion.outputs.MajorMinorPatch }} | ||
informationalVersion: ${{ steps.gitversion.outputs.InformationalVersion }} | ||
|
||
- name: Install .NET 8.0 | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: '8.0.x' | ||
|
||
- name: Restore dependencies | ||
run: dotnet restore ./Source/SVGImage/DotNetProjects.SVGImage.csproj | ||
|
||
- name: Build | ||
run: dotnet build --configuration Release DotNetProjects.SVGImage.csproj | ||
working-directory: ./Source/SVGImage | ||
|
||
- name: Generate nuget package. | ||
run: dotnet pack DotNetProjects.SVGImage.csproj --configuration Release -o nupkg | ||
working-directory: ./Source/SVGImage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
next-version: 5.0.118 |
This file was deleted.
Oops, something went wrong.