Browse Source

housekeeping: Add Basic GitHub Actions Configuration (#11)

pull/10407/head 0.1.1
Artyom V. Gorchakov 5 years ago
committed by GitHub
parent
commit
73cd39be10
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 100
      .github/workflows/ci-build.yml
  2. 2
      LICENSE
  3. 18
      src/Directory.build.props
  4. 1
      src/XamlNameReferenceGenerator.Sandbox/XamlNameReferenceGenerator.Sandbox.csproj
  5. 1
      src/XamlNameReferenceGenerator.Tests/XamlNameReferenceGenerator.Tests.csproj
  6. 31
      src/XamlNameReferenceGenerator/Infrastructure/PhysicalFileDebugger.cs
  7. 3
      src/XamlNameReferenceGenerator/NameReferenceGenerator.cs
  8. 5
      src/XamlNameReferenceGenerator/XamlNameReferenceGenerator.csproj
  9. 11
      version.json

100
.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

2
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

18
src/Directory.build.props

@ -0,0 +1,18 @@
<Project>
<PropertyGroup>
<Product>XamlNameReferenceGenerator</Product>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/worldbeater/XamlNameReferenceGenerator/</PackageProjectUrl>
<Description>Generates typed x:Name references to Avalonia controls declared in XAML.</Description>
<PackageReleaseNotes>https://github.com/worldbeater/XamlNameReferenceGenerator/releases</PackageReleaseNotes>
<RepositoryUrl>https://github.com/worldbeater/XamlNameReferenceGenerator</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="3.3.37" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)..\LICENSE" Pack="true" PackagePath="LICENSE" />
</ItemGroup>
</Project>

1
src/XamlNameReferenceGenerator.Sandbox/XamlNameReferenceGenerator.Sandbox.csproj

@ -3,6 +3,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>net5</TargetFramework>
<LangVersion>preview</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.0-preview5" />

1
src/XamlNameReferenceGenerator.Tests/XamlNameReferenceGenerator.Tests.csproj

@ -3,6 +3,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>net5</TargetFramework>
<LangVersion>preview</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.8.0-3.final" />

31
src/XamlNameReferenceGenerator/Infrastructure/PhysicalFileDebugger.cs

@ -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<string> 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;
}
}
}
}

3
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 @@ namespace XamlNameReferenceGenerator
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)

5
src/XamlNameReferenceGenerator/XamlNameReferenceGenerator.csproj

@ -2,6 +2,8 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>preview</LangVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<IncludeBuildOutput>false</IncludeBuildOutput>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.8.0-3.final" PrivateAssets="all" />
@ -11,4 +13,7 @@
<Compile Link="XamlX\filename" Include="../../external/XamlX/src/XamlX/**/*.cs" />
<Compile Remove="../../external/XamlX/src/XamlX/**/SreTypeSystem.cs" />
</ItemGroup>
<ItemGroup>
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
</ItemGroup>
</Project>

11
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+$"
]
}
Loading…
Cancel
Save