From c12b53d6b0e2272766e59ca91971b7b690c8df51 Mon Sep 17 00:00:00 2001 From: Matthew O'Connor Date: Tue, 1 Oct 2024 10:46:20 -0600 Subject: [PATCH 1/4] Test and release. --- .github/workflows/build.yml | 19 +++++++++++++++++++ .github/workflows/release.yml | 24 ++++++++++++++++++++++++ Xledger.Sql.Test/Xledger.Sql.Test.csproj | 4 ++++ 3 files changed, 47 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..b0a756a3 --- /dev/null +++ b/.github/workflows/build.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..aefab9db --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,24 @@ +name: Upload .NET package + +on: + release: + types: [created] + +jobs: + release: + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + - run: dotnet build --configuration Release Xledger.Sql + - run: dotnet pack --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 + # - run: dotnet nuget push Xledger.Sql/bin/Release/*.nupkg --api-key "$NUGET_API_KEY" --source https://apiint.nugettest.org/v3/index.json + env: + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} diff --git a/Xledger.Sql.Test/Xledger.Sql.Test.csproj b/Xledger.Sql.Test/Xledger.Sql.Test.csproj index fc94c3db..b43b5d69 100644 --- a/Xledger.Sql.Test/Xledger.Sql.Test.csproj +++ b/Xledger.Sql.Test/Xledger.Sql.Test.csproj @@ -20,6 +20,10 @@ + + + + From e4422ae7a7db27446ac0f12cb948eceab2d55099 Mon Sep 17 00:00:00 2001 From: Matthew O'Connor Date: Tue, 1 Oct 2024 12:19:33 -0600 Subject: [PATCH 2/4] Include Git commit hash in assembly. --- Xledger.Sql/Xledger.Sql.csproj | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Xledger.Sql/Xledger.Sql.csproj b/Xledger.Sql/Xledger.Sql.csproj index 8b5bc3f7..b7645aaf 100644 --- a/Xledger.Sql/Xledger.Sql.csproj +++ b/Xledger.Sql/Xledger.Sql.csproj @@ -16,6 +16,20 @@ README.md + + + + + + + + + <_Parameter1>SourceRevisionId + <_Parameter2>$(SourceRevisionId) + + + + From f2c8cbbf313438f69aced265ed852bd2c6597fe3 Mon Sep 17 00:00:00 2001 From: Matthew O'Connor Date: Tue, 1 Oct 2024 14:14:59 -0600 Subject: [PATCH 3/4] Derive release version number from Git tag. --- .github/workflows/release.yml | 24 ++++++++++++++++++------ README.md | 4 ++-- Xledger.Sql/Xledger.Sql.csproj | 2 -- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index aefab9db..541938e8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,15 +10,27 @@ jobs: permissions: packages: write contents: read + env: + version: ${{ github.event.release.tag_name }} steps: - - uses: actions/checkout@v4 - - uses: actions/setup-dotnet@v4 + - name: Checkout source + uses: actions/checkout@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v4 with: dotnet-version: 8.0.x - - run: dotnet build --configuration Release Xledger.Sql - - run: dotnet pack --configuration Release Xledger.Sql + - 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 - # - run: dotnet nuget push Xledger.Sql/bin/Release/*.nupkg --api-key "$NUGET_API_KEY" --source https://apiint.nugettest.org/v3/index.json + # - 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 env: NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} diff --git a/README.md b/README.md index b352e002..2d97e41a 100644 --- a/README.md +++ b/README.md @@ -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 + ## Running the Tests diff --git a/Xledger.Sql/Xledger.Sql.csproj b/Xledger.Sql/Xledger.Sql.csproj index b7645aaf..c0e94a8e 100644 --- a/Xledger.Sql/Xledger.Sql.csproj +++ b/Xledger.Sql/Xledger.Sql.csproj @@ -6,8 +6,6 @@ MIT Xledger.Sql Xledger.Sql - 1.0.1 - Isak Sky, Matthew O'Connor Xledger Utilities to aid in the analysis, generation, and transformation of Transact SQL. From abcc737977125ee4a7142517cf794c1535508be0 Mon Sep 17 00:00:00 2001 From: Matthew O'Connor Date: Tue, 1 Oct 2024 16:57:45 -0600 Subject: [PATCH 4/4] Use production nuget source. Co-authored-by: Isak Sky --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 541938e8..02861aea 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,6 +31,6 @@ jobs: # 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 + run: dotnet nuget push Xledger.Sql/bin/Release/*.nupkg --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json env: NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}