Skip to content

Add CI and Start yaml #6

Add CI and Start yaml

Add CI and Start yaml #6

Workflow file for this run

name: .NET Core Build and Publish
on:
push:
branches: master
pull_request:
branches: master
env:
NETCORE_VERSION: '8.0.x'
MAJOR_MINOR_VERSION: 1.0.
OPENAPI_GENERATOR_IMAGE: openapitools/openapi-generator-cli
CSHARP_TARGET_FRAMEWORK: netstandard2.0
CSHARP_CLIENT_NAMESPACE: Agoda.Gitlab.Client
SOLUTION_FILE: $CSHARP_CLIENT_NAMESPACE.sln
jobs:
build:
name: Build Package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core SDK ${{ env.NETCORE_VERSION }}
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.NETCORE_VERSION }}
- name: Generate
run: |
cat << EOF > api-client-gen-config.yml
packageName: ${{ env.CSHARP_CLIENT_NAMESPACE }}
packageVersion: ${{ env.MAJOR_MINOR_VERSION }}${{ github.run_number }}
targetFramework: "${{ env.CSHARP_TARGET_FRAMEWORK }}"
netCoreProjectFile: true
optionalAssemblyInfo: false
EOF
pwd
docker run --network host -v '$(pwd):/work' -w '/work' ${{ env.OPENAPI_GENERATOR_IMAGE }} generate -i gitlab.yaml -g csharp -c api-client-gen-config.yml -o .
ls
- name: Restore
run: dotnet restore ${{ env.SOLUTION_FILE }}
- name: Build
run: dotnet build ${{ env.SOLUTION_FILE }} --configuration Debug --no-restore
- name: Pack
run: dotnet pack ${{ env.SOLUTION_FILE }} --configuration Debug -o finalpackage -p:PackageVersion=${{ env.MAJOR_MINOR_VERSION }}${{ github.run_number }}
- name: Publish artifact
uses: actions/upload-artifact@master
with:
name: nupkg
path: finalpackage
deploy:
needs: build
if: github.ref == 'refs/heads/main'
name: Deploy Packages
runs-on: ubuntu-latest
steps:
- name: Download Package artifact
uses: actions/download-artifact@master
with:
name: nupkg
path: ./nupkg
- name: Setup NuGet
uses: NuGet/setup-nuget@v1.0.5
with:
nuget-api-key: ${{ secrets.NUGET_API_KEY }}
nuget-version: latest
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.NETCORE_VERSION }}
- name: Push to NuGet
run: dotnet nuget push nupkg/**/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://nuget.org --skip-duplicate