diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml new file mode 100644 index 0000000..8a9d5f6 --- /dev/null +++ b/.github/workflows/build-and-test.yaml @@ -0,0 +1,34 @@ +name: Build and test + +env: + DOTNET_VERSION: '9.0.x' + PROJECT_NAME: src/Monobank.Core/Monobank.Core.csproj + TEST_PROJECT_NAME: src/Monobank.Tests/Monobank.Tests.csproj + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - name: Restore dependencies + run: dotnet restore ${{ env.PROJECT_NAME }} + + - name: Build the project + run: dotnet build ${{ env.PROJECT_NAME }} --configuration Release --no-restore + + - name: Test the project + run: dotnet test ${{ env.TEST_PROJECT_NAME }} --no-build --verbosity normal \ No newline at end of file diff --git a/.github/workflows/package.yaml b/.github/workflows/package.yaml new file mode 100644 index 0000000..f871e60 --- /dev/null +++ b/.github/workflows/package.yaml @@ -0,0 +1,37 @@ +name: Package and publish + +env: + DOTNET_VERSION: '9.0.x' + PROJECT_NAME: src/Monobank.Core/Monobank.Core.csproj + TEST_PROJECT_NAME: src/Monobank.Tests/Monobank.Tests.csproj + +on: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - name: Restore dependencies + run: dotnet restore ${{ env.PROJECT_NAME }} + + - name: Build the project + run: dotnet build ${{ env.PROJECT_NAME }} --configuration Release --no-restore + + - name: Test the project + run: dotnet test ${{ env.TEST_PROJECT_NAME }} --no-build --verbosity normal + + - name: Pack the project + run: dotnet pack ${{ env.PROJECT_NAME }} --configuration Release --no-restore --output ./publish + + - name: Push to the packages + run: dotnet nuget push ./publish/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json \ No newline at end of file diff --git a/src/MonobankClient.sln b/src/MonobankClient.sln index 30130d4..a5c03f0 100644 --- a/src/MonobankClient.sln +++ b/src/MonobankClient.sln @@ -13,6 +13,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution items", "Solution ..\README.md = ..\README.md EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "actions", "actions", "{AC20577B-F4B5-4986-9BBB-D294462F3998}" + ProjectSection(SolutionItems) = preProject + ..\.github\workflows\build-and-test.yaml = ..\.github\workflows\build-and-test.yaml + ..\.github\workflows\package.yaml = ..\.github\workflows\package.yaml + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -34,4 +40,7 @@ Global GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C319BAE9-149E-46C0-ABF6-40F639F75FD7} EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {AC20577B-F4B5-4986-9BBB-D294462F3998} = {C382ABF6-3EFD-4C3A-84D4-A2A9DABD6E3E} + EndGlobalSection EndGlobal