Skip to content

Commit

Permalink
Merge pull request #1 from naminodarie/release/v1.0.0
Browse files Browse the repository at this point in the history
Release/v1.0.0
  • Loading branch information
kzrnm committed Nov 30, 2020
2 parents 199630f + 93e3046 commit 64300a7
Show file tree
Hide file tree
Showing 15 changed files with 250 additions and 152 deletions.
132 changes: 132 additions & 0 deletions .github/workflows/build-release-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: Build-Release-Publish

on:
push:
branches:
- master
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_NOLOGO: true
NUGET_XMLDOC_MODE: skip
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
WORKFLOW_VERSION_PROJ: AtCoderLibrary/AtCoderLibrary.csproj
WORKFLOW_BUILD_SLN: AtCoderLibrary.sln
GIT_COMMIT: ${{ github.sha }}

jobs:
get-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
is-new: ${{ steps.is-new-version.outputs.is-new }}
is-prerelease: ${{ steps.is-new-version.outputs.is-prerelease }}
steps:
- uses: actions/checkout@v2
- name: Get version
uses: naminodarie/get-net-sdk-project-versions-action@v1
id: get-version
with:
proj-path: ${{ env.WORKFLOW_VERSION_PROJ }}
- name: Check tag
uses: mukunku/tag-exists-action@v1.0.0
id: check-tag
with:
tag: v${{ steps.get-version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: is new version?
id: is-new-version
run: |
IS_PRE=false
IS_NEW=false
if [ "${{ steps.get-version.outputs.version }}" = "${GITHUB_REF#refs/tags/v}" ]; then
echo "create version tag event: $GITHUB_REF"
if [ "${{ steps.get-version.outputs.version-suffix }}" != "" ]; then
IS_PRE=true
fi
IS_NEW=true
elif [ "${{ steps.check-tag.outputs.exists }}" = "false" ]; then
if [ "${{ steps.get-version.outputs.version-suffix }}" = "" ]; then
echo "new version tag project: ${{ steps.get-version.outputs.version }}"
IS_NEW=true
fi
fi
echo "::set-output name=is-new::$IS_NEW"
echo "::set-output name=is-prerelease::$IS_PRE"
new-version-only:
runs-on: ubuntu-latest
needs: [get-version]
if: ${{ needs.get-version.outputs.is-new == 'true' }}
steps:
- run: echo "new-version"

build:
runs-on: ubuntu-latest
needs: [new-version-only]
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core SDK 3.1
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x
- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- uses: actions/cache@v2
with:
path: ${{ github.workspace }}/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Install dependencies
run: dotnet restore ${{ env.WORKFLOW_BUILD_SLN }}
- name: Build
run: dotnet build ${{ env.WORKFLOW_BUILD_SLN }} --no-restore -c Release
- name: Test
run: dotnet test ${{ env.WORKFLOW_BUILD_SLN }} --no-restore --verbosity normal -c Release
- uses: actions/upload-artifact@v1
with:
name: dist
path: bin/Packages/Release
release:
runs-on: ubuntu-latest
needs: [get-version, build]
steps:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: dist
path: dist
- name: Push tag
id: tag-version
uses: mathieudutour/github-tag-action@v5
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ needs.get-version.outputs.version }}
tag_prefix: "v"
- name: Create release
uses: ncipollo/release-action@v1
id: create-release
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.tag-version.outputs.new_tag }}
name: Version ${{ needs.get-version.outputs.version }}
body: ${{ steps.tag_version.outputs.changelog }}
artifacts: "./dist/*.nupkg"
prerelease: ${{ needs.get-version.outputs.is-prerelease }}
publish:
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: dist
path: dist
- name: Upload nuget
run: dotnet nuget push "./dist/*.nupkg" --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }}
6 changes: 5 additions & 1 deletion .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET SDK
- name: Setup .NET Core SDK 3.1
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x
- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- uses: actions/cache@v2
with:
path: ${{ github.workspace }}/.nuget/packages
Expand Down
3 changes: 2 additions & 1 deletion AtCoderLibrary.Test/AtCoderLibrary.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>

<IsPackable>false</IsPackable>
<RootNamespace>AtCoder</RootNamespace>
</PropertyGroup>
Expand All @@ -12,6 +11,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Base32768" Version="1.0.5" />
<PackageReference Include="SourceExpander.Core" Version="2.2.0" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="MersenneTwister" Version="1.0.6" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
Expand Down
23 changes: 0 additions & 23 deletions AtCoderLibrary.Test/ExpanderTest.cs

