-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (118 loc) · 4.81 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: CI/CD
on:
workflow_dispatch:
inputs:
release_major:
description: 'Release - major number'
required: true
default: '3' # major
release_minor:
description: 'Release - minor number'
required: true
default: '4' # minor
release_patch:
description: 'Release - patch number (previous 1)'
required: true
release_name:
description: 'Additional name of the release'
required: true
release_suffix:
description: 'Release - version suffix (including dash!)'
required: false
defaults:
run:
shell: bash
jobs:
build:
runs-on: windows-latest
env:
release_version: ${{github.event.inputs.release_major}}.${{github.event.inputs.release_minor}}.${{github.event.inputs.release_patch}}.${{github.run_number}}
bin_dir: 'Mapp.UI/bin/publish/'
workflow: '.github/workflows/ci_cd.yml'
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
token: ${{ secrets.MAPP_PAT }}
- name: Install dependencies
run: dotnet restore
- name: Change assembly versions
run: |
sed -i 's/AssemblyVersion(".*")/AssemblyVersion("${{env.release_version}}")/g' Mapp.UI/Properties/SharedAssemblyInfo.cs
sed -i 's/AssemblyFileVersion(".*")/AssemblyFileVersion("${{env.release_version}}")/g' Mapp.UI/Properties/SharedAssemblyInfo.cs
- name: Build
run: |
dotnet build --configuration Release --no-restore
dotnet publish Mapp.UI -c Release -r win-x64 -o ${{env.bin_dir}} -p:PublishSingleFile=true --self-contained false
- name: Test
run: dotnet test --no-restore --verbosity minimal
- name: Set ENV
# TODO is it possible to combine output variables in single step?
run: |
echo "release_tag=v${{env.release_version}}${{github.event.inputs.release_suffix}}" >> $GITHUB_ENV
- name: Set ENV 2
run: |
echo "artifact_name=mapp_${{env.release_tag}}_binaries.zip" >> $GITHUB_ENV
- name: Find Head
id: head
run: echo "::set-output name=head::$(git rev-parse HEAD)"
- name: Find latest tag
id: latest_tag
run: echo "::set-output name=latest_tag::$(git describe --tags --abbrev=0)"
- name: Generate changelog text
id: changelog_build
uses: mikepenz/[email protected]
with:
configuration: ".github/workflows/changelog_settings.json"
ignorePreReleases: "false"
commitMode: "true"
toTag: ${{ steps.head.outputs.head }}
fromTag: ${{ steps.latest_tag.outputs.latest_tag }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Append to CHANGELOG.md
uses: DamianReeves/write-file-action@master
with:
path: ./CHANGELOG.md
contents: \n${{ steps.changelog_build.outputs.changelog }}
write-mode: append
- name: Check prerelease version
uses: haya14busa/action-cond@v1
id: condval
with: # allows to get actual bool from string
cond: ${{ github.event.inputs.release_suffix != '' }}
if_true: true
if_false: false
- name: Create Archive
uses: thedoctor0/zip-release@master
with:
path: .
directory: ${{env.bin_dir}}
filename: ${{env.artifact_name}}
exclusions: '*.git* *.pdb /*Invoice Converter/* /*Transactions Configs/* ${{env.bin_dir}}Invoice Converter/* ${{env.bin_dir}}Transactions Configs/ ${{env.bin_dir}}Transactions Configs'
- name: Create Release
uses: ncipollo/release-action@v1
with:
artifacts: "${{env.bin_dir}}${{env.artifact_name}}"
tag: v${{env.release_version}}
name: "${{env.release_tag}} - ${{github.event.inputs.release_name}}"
allowUpdates: true
commit: master
omitBody: false
omitName: false
prerelease: ${{steps.condval.outputs.value}}
artifactErrorsFailBuild: true
body: ${{ steps.changelog_build.outputs.changelog }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Change default version in workflow
# sed to replace only the first occurence
run: |
sed -i "0,/default: '.*' # major/s//default: '${{github.event.inputs.release_major}}' # major/g" ${{env.workflow}}
sed -i "0,/default: '.*' # minor/s//default: '${{github.event.inputs.release_minor}}' # minor/g" ${{env.workflow}}
sed -i "0,/(previous .*)/s//(previous ${{github.event.inputs.release_patch}})/g" ${{env.workflow}}
- name: Commit report
run: |
git config --global user.name 'AutomatedRelease'
git config --global user.email '[email protected]'
git commit -am "chore: Automated report [skip ci]"
git push