Skip to content

Refactor Code

Refactor Code #18

Workflow file for this run

name: CI
on:
pull_request:
types: [opened, reopened, edited, synchronize]
paths-ignore:
- "**/*.md"
- "**/*.gitignore"
- "**/*.gitattributes"
jobs:
Run-Lint:
runs-on: ubuntu-latest
env:
github-token: '${{ secrets.GITHUB_TOKEN }}'
steps:
- name: Step-01 Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Step-02 Lint Code Base
uses: github/super-linter@v4
env:
VALIDATE_ALL_CODEBASE: false
FILTER_REGEX_INCLUDE: .*src/.*
DEFAULT_BRANCH: master
GITHUB_TOKEN: '${{ env.github-token }}'
Build-Test:
runs-on: ubuntu-latest
outputs:
release_Version: ${{ steps.gitversion.outputs.MajorMinorPatch }}
beta_Version: ${{ steps.gitversion.outputs.nuGetVersion }}
branchName: ${{ steps.gitversion.outputs.branchName }}
env:
working-directory: /home/runner/work/Schemio.Object/Schemio.Object
steps:
- name: Step-01 Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.7
with:
versionSpec: 5.x
- name: Step-02 Check out Code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Step-03 Calculate Version
id: gitversion
uses: gittools/actions/gitversion/execute@v0.9.7
with:
useConfigFile: true
- name: Step-04 Install .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Step-05 Restore dependencies
run: dotnet restore
working-directory: '${{ env.working-directory }}'
- name: Step-06 Build Version (Beta)
if: ${{ !startsWith(github.head_ref, 'release/')}}
run: dotnet build --configuration Release --no-restore -p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersion }}
working-directory: '${{ env.working-directory }}'
- name: Step-06 Build Version (Release)
if: ${{ startsWith(github.head_ref, 'release/')}}
run: dotnet build --configuration Release --no-restore -p:PackageVersion=${{ steps.gitversion.outputs.MajorMinorPatch }}
working-directory: '${{ env.working-directory }}'
- name: Step-07 Test Solution
run: dotnet test --configuration Release --no-build --no-restore --verbosity normal
working-directory: '${{ env.working-directory }}'
- name: Step-08 Upload Build Artifacts
uses: actions/upload-artifact@v3
with:
name: build-artifact
path: ${{env.working-directory}}
retention-days: 1
Package:
needs: [Build-Test]
runs-on: ubuntu-latest
outputs:
semVersion: ${{ needs.Build-Release.outputs.semVersion }}
env:
github-token: '${{ secrets.GITHUB_TOKEN }}'
nuget-token: '${{ secrets.NUGET_API_KEY }}'
working-directory: /home/runner/work/Schemio.Object/Schemio.Object
steps:
- name: Step-01 Retrieve Build Artifacts
uses: actions/download-artifact@v3
with:
name: build-artifact
path: ${{env.working-directory}}
- name: Step-02 Install Github Packages
run: dotnet tool install gpr --global
- name: Step-03 Publish to Github Packages
run: find -name "*.nupkg" -print -exec gpr push -k ${{env.github-token}} {} \;
- name: Step-03 Release to Nuget Org
if: ${{ startsWith(github.head_ref, 'release/')}}
run: dotnet nuget push ${{env.working-directory}}/src/Schemio.Object/bin/Release/*.nupkg --skip-duplicate --api-key ${{ env.nuget-token }} --source https://api.nuget.org/v3/index.json
Release:
name: Release to Nuget
needs: [Package]
if: ${{ startsWith(github.head_ref, 'release/')}}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# - name: Setup dotnet
# uses: actions/setup-dotnet@v1
# with:
# dotnet-version: '6.0.x'
# Publish
- name: publish Schemio.Object package
id: publish_nuget
uses: Rebel028/publish-nuget@v2.8.0
with:
# Filepath of the project to be packaged, relative to root of repository
PROJECT_FILE_PATH: Schemio.Object/Schemio.Object.csproj
# NuGet package id, used for version detection & defaults to project name
PACKAGE_NAME: Schemio.Object
# Filepath with version info, relative to root of repository & defaults to PROJECT_FILE_PATH
# VERSION_FILE_PATH: Directory.Build.props
# Regex pattern to extract version info in a capturing group
# VERSION_REGEX: ^\s*<Version>(.*)<\/Version>\s*$
# Useful with external providers like Nerdbank.GitVersioning, ignores VERSION_FILE_PATH & VERSION_REGEX
# VERSION_STATIC: 1.0.0
# Flag to toggle git tagging, enabled by default
# TAG_COMMIT: true
# Format of the git tag, [*] gets replaced with actual version
# TAG_FORMAT: v*
# API key to authenticate with NuGet server, or a token, issued for GITHUB_USER if you use GPR
# NUGET_KEY: ${{secrets.NUGET_API_KEY}}
# NuGet server uri hosting the packages, defaults to https://api.nuget.org
# NUGET_SOURCE: https://api.nuget.org
# Flag to toggle pushing symbols along with nuget package to the server, disabled by default
# INCLUDE_SYMBOLS: false
# Flag to throw an error when trying to publish an existing version of a package
# THOW_ERROR_IF_VERSION_EXISTS: false
# Flag to add the `--no-build` option to the `dotnet pack` command. Enabled by default.
# PACK_NO_BUILD: true