-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (95 loc) · 4.33 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
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
119
120
121
name: CI-CD
on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop
jobs:
Tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
- name: Build
run: dotnet build -c Debug
- name: Test
run: dotnet test --no-build -c Debug
Package_Version:
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
needs: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Prepare environment
run: |
echo "PARSER_VERSION=$(grep -oPm1 "(?<=<Version>)[^<]+" ./GherkinSimpleParser/GherkinSimpleParser.csproj)" >> $GITHUB_ENV
echo "CONVERTER_VERSION=$(grep -oPm1 "(?<=<Version>)[^<]+" ./GherkinSimpleParser.Converter/GherkinSimpleParser.Converter.csproj)" >> $GITHUB_ENV
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
- name: Build
run: dotnet build -c Release
- name: Publish Parser
run: |
dotnet publish ./GherkinSimpleParser --no-build -c Release -o ./PublishFolder/temp
cp ./LICENSE.txt ./PublishFolder/temp
cp ./README.md ./PublishFolder/temp
zip -r ./PublishFolder/GherkinSimpleParser_dll_$PARSER_VERSION.zip ./PublishFolder/temp/*
rm -rf ./PublishFolder/temp
cp ./GherkinSimpleParser/bin/Release/GherkinSimpleParser.$PARSER_VERSION.nupkg ./PublishFolder
- name: Publish Converter
run: |
dotnet publish ./GherkinSimpleParser.Converter --no-build -c Release -o ./PublishFolder/temp
cp ./LICENSE.txt ./PublishFolder/temp
cp ./README.md ./PublishFolder/temp
zip -r ./PublishFolder/GherkinSimpleParser.Converter_dll_$CONVERTER_VERSION.zip ./PublishFolder/temp/*
rm -rf ./PublishFolder/temp
cp ./GherkinSimpleParser.Converter/bin/Release/GherkinSimpleParser.Converter.$CONVERTER_VERSION.nupkg ./PublishFolder
- name: Publish Console
run: |
dotnet publish ./GherkinSimpleParser.Console --no-build -c Release -o ./PublishFolder/temp
cp ./LICENSE.txt ./PublishFolder/temp
cp ./README.md ./PublishFolder/temp
zip -r ./PublishFolder/GherkinSimpleParser.Console_dll_$PARSER_VERSION.zip ./PublishFolder/temp/*
rm -rf ./PublishFolder/temp
- name: Generate Release File
run: |
cd ./PublishFolder
echo -e "## Release Notes \n\n- TODO\n\n## SHA256\n\n### Parser\n" >> release_notes.md
echo "- \`$(shasum -a 256 GherkinSimpleParser.$PARSER_VERSION.nupkg)\`" >> release_notes.md
echo "- \`$(shasum -a 256 GherkinSimpleParser_dll_$PARSER_VERSION.zip)\`" >> release_notes.md
echo -e "\n### Converter\n" >> release_notes.md
echo "- \`$(shasum -a 256 GherkinSimpleParser.Converter.$CONVERTER_VERSION.nupkg)\`" >> release_notes.md
echo "- \`$(shasum -a 256 GherkinSimpleParser.Converter_dll_$CONVERTER_VERSION.zip)\`" >> release_notes.md
echo -e "\n### Console\n" >> release_notes.md
echo "- \`$(shasum -a 256 GherkinSimpleParser.Console_dll_$PARSER_VERSION.zip)\`" >> release_notes.md
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: PublishFolder
path: ./PublishFolder
Publish_Nuget_Package:
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
needs: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
- name: Build
run: dotnet build ./GherkinSimpleParser -c Release
- name: Nuget Push
run: |
PARSER_VERSION=$(grep -oPm1 "(?<=<Version>)[^<]+" ./GherkinSimpleParser/GherkinSimpleParser.csproj)
dotnet nuget add source --username ${{ github.repository_owner }} --password ${{ secrets.NUGET_PAT }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
dotnet nuget push ./GherkinSimpleParser/bin/Release/GherkinSimpleParser.$PARSER_VERSION.nupkg --source "github"