-
Notifications
You must be signed in to change notification settings - Fork 32
67 lines (67 loc) · 3.24 KB
/
ci-cd.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
name: OData.QueryBuilder
on: push
env:
DOTNET_VERSION: '3.1.x'
jobs:
ci:
name: build&test-${{matrix.os}}
runs-on: ${{ matrix.os }}
environment: ci-cd
strategy:
matrix:
#os: [ubuntu-latest, windows-latest, macOS-latest]
os: [ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup .NET SDK ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build -c ${{ vars.CONFIGURATION }} --no-restore
- name: Test
run: dotnet test -c ${{ vars.CONFIGURATION }} --no-build
- name: Coveralls
run: |
dotnet minicover instrument
dotnet minicover reset
dotnet test -c ${{ vars.CONFIGURATION }} --no-build
dotnet minicover uninstrument
dotnet minicover report
# dotnet minicover coverallsreport --service-name "github-actions" --service-job-id ${{ vars.GITHUB_ACTION }}
cd:
needs: ci
if: github.ref == 'refs/heads/feature/migrate-to-github-actions'
name: release
runs-on: ubuntu-latest
environment: ci-cd
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create tag
id: create_tag
run: |
git fetch --tags --force &> /dev/null
PR_TITLE=$(git log -1 --pretty='%f')
LAST_TAG=$(echo $(git describe --tags $(git rev-list --tags --max-count=1)) | cut -d'v' -f 2)
CURRENT_MAJOR=$(echo $LAST_TAG | cut -d. -f 1)
CURRENT_MINOR=$(echo $LAST_TAG | cut -d. -f 2)
CURRENT_PATCH=$(echo $(echo $LAST_TAG | cut -d. -f 3) | cut -d- -f 1)
RC=$(echo $(echo $LAST_TAG | cut -d. -f 3) | cut -d- -f 2)
MAJOR=$(([ "$RC" == "rc" ] && echo $CURRENT_MAJOR) || ([ "$(echo $PR_TITLE | grep -oP 'release')" == "release" ] && echo $(($CURRENT_MAJOR+1))) || echo $CURRENT_MAJOR)
MINOR=$(([ "$RC" == "rc" ] && echo $CURRENT_MINOR) || ([ "$(echo $PR_TITLE | grep -oP 'release')" == "release" ] && echo 0) || ([ "$(echo $PR_TITLE | grep -oP 'feature')" == "feature" ] && echo $(($CURRENT_MINOR+1))) || echo $CURRENT_MINOR)
PATCH=$(([ "$RC" == "rc" ] && echo $CURRENT_PATCH) || ([ "$(echo $PR_TITLE | grep -oP 'release')" == "release" ] && echo 0) || ([ "$(echo $PR_TITLE | grep -oP 'feature')" == "feature" ] && echo 0) || echo $(($CURRENT_PATCH+1)))
NEW_TAG=$(echo $MAJOR.$MINOR.$PATCH)
PACKAGE_VERSION=${NEW_TAG:-${{ vars.DEFAULT_PACKAGE_VERSION }}}
echo "release_package_version=$PACKAGE_VERSION" >> "$GITHUB_OUTPUT"
echo $PACKAGE_VERSION
- name: Pack
run: dotnet pack -c ${{ vars.CONFIGURATION }} -p:PackageVersion=${{ steps.create_tag.outputs.release_package_version }}
#- name: Release
# run: |
# dotnet nuget push */bin/Release/OData.QueryBuilder.${{ steps.create_tag.outputs.release_package_version }}.nupkg -k ${{ secrets.NUGET_API_KEY }} -s ${{ vars.NUGET_SOURCE }}
# git tag v${{ steps.create_tag.outputs.release_package_version }}
# git push origin v${{ steps.create_tag.outputs.release_package_version }}