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

Test and release. #5

Merged
merged 4 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
19 changes: 19 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Build .NET assemblies and test

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- run: dotnet restore
- run: dotnet build --no-restore
- run: dotnet test --no-build --verbosity normal
36 changes: 36 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Upload .NET package

on:
release:
types: [created]

jobs:
release:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
env:
version: ${{ github.event.release.tag_name }}
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Build and pack
run: |
echo $version
echo ${version:1}
case $version in v*) true;; *) echo "Git tag must start with a 'v'"; false;; esac
export version=${version:1}
echo $version
dotnet build /p:VersionPrefix=$version --configuration Release Xledger.Sql
dotnet pack /p:VersionPrefix=$version --configuration Release Xledger.Sql
# https://learn.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package-using-the-dotnet-cli
# - run: dotnet nuget push Xledger.Sql/bin/Release/*.nupkg --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json
- name: Push package to nuget
run: dotnet nuget push Xledger.Sql/bin/Release/*.nupkg --api-key "$NUGET_API_KEY" --source https://apiint.nugettest.org/v3/index.json
oconnor0 marked this conversation as resolved.
Show resolved Hide resolved
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Xledger.Sql provides tools for analyzing and transforming Transact SQL queries.

The tests in [Xledger.Sql.Test](./Xledger.Sql.Test) demonstrate how to use this library.

## Testing Locally
<!-- ## Testing Locally

To generate a new NuGet package to verify that the package is sane.

Expand All @@ -29,7 +29,7 @@ nuget init Xledger.Sql\bin\Debug c:\packages;
3. Update the project that depends on Xledger.Sql.
```powershell
dotnet add package Xledger.Sql --source c:\packages --prerelease
```
``` -->

## Running the Tests

Expand Down
4 changes: 4 additions & 0 deletions Xledger.Sql.Test/Xledger.Sql.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net48'">
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="17.11.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Xledger.Sql\Xledger.Sql.csproj" />
</ItemGroup>
Expand Down
16 changes: 14 additions & 2 deletions Xledger.Sql/Xledger.Sql.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RootNamespace>Xledger.Sql</RootNamespace>
<AssemblyName>Xledger.Sql</AssemblyName>
<VersionPrefix>1.0.1</VersionPrefix>
<!-- <VersionSuffix>rc0</VersionSuffix> -->
<Authors>Isak Sky, Matthew O'Connor</Authors>
<Company>Xledger</Company>
<Description>Utilities to aid in the analysis, generation, and transformation of Transact SQL.</Description>
Expand All @@ -16,6 +14,20 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<!-- Extract Git commit hash so it will be added to InformationalVersion. -->
<!-- https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props -->
<Target Name="SetSourceRevisionId" BeforeTargets="InitializeSourceControlInformation">
<Exec Command="git describe --long --always --dirty --exclude='*' --abbrev=40" ConsoleToMSBuild="True" StandardOutputImportance="Low" IgnoreExitCode="False">
<Output PropertyName="SourceRevisionId" TaskParameter="ConsoleOutput" />
</Exec>
<ItemGroup>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>SourceRevisionId</_Parameter1>
<_Parameter2>$(SourceRevisionId)</_Parameter2>
</AssemblyAttribute>
</ItemGroup>
</Target>

<ItemGroup>
<None Include="../LICENSE" Pack="true" PackagePath="/" />
<None Include="../README.md" Pack="true" PackagePath="/" />
Expand Down