forked from Testura/Testura.Code
-
Notifications
You must be signed in to change notification settings - Fork 1
118 lines (99 loc) · 4.06 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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 ]
pull_request:
branches: [ stable, productive, deploy ]
# 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 powershell
- name: Setup powershell
run: sh ./.github/scripts/install-powershell.sh
# setup dotnet with dotnet core 3.1
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x' # SDK Version to use.
# setup dotnet with .NET 6.0
- name: Setup .NET 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x' # SDK Version to use.
# 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'
run: pwsh -File ./.github/scripts/pack-files.ps1 -path './*'
# Artifact for testing purpose
- name: upload artifacts
uses: actions/upload-artifact@v2
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/[email protected]
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