This file was deleted.

52 changes: 52 additions & 0 deletions AtCoderLibrary.Test/SourceExpanderTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Text.Json;
using FluentAssertions;
using Kzrnm.Convert.Base32768;
using Xunit;

namespace AtCoder.Embedding
{
public class SourceExpanderTest
{
private readonly Dictionary<string, string> assemblyMetadata
= typeof(IntFenwickTree).Assembly
.GetCustomAttributes<AssemblyMetadataAttribute>()
.ToDictionary(attr => attr.Key, attr => attr.Value);

[Fact]
public void LanguageVersion()
=> assemblyMetadata.Should().ContainKey("SourceExpander.EmbeddedLanguageVersion")
.WhichValue.Should().Be("8.0");

[Fact]
public async void EmbeddedSource()
{
var embeddedSourceGZipJson = Base32768.Decode(assemblyMetadata.Should().ContainKey("SourceExpander.EmbeddedSourceCode.GZipBase32768").WhichValue);
using var msIn = new MemoryStream(embeddedSourceGZipJson);
using var gzipStream = new GZipStream(msIn, CompressionMode.Decompress);
var embeddedSource = await JsonSerializer.DeserializeAsync<SourceFileInfo[]>(gzipStream);
embeddedSource.Select(s => s.FileName)
.Should()
.OnlyContain(name => name.StartsWith("AtCoderLibrary>"));
embeddedSource.SelectMany(s => s.TypeNames)
.Should()
.Contain(new[] {
"AtCoder.IArithmeticOperator<T>",
"AtCoder.FenwickTree<TValue, TOp>",
});
}

private class SourceFileInfo
{
public string FileName { get; set; }
public IEnumerable<string> TypeNames { get; set; }
//public IEnumerable<string> Usings { get; set; }
//public IEnumerable<string> Dependencies { get; set; }
//public string CodeBody { get; set; }
}
}
}
11 changes: 6 additions & 5 deletions AtCoderLibrary/AtCoderLibrary.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
<RootNamespace>AtCoder</RootNamespace>
<OutputType>Library</OutputType>
<LangVersion>8</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>

<EnableSourceLink>true</EnableSourceLink>
<PackageId>ac-library-csharp</PackageId>
<Version>0.4.0</Version>
<Description>ac-library ported to C#.</Description>
<Version>1.0.0</Version>
<Description>C# port of ac-library</Description>
<GeneratePackageOnBuild Condition="'$(Configuration)' == 'Release'">true</GeneratePackageOnBuild>
<PackageOutputPath>$(MSBuildThisFileDirectory)..\bin\Packages\$(Configuration)\</PackageOutputPath>

<Authors>naminodarie</Authors>
<PackageTags>ac-library-csharp</PackageTags>
Expand All @@ -35,11 +36,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="SourceExpander.Embedder" Version="2.1.1">
<PackageReference Include="SourceExpander.Embedder" Version="2.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="SourceExpander.Core" Version="2.1.1" />
<PackageReference Include="SourceExpander.Core" Version="2.2.0" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.7.0" />
</ItemGroup>

Expand Down
14 changes: 0 additions & 14 deletions Sample.Usage/Expander/Program.cs

This file was deleted.

16 changes: 0 additions & 16 deletions Sample.Usage/Expander/Sample.Expander.csproj

This file was deleted.

30 changes: 0 additions & 30 deletions Sample.Usage/Generator/EntryPoint.cs

This file was deleted.

17 changes: 0 additions & 17 deletions Sample.Usage/Generator/Program.cs

This file was deleted.

23 changes: 0 additions & 23 deletions Sample.Usage/Generator/Sample.Generator.csproj

This file was deleted.

9 changes: 3 additions & 6 deletions Sample.Usage/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
`ac-library-csharp` の使用方法です。
# Usage of `ac-library-csharp`

## Generator(recommend)

Source Generatorsを使用してライブラリに埋め込んだソースコードを展開します。
## Installation

```
Install-Package Microsoft.Net.Compilers.Toolset
Install-Package SourceExpander.Generator
Install-Package SourceExpander
Install-Package ac-library-csharp
```

Expand Down
Loading

0 comments on commit 64300a7

Please sign in to comment.