Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synchronizing with master branch #83

Merged
merged 3 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 121 additions & 22 deletions .github/workflows/dotnet.yml
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
Expand All @@ -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/set-vs-sdk-project-version@v1.0.6
- 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/set-vs-sdk-project-version@v1.0.6
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]))
});
}
}
});
88 changes: 88 additions & 0 deletions .github/workflows/dotnetpull.yml
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/set-vs-sdk-project-version@v1.0.6
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
1 change: 1 addition & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
next-version: 5.0.118
6 changes: 0 additions & 6 deletions Source/dotnet-releaser.toml

This file was deleted.