Update the ci #172
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
# Controls when the action will run. | |
on: | |
# Triggers the workflow on push or pull request events but only for the develop branch | |
push: | |
branches: [ stable, productive, deploy, develop, master ] | |
pull_request: | |
branches: [ stable, productive, deploy, develop, master ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "build" | |
build: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Set environment variables | |
env: | |
isProductive: ${{ github.ref == 'refs/heads/productive' }} | |
isDeploy: ${{ github.ref == 'refs/heads/deploy' }} | |
isStable: ${{ github.ref == 'refs/heads/stable' }} | |
isPush: ${{ github.event_name == 'push' }} | |
debug: false | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Set dynamic environment variables | |
- name: Set dynamic environment variables | |
run: | | |
isAlpha=${{ env.isProductive == 'false' && env.isDeploy == 'false'}} | |
publish=${{ env.isPush == 'true' && env.isProductive == 'false' && env.isDeploy == 'false'}} | |
suffix="${{ (env.isProductive == 'false' && env.isDeploy == 'false' && '-alpha') || (env.isProductive == 'false' && env.isDeploy == 'true' && '-beta') || '' }}" | |
echo "isAlpha=$isAlpha" >> $GITHUB_ENV | |
echo "publish=$publish" >> $GITHUB_ENV | |
echo "suffix=$suffix" >> $GITHUB_ENV | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 #to ensure to retrieve everything for version lookup | |
lfs: true | |
# setup dotnet with .NET 7.0 | |
- name: Setup .NET 7.0 | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '7.0.x' | |
# Print current suffix | |
- name: Print suffix | |
run: echo "${{env.suffix}}" | |
# Parse LitGit templates | |
- name: Set Version Suffix | |
uses: jvbsl/litgit-action@master | |
id: litgit | |
with: | |
templates: '**/*.template' | |
parameters: '-p VERSION_ADDITIONAL="${{env.suffix}}" -c ./.github/configs/**/*.config' | |
# Restore all dependecies | |
- name: Restore dependencies | |
run: dotnet restore | |
# Build the hole solution | |
- name: Build | |
run: dotnet build -c Release --no-restore | |
# Run Unit tests | |
- name: Test | |
run: dotnet test -c Release --no-build --verbosity normal | |
# Create nupkg | |
- name: Pack extension | |
if: env.isPush == 'true' || env.debug == 'true' | |
run: ./.github/scripts/pack-files.ps1 -path './*' | |
shell: pwsh | |
# Artifact for testing purpose | |
- name: upload artifacts | |
uses: actions/upload-artifact@v4 | |
if: env.debug == 'true' | |
with: | |
name: test-result | |
path: '**/*.nupkg' | |
# Setup Nuget | |
- name: Setup NuGet.exe | |
if: env.publish == 'true' | |
# You may pin to the exact commit or the version. | |
# uses: NuGet/setup-nuget@04b0c2b8d1b97922f67eca497d7cf0bf17b8ffe1 | |
uses: NuGet/setup-nuget@v2 | |
with: | |
# NuGet version to install. Can be `latest`, `preview`, a concrete version like `5.3.1`, or a semver range specifier like `5.x`. | |
# nuget-version: # optional, default is latest | |
# NuGet API Key to configure. | |
nuget-api-key: ${{secrets.NUGET_API_KEY}} | |
# Source to scope the NuGet API Key to. | |
# nuget-api-key-source: # optional | |
# Push nuget packages | |
- name: Publish packages | |
if: env.publish == 'true' | |
run: nuget push "**/*.nupkg" -src https://api.nuget.org/v3/index.json |