From a95e06c15d580226d319ae3d5b888b05e7449972 Mon Sep 17 00:00:00 2001 From: Tig Kindel Date: Thu, 26 May 2022 16:36:50 -0700 Subject: [PATCH] Fixes #1741. Use gitversion instead of minver (#1746) --- .github/workflows/dotnet-core.yml | 4 +- .github/workflows/publish.yml | 125 +++++++++------------ Example/Example.csproj | 14 +-- FSharpExample/FSharpExample.fsproj | 11 +- ReactiveExample/ReactiveExample.csproj | 32 +++--- StandaloneExample/StandaloneExample.csproj | 10 +- Terminal.Gui/README.md | 71 +++++++----- Terminal.Gui/Terminal.Gui.csproj | 26 ++--- Terminal.sln | 2 + UICatalog/Properties/launchSettings.json | 3 +- UICatalog/UICatalog.cs | 2 +- UICatalog/UICatalog.csproj | 12 +- UnitTests/UnitTests.csproj | 16 +-- 13 files changed, 162 insertions(+), 166 deletions(-) diff --git a/.github/workflows/dotnet-core.yml b/.github/workflows/dotnet-core.yml index cd5127ba9..a9e013f48 100644 --- a/.github/workflows/dotnet-core.yml +++ b/.github/workflows/dotnet-core.yml @@ -22,8 +22,8 @@ jobs: - name: Install dependencies run: dotnet restore - - name: Build - run: dotnet build --configuration Release --no-restore + - name: Build Debug + run: dotnet build --configuration Debug --no-restore - name: Test run: | diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4f07dd8df..8573e8ecf 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,4 +1,4 @@ -name: Publish Terminal.Gui to nuget +name: Publish Terminal.Gui on: push: tags: @@ -7,89 +7,72 @@ on: jobs: publish: - name: build, pack & publish + name: Build and Publish to Nuget.org runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 + - uses: actions/checkout@v3 + with: + fetch-depth: 0 #fetch-depth is needed for GitVersion - - name: Setup dotnet - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 6.0.100 + - name: Install and calculate the new version with GitVersion + uses: gittools/actions/gitversion/setup@v0.9.13 + with: + versionSpec: 5.x - - name: minver-cli - run: | - dotnet tool install --global minver-cli --version 2.4.0 - echo "MINVERVERSIONOVERRIDE=$(minver -t v -d rc)" >> $GITHUB_ENV + - name: Determine Version + uses: gittools/actions/gitversion/execute@v0.9.13 + id: gitversion # step id used as reference for output values - #- name: Install dependencies - # run: dotnet restore + - name: Display GitVersion outputs + run: | + echo "Version: ${{ steps.gitversion.outputs.SemVer }}" + echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }}" - #- name: Build - # run: dotnet build --configuration Release --no-restore + - name: Setup dotnet + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 6.0.100 - #- name: Pack nuget package with symbols - # run: dotnet pack --include-symbols - - - name: Publish Terminal.Gui - id: publish_nuget - uses: rohith/publish-nuget@v2 - with: - VERSION_STATIC: ${{ env.MINVERVERSIONOVERRIDE }} - NUGET_SOURCE: https://api.nuget.org + - name: Install dependencies + run: dotnet restore - # Filepath of the project to be packaged, relative to root of repository - PROJECT_FILE_PATH: Terminal.Gui/Terminal.Gui.csproj - - # NuGet package id, used for version detection & defaults to project name - PACKAGE_NAME: Terminal.Gui - - # Filepath with version info, relative to root of repository & defaults to PROJECT_FILE_PATH - #VERSION_FILE_PATH: Terminal.Gui/Directory.Build.props + - name: Build Release + run: | + dotnet-gitversion /updateprojectfiles + dotnet build --no-restore -c Release - # Regex pattern to extract version info in a capturing group - #VERSION_REGEX: ^\s*(.*)<\/Version>\s*$ - - # Useful with external providers like Nerdbank.GitVersioning, ignores VERSION_FILE_PATH & VERSION_REGEX - # VERSION_STATIC: 1.0.0 + - name: Pack + run: dotnet pack -c Release -p:Version='${{ steps.gitversion.outputs.SemVer }}' -v d - # Flag to toggle git tagging, enabled by default - TAG_COMMIT: false + - name: Test to generate Code Coverage Report + run: | + dotnet test --verbosity normal --collect:"XPlat Code Coverage" --settings UnitTests/coverlet.runsettings + mv -v UnitTests/TestResults/*/*.* UnitTests/TestResults/ - # Format of the git tag, [*] gets replaced with actual version - # TAG_FORMAT: v* + - name: Create Test Coverage Badge + uses: simon-k/dotnet-code-coverage-badge@v1.0.0 + id: create_coverage_badge + with: + label: Unit Test Coverage + color: brightgreen + path: UnitTests/TestResults/coverage.opencover.xml + gist-filename: code-coverage.json + # https://gist.github.com/migueldeicaza/90ef67a684cb71db1817921a970f8d27 + gist-id: 90ef67a684cb71db1817921a970f8d27 + gist-auth-token: ${{ secrets.GIST_AUTH_TOKEN }} - # API key to authenticate with NuGet server - NUGET_KEY: ${{secrets.NUGET_API_KEY}} + - name: Print Code Coverage + run: | + echo "Code coverage percentage: ${{steps.create_coverage_badge.outputs.percentage}}%" + echo "Badge data: ${{steps.create_coverage_badge.outputs.badge}}" - # NuGet server uri hosting the packages, defaults to https://api.nuget.org - # NUGET_SOURCE: https://api.nuget.org + + #- name: Prep GitHub Packages + # run: dotnet nuget add source --username tig --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/tig/index.json" - # Flag to toggle pushing symbols along with nuget package to the server, disabled by default - # This is broken - see https://github.com/brandedoutcast/publish-nuget/issues/30 - INCLUDE_SYMBOLS: false + #- name: Publish to GitHub packages + # run: dotnet nuget push NStack/bin/Release/*.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source "github" - - name: Test to generate Code Coverage Report - run: | - dotnet test --verbosity normal --collect:"XPlat Code Coverage" --settings UnitTests/coverlet.runsettings - mv -v UnitTests/TestResults/*/*.* UnitTests/TestResults/ - - - name: Create Test Coverage Badge - uses: simon-k/dotnet-code-coverage-badge@v1.0.0 - id: create_coverage_badge - with: - label: Unit Test Coverage - color: brightgreen - path: UnitTests/TestResults/coverage.opencover.xml - gist-filename: code-coverage.json - # https://gist.github.com/migueldeicaza/90ef67a684cb71db1817921a970f8d27 - gist-id: 90ef67a684cb71db1817921a970f8d27 - gist-auth-token: ${{ secrets.GIST_AUTH_TOKEN }} - - - name: Print Code Coverage - run: | - echo "Code coverage percentage: ${{steps.create_coverage_badge.outputs.percentage}}%" - echo "Badge data: ${{steps.create_coverage_badge.outputs.badge}}" \ No newline at end of file + - name: Publish to NuGet.org + run: dotnet nuget push Terminal.Gui/bin/Release/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json diff --git a/Example/Example.csproj b/Example/Example.csproj index 3e494bd3f..012a05460 100644 --- a/Example/Example.csproj +++ b/Example/Example.csproj @@ -1,16 +1,16 @@ - - + Exe net6.0 + 1.6.1.0 + 1.6.1.0 + 1.6.1+Branch.fixes-1741-gitversion.Sha.cc04bb37f5c7684d45833dabd3f7e1ca9c53786f + 1.6.1 - - + - - - + \ No newline at end of file diff --git a/FSharpExample/FSharpExample.fsproj b/FSharpExample/FSharpExample.fsproj index 6045b22c7..e034e1935 100644 --- a/FSharpExample/FSharpExample.fsproj +++ b/FSharpExample/FSharpExample.fsproj @@ -1,20 +1,19 @@  - Exe net6.0 + 1.6.1.0 + 1.6.1.0 + 1.6.1+Branch.fixes-1741-gitversion.Sha.cc04bb37f5c7684d45833dabd3f7e1ca9c53786f + 1.6.1 - - - - - + \ No newline at end of file diff --git a/ReactiveExample/ReactiveExample.csproj b/ReactiveExample/ReactiveExample.csproj index a6358886c..a6a7658cb 100644 --- a/ReactiveExample/ReactiveExample.csproj +++ b/ReactiveExample/ReactiveExample.csproj @@ -1,14 +1,18 @@ - - - Exe - net6.0 - - - - - - - - - - + + + Exe + net6.0 + 1.6.1.0 + 1.6.1.0 + 1.6.1+Branch.fixes-1741-gitversion.Sha.cc04bb37f5c7684d45833dabd3f7e1ca9c53786f + 1.6.1 + + + + + + + + + + \ No newline at end of file diff --git a/StandaloneExample/StandaloneExample.csproj b/StandaloneExample/StandaloneExample.csproj index 3ba15da2c..c22004b93 100644 --- a/StandaloneExample/StandaloneExample.csproj +++ b/StandaloneExample/StandaloneExample.csproj @@ -1,12 +1,14 @@ - - + latest Exe net6.0 + 1.6.1.0 + 1.6.1.0 + 1.6.1+Branch.fixes-1741-gitversion.Sha.cc04bb37f5c7684d45833dabd3f7e1ca9c53786f + 1.6.1 - - + \ No newline at end of file diff --git a/Terminal.Gui/README.md b/Terminal.Gui/README.md index 2de6cf82c..28452ed4d 100644 --- a/Terminal.Gui/README.md +++ b/Terminal.Gui/README.md @@ -1,6 +1,6 @@ # Terminal.Gui Project -Contains all files required to build the **Terminal.Gui** library (and NuGEt package). +Contains all files required to build the **Terminal.Gui** library (and NuGet package). ## Project Folder Structure @@ -22,33 +22,40 @@ Contains all files required to build the **Terminal.Gui** library (and NuGEt pac ## Version numbers -Version info for Terminal.Gui is managed by MinVer (https://github.com/adamralph/minver). +Version info for Terminal.Gui is managed by [gitversion](https://gitversion.net). -The project version (the nuget package and in `Terminal.Gui.dlls`) is determined from the latest `git tag`. +Install `gitversion`: + +```powershell +dotnet tool install --global GitVersion.Tool +dotnet-gitversion +``` + +The project version (the nuget package and in `Terminal.Gui.dll`) is determined from the latest `git tag`. The format of version numbers is `vmajor.minor.patch.build.height` and follows the [Semantic Versioning](https://semver.org/) rules. To define a new version (e.g. with a higher `major`, `minor`, `patch`, or `build` value) tag a commit using `git tag`: ```powershell -git tag v1.3.4-beta.5 -a -m "v1.3.4 Beta 5" +git tag v1.3.4-beta.5 -a -m "Release v1.3.4 Beta 5" +dotnet-gitversion /updateprojectfiles dotnet build -c Release ``` -If the current commit does not have a version tag, another number is added to the pre-release identifiers. This is the number of commits since the latest commit with a version tag or, if no commits have a version tag, since the root commit. This is known as "height". For example, if the latest version tag found is 1.0.0-beta.1, at a height of 42 commits, the calculated version is 1.0.0-beta.1.42. - -You can see the version in the `UICatalog` about box or by viewing the "Details" page of the file properties of `/Terminal.Gui/bin/Release/net5.0/Terminal.Gui.dll. +You can see the version in the `UICatalog` about box. ![About Box](https://raw.githubusercontent.com/migueldeicaza/gui.cs/master/docfx/aboutbox.png) ## Publishing a Release of Terminal.Gui -To release a new version (e.g. with a higher `major`, `minor`, or `patch` value) tag a commit using `git tag` and then push that tag directly to the upstream repo: +To release a new version (e.g. with a higher `major`, `minor`, or `patch` value) tag a commit using `git tag` and then push that tag directly to the upstream repo. + +The `tag` must be of the form `v..`, e.g. `v1.2.3`. ```powershell -git tag vmajor.minor.patch.build -a -m "Descriptive comment about release" -git push upstream vmajor.minor.patch.build - +git tag vmajor.minor.patch -a -m "Release vmajor.minor.patch" +git push upstream vmajor.minor.patch ``` `patch` can indicate pre-release or not (e.g. `pre`, `beta`, `rc`, etc...). @@ -62,49 +69,63 @@ git push upstream v1.3.4-beta.5 ## To launch version 2.3.4 as a Release nuget package do this: -1) Create a new tag +1) Generate release notes with the list of PRs since the last release + +Use `gh` to get list with just titles to make it easy to paste into release notes: ```powershell -git tag v2.3.4 -a -m "v2.3.4 Release" -``` +gh pr list --limit 500 --search "is:pr is:closed is:merged closed:>=2021-05-18" +``` -2) Update `./Terminal.Gui/Terminal.Gui.csproj` with latest release notes and submit a PR with a commit of `v2.3.4 Release` +Use the output to update `./Terminal.Gui/Terminal.Gui.csproj` with latest release notes -* Use `gh` to get list with just titles to make it easy to paste into release notes: `gh pr list --limit 500 --search "is:pr is:closed is:merged closed:>=2021-05-18"` -* PR title should be "v2.3.4 Release" +2) Update the API documentation + +See `./docfx/README.md`. + +3) Create a PR for the release + +The PR title should be "Release v2.3.4" ```powershell git add . -git commit -m "v2.3.4 Release" +git commit -m "Release v2.3.4" git push ``` -3) Pull upstream after PR has been merged +4) On github.co, verify the build action worked on your fork, then merge the PR + +5) Pull the merged main ```powershell git pull upstream main ``` -4) Push new tag to `main` +6) Create a new tag for the release + +```powershell +git tag v2.3.4 -a -m "Release v2.3.4" +``` + +7) Push new tag to `main` ```powershell -git tag v2.3.4 -a -m "v2.3.4 Release" git push upstream v2.3.4 ``` -5) Monitor Github actions to ensure it worked. +8) Monitor Github actions to ensure it worked. -6) Check nuget to see new package (wait a few minutes) +9) Check nuget to see new package (wait a few minutes) https://www.nuget.org/packages/Terminal.Gui -7) Add a new Release in Github: https://github.com/migueldeicaza/gui.cs/releases +10) Add a new Release in Github: https://github.com/migueldeicaza/gui.cs/releases ## Nuget https://www.nuget.org/packages/Terminal.Gui -When a new version tag is defined, and merged into master, a nuget package will be generated. +When a new version tag is defined, and merged into main, a nuget package will be generated. If the version is pre-release (includes a hyphen, e.g. `1.3.4-beta.5`) the Nuget package will be tagged as pre-release. diff --git a/Terminal.Gui/Terminal.Gui.csproj b/Terminal.Gui/Terminal.Gui.csproj index 61d819451..c2af91289 100644 --- a/Terminal.Gui/Terminal.Gui.csproj +++ b/Terminal.Gui/Terminal.Gui.csproj @@ -2,24 +2,24 @@ - TRACE;DEBUG_IDISPOSABLE - - - + + 1.6.1.0 + 1.6.1.0 + 1.6.1+Branch.fixes-1741-gitversion.Sha.cc04bb37f5c7684d45833dabd3f7e1ca9c53786f + 1.6.1 + + - - - + - True @@ -27,7 +27,6 @@ Strings.resx - ResXFileCodeGenerator @@ -35,12 +34,6 @@ - true - - - - v - net472;netstandard2.0;net6.0 Terminal.Gui Terminal.Gui @@ -57,7 +50,6 @@ Miguel de Icaza Application framework for creating modern console applications using .NET Terminal.Gui is a framework for creating console user interfaces - v1.6.0 * Adds ColorPicker control @@ -435,4 +427,4 @@ * Fixes #838. Added a Visible property to the View. (Thanks @bidsp!) - + \ No newline at end of file diff --git a/Terminal.sln b/Terminal.sln index 3a1e7e5a4..0f458fd0b 100644 --- a/Terminal.sln +++ b/Terminal.sln @@ -14,8 +14,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReactiveExample", "Reactive EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E143FB1F-0B88-48CB-9086-72CDCECFCD22}" ProjectSection(SolutionItems) = preProject + .gitignore = .gitignore CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md CONTRIBUTING.md = CONTRIBUTING.md + .github\workflows\dotnet-core.yml = .github\workflows\dotnet-core.yml .github\workflows\publish.yml = .github\workflows\publish.yml README.md = README.md EndProjectSection diff --git a/UICatalog/Properties/launchSettings.json b/UICatalog/Properties/launchSettings.json index 427554a49..5f83420e7 100644 --- a/UICatalog/Properties/launchSettings.json +++ b/UICatalog/Properties/launchSettings.json @@ -1,8 +1,7 @@ { "profiles": { "UICatalog": { - "commandName": "Project", - "commandLineArgs": "\"ProgressBar Styles\"" + "commandName": "Project" }, "UICatalog : -usc": { "commandName": "Project", diff --git a/UICatalog/UICatalog.cs b/UICatalog/UICatalog.cs index 381ab243d..222fbb7fa 100644 --- a/UICatalog/UICatalog.cs +++ b/UICatalog/UICatalog.cs @@ -166,7 +166,7 @@ namespace UICatalog { aboutMessage.AppendLine (@" | | __/ | | | | | | | | | | | (_| | || |__| | |_| | |"); aboutMessage.AppendLine (@" |_|\___|_| |_| |_| |_|_|_| |_|\__,_|_(_)_____|\__,_|_|"); aboutMessage.AppendLine (@""); - aboutMessage.AppendLine ($"Using Terminal.Gui Version: {FileVersionInfo.GetVersionInfo (typeof (Terminal.Gui.Application).Assembly.Location).ProductVersion}"); + aboutMessage.AppendLine ($"Using Terminal.Gui Version: {FileVersionInfo.GetVersionInfo (typeof (Terminal.Gui.Application).Assembly.Location).FileVersion}"); aboutMessage.AppendLine (@""); _menu = new MenuBar (new MenuBarItem [] { diff --git a/UICatalog/UICatalog.csproj b/UICatalog/UICatalog.csproj index 7f4338c3a..95742322f 100644 --- a/UICatalog/UICatalog.csproj +++ b/UICatalog/UICatalog.csproj @@ -1,23 +1,21 @@  - Exe net6.0 UICatalog.UICatalogApp - 1.0.0.0 + 1.6.1.0 8.0 + 1.6.1.0 + 1.6.1+Branch.fixes-1741-gitversion.Sha.cc04bb37f5c7684d45833dabd3f7e1ca9c53786f + 1.6.1 - TRACE - TRACE;DEBUG_IDISPOSABLE - - - + \ No newline at end of file diff --git a/UnitTests/UnitTests.csproj b/UnitTests/UnitTests.csproj index da4eb8b30..d65fa6011 100644 --- a/UnitTests/UnitTests.csproj +++ b/UnitTests/UnitTests.csproj @@ -1,19 +1,19 @@  - net6.0 false + 1.6.1.0 + 1.6.1.0 + 1.6.1+Branch.fixes-1741-gitversion.Sha.cc04bb37f5c7684d45833dabd3f7e1ca9c53786f + 1.6.1 - TRACE - TRACE;DEBUG_IDISPOSABLE - @@ -28,12 +28,10 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - True @@ -41,8 +39,7 @@ [UICatalog]* - - + @@ -54,5 +51,4 @@ False - - + \ No newline at end of file