Skip to content

Commit

Permalink
build/test and package/publish actions
Browse files Browse the repository at this point in the history
  • Loading branch information
maisak committed Jan 5, 2025
1 parent 358b24e commit 6d9573c
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
@@ -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
37 changes: 37 additions & 0 deletions .github/workflows/package.yaml
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions src/MonobankClient.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 6d9573c

Please sign in to comment.