diff --git a/.github/actions/build-and-test/action.yml b/.github/actions/build-and-test/action.yml new file mode 100644 index 0000000..200e790 --- /dev/null +++ b/.github/actions/build-and-test/action.yml @@ -0,0 +1,23 @@ +name: Build and test +description: The action file for building and testing a .NET project. +author: a.eiji + +runs: + using: 'composite' + steps: + - name: set up dotnet core sdk + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.0.x' + + - name: restoring dependencies + run: dotnet restore --no-cache + shell: bash + + - name: build project + run: dotnet build --no-restore --configuration Release + shell: bash + + - name: run unit tests + run: dotnet test -c Release --no-restore --verbosity normal + shell: bash \ No newline at end of file diff --git a/.github/actions/create-and-push-artifact/action.yml b/.github/actions/create-and-push-artifact/action.yml new file mode 100644 index 0000000..35dd36d --- /dev/null +++ b/.github/actions/create-and-push-artifact/action.yml @@ -0,0 +1,32 @@ +name: Pack and publish nuget +description: Action for packing and publishing NuGet packages to the NuGet repository +author: a.eiji + +inputs: + nuget_api_key: + required: true + description: "nuget.org api key for publishing the nuget package" +runs: + using: 'composite' + + steps: + - name: Generate Version + id: get_next_version + uses: thenativeweb/get-next-version@main + + - name: create tag + if: ${{ steps.get_next_version.outputs.hasNextVersion == 'true' }} + run: | + git tag v${{ steps.get_next_version.outputs.version }} + git push origin v${{ steps.get_next_version.outputs.version }} + shell: bash + + - name: pack the nuget package + if: ${{ steps.get_next_version.outputs.hasNextVersion == 'true' }} + run: dotnet pack --configuration Release --no-build --output ./nupkg /p:PackageVersion=${{ steps.get_next_version.outputs.version }} + shell: bash + + - name: publish nuget package + if: ${{ steps.get_next_version.outputs.hasNextVersion == 'true' }} + run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ inputs.nuget_api_key }} --source https://api.nuget.org/v3/index.json --skip-duplicate + shell: bash \ No newline at end of file diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml new file mode 100644 index 0000000..f104502 --- /dev/null +++ b/.github/workflows/cicd.yml @@ -0,0 +1,25 @@ +name: Gitea.client cicd workflow + +on: + push: + pull_request: + branches: + - master + +jobs: + build-test-deploy: + runs-on: ubuntu-latest + steps: + - name: checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: build and test + uses: ./.github/actions/build-and-test/ + + - name: pack and push nuget + if: github.event_name == 'push' && github.base_ref == 'master' + uses: ./.github/actions/create-and-push-artifact/ + with: + nuget_api_key: ${{ secrets.NUGET_API_KEY }} \ No newline at end of file