From 73cd39be109c6cf2a596f7cf13d009aacad1c251 Mon Sep 17 00:00:00 2001 From: "Artyom V. Gorchakov" Date: Sun, 1 Nov 2020 10:12:46 +0300 Subject: [PATCH] housekeeping: Add Basic GitHub Actions Configuration (#11) --- .github/workflows/ci-build.yml | 100 ++++++++++++++++++ LICENSE | 2 +- src/Directory.build.props | 18 ++++ .../XamlNameReferenceGenerator.Sandbox.csproj | 1 + .../XamlNameReferenceGenerator.Tests.csproj | 1 + .../Infrastructure/PhysicalFileDebugger.cs | 31 ------ .../NameReferenceGenerator.cs | 3 +- .../XamlNameReferenceGenerator.csproj | 5 + version.json | 11 ++ 9 files changed, 138 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/ci-build.yml create mode 100644 src/Directory.build.props delete mode 100644 src/XamlNameReferenceGenerator/Infrastructure/PhysicalFileDebugger.cs create mode 100644 version.json diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml new file mode 100644 index 0000000..7a3808b --- /dev/null +++ b/.github/workflows/ci-build.yml @@ -0,0 +1,100 @@ +name: Build + +on: + push: + branches: [ main ] + pull_request: + types: [opened, synchronize, reopened, closed] + branches: [ main ] + +env: + configuration: Release + productNamespacePrefix: "XamlNameReferenceGenerator" + +jobs: + build: + runs-on: windows-latest + outputs: + nbgv: ${{ steps.nbgv.outputs.SemVer2 }} + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + submodules: 'recursive' + + - name: Install .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 5.0.100-rc.2.20479.15 + + - name: NBGV + id: nbgv + uses: dotnet/nbgv@master + with: + setAllVars: true + + - name: NuGet Restore + run: dotnet restore + working-directory: src + + - name: Add MSBuild to PATH + uses: microsoft/setup-msbuild@v1 + + - name: Build + run: dotnet build --configuration ${{ env.configuration }} + working-directory: src + + - name: Run Unit Tests and Generate Coverage + uses: glennawatson/coverlet-msbuild@v1 + with: + project-files: 'src/**/*.Tests.csproj' + no-build: true + exclude-filter: '[${{env.productNamespacePrefix}}.*.Tests.*]*' + include-filter: '[${{env.productNamespacePrefix}}*]*' + output-format: cobertura + output: '../../artifacts/' + configuration: ${{ env.configuration }} + working-directory: src + + - name: Create NuGet Artifacts + uses: actions/upload-artifact@master + with: + name: nuget + path: '**/*.nupkg' + + release: + runs-on: ubuntu-latest + needs: build + if: contains(github.event.pull_request.labels.*.name, 'release') && github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Download NuGet Packages + uses: actions/download-artifact@v2 + with: + name: nuget + + - name: Changelog + uses: glennawatson/ChangeLog@v1 + id: changelog + + - name: Create Release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: ${{ needs.build.outputs.nbgv }} + release_name: ${{ needs.build.outputs.nbgv }} + body: | + ${{ steps.changelog.outputs.commitLog }} + + - name: NuGet Push + env: + NUGET_AUTH_TOKEN: ${{ secrets.NUGET_API_KEY }} + SOURCE_URL: https://api.nuget.org/v3/index.json + run: | + dotnet nuget push -s ${{ env.SOURCE_URL }} -k ${{ env.NUGET_AUTH_TOKEN }} **/*.nupkg diff --git a/LICENSE b/LICENSE index d4e7454..edf33d1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 Artyom V. Gorchakov +Copyright (c) 2020 Artyom V. Gorchakov and Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Directory.build.props b/src/Directory.build.props new file mode 100644 index 0000000..8a5a1d8 --- /dev/null +++ b/src/Directory.build.props @@ -0,0 +1,18 @@ + + + XamlNameReferenceGenerator + MIT + https://github.com/worldbeater/XamlNameReferenceGenerator/ + Generates typed x:Name references to Avalonia controls declared in XAML. + https://github.com/worldbeater/XamlNameReferenceGenerator/releases + https://github.com/worldbeater/XamlNameReferenceGenerator + git + true + + + + + + + + diff --git a/src/XamlNameReferenceGenerator.Sandbox/XamlNameReferenceGenerator.Sandbox.csproj b/src/XamlNameReferenceGenerator.Sandbox/XamlNameReferenceGenerator.Sandbox.csproj index 3a0161f..64a75d8 100644 --- a/src/XamlNameReferenceGenerator.Sandbox/XamlNameReferenceGenerator.Sandbox.csproj +++ b/src/XamlNameReferenceGenerator.Sandbox/XamlNameReferenceGenerator.Sandbox.csproj @@ -3,6 +3,7 @@ Exe net5 preview + false diff --git a/src/XamlNameReferenceGenerator.Tests/XamlNameReferenceGenerator.Tests.csproj b/src/XamlNameReferenceGenerator.Tests/XamlNameReferenceGenerator.Tests.csproj index 5b1aa47..d67d7b0 100644 --- a/src/XamlNameReferenceGenerator.Tests/XamlNameReferenceGenerator.Tests.csproj +++ b/src/XamlNameReferenceGenerator.Tests/XamlNameReferenceGenerator.Tests.csproj @@ -3,6 +3,7 @@ Exe net5 preview + false diff --git a/src/XamlNameReferenceGenerator/Infrastructure/PhysicalFileDebugger.cs b/src/XamlNameReferenceGenerator/Infrastructure/PhysicalFileDebugger.cs deleted file mode 100644 index 68b70c5..0000000 --- a/src/XamlNameReferenceGenerator/Infrastructure/PhysicalFileDebugger.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.IO; - -namespace XamlNameReferenceGenerator.Infrastructure -{ - internal class PhysicalFileDebugger - { - private const string DefaultPath = @"C:\Users\prizr\Documents\GitHub\XamlNameReferenceGenerator\debug.txt"; - private readonly string _path; - - public PhysicalFileDebugger(string path = DefaultPath) => _path = path; - - public string Debug(Func function) - { - if (File.Exists(_path)) - File.Delete(_path); - - try - { - var sourceCode = function(); - File.WriteAllText(_path, sourceCode); - return sourceCode; - } - catch (Exception exception) - { - File.WriteAllText(_path, exception.ToString()); - throw; - } - } - } -} \ No newline at end of file diff --git a/src/XamlNameReferenceGenerator/NameReferenceGenerator.cs b/src/XamlNameReferenceGenerator/NameReferenceGenerator.cs index 5549ac9..dff5fb4 100644 --- a/src/XamlNameReferenceGenerator/NameReferenceGenerator.cs +++ b/src/XamlNameReferenceGenerator/NameReferenceGenerator.cs @@ -27,7 +27,6 @@ namespace XamlNameReferenceGenerator sealed class GenerateTypedNameReferencesAttribute : Attribute { } } "; - private static readonly PhysicalFileDebugger Debugger = new PhysicalFileDebugger(); private static readonly SymbolDisplayFormat SymbolDisplayFormat = new SymbolDisplayFormat( typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces, genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters | @@ -76,7 +75,7 @@ public void Execute(GeneratorExecutionContext context) try { - var sourceCode = Debugger.Debug(() => GenerateSourceCode(xamlParser, typeSymbol, relevantXamlFile)); + var sourceCode = GenerateSourceCode(xamlParser, typeSymbol, relevantXamlFile); context.AddSource($"{typeSymbol.Name}.g.cs", SourceText.From(sourceCode, Encoding.UTF8)); } catch (Exception exception) diff --git a/src/XamlNameReferenceGenerator/XamlNameReferenceGenerator.csproj b/src/XamlNameReferenceGenerator/XamlNameReferenceGenerator.csproj index 6b07365..c8c886b 100644 --- a/src/XamlNameReferenceGenerator/XamlNameReferenceGenerator.csproj +++ b/src/XamlNameReferenceGenerator/XamlNameReferenceGenerator.csproj @@ -2,6 +2,8 @@ netstandard2.0 preview + true + false @@ -11,4 +13,7 @@ + + + \ No newline at end of file diff --git a/version.json b/version.json new file mode 100644 index 0000000..b93e992 --- /dev/null +++ b/version.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", + "version": "0.1", + "assemblyVersion": { + "precision": "revision" + }, + "publicReleaseRefSpec": [ + "^refs/heads/main$", + "^refs/heads/v\\d+\\.\\d+$" + ] +} \ No newline at end of file