-
Notifications
You must be signed in to change notification settings - Fork 0
143 lines (137 loc) · 5.21 KB
/
continuous-delivery.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
140
141
142
143
name: Continuous Delivery
on:
push: {}
pull_request: {}
workflow_dispatch:
inputs:
force-release:
type: boolean
description: Force tag & release even when the source branch is not main or no production source files have changed
jobs:
check-release-requirement:
runs-on: ubuntu-latest
outputs:
needs-release: ${{ steps.release-check.outputs.needs-release }}
semantic-version: ${{ steps.get-semver.outputs.semantic-version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: GetSemVer
id: get-semver
run: |
dotnet tool install --global GitVersion.Tool --version 6.*
output=$(dotnet-gitversion)
semver=$(echo $output | grep -oP '"SemVer"\s*:\s*"\K[^"]+')
echo $output
echo "Semantic version: $semver"
echo "semantic-version=$semver" >> $GITHUB_OUTPUT
- name: Check for Release Requirement
id: release-check
run: |
productionFilesChangedCount=$(git diff --name-only HEAD^ HEAD | grep -E 'src/|Installer/' | wc -l)
echo "$productionFilesChangedCount production source code files have changed"
productionFilesChanged=$((productionFilesChangedCount > 0))
echo "Git ref: ${{ github.ref_name }}"
branchIsMain=$([[ "${{ github.ref_name }}" == "main" ]] && echo true || echo false)
forceReleaseRequested=$([[ "${{ github.event.inputs.force-release }}" == "true" ]] && echo true || echo false)
echo "Forced release requested: $forceReleaseRequested"
needsRelease=$([[ "$forceReleaseRequested" == "true" || ( "$productionFilesChanged" == "1" && "$branchIsMain" == "true" ) ]] && echo true || echo false)
echo "Release will be generated: $needsRelease"
echo "needs-release=$needsRelease" >> $GITHUB_OUTPUT
display-job-outputs:
needs: check-release-requirement
runs-on: ubuntu-latest
steps:
- name: Display Job Outputs
run: |
echo "needs-release = ${{ needs.check-release-requirement.outputs.needs-release }}"
echo "semantic-version = ${{ needs.check-release-requirement.outputs.semantic-version }}"
build-windows:
runs-on: windows-latest
needs: check-release-requirement
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Build & Test
run: ./Build/build-and-test.ps1
shell: pwsh
- name: Upload Coverage Badge
if: github.event_name != 'pull_request' && github.actor != 'dependabot[bot]'
uses: exuanbo/actions-deploy-gist@v1
with:
token: ${{ secrets.CODE_COVERAGE_AUTH_TOKEN }}
gist_id: 527882e89a938dc78f61a08c300edec4
gist_description: "code-coverage-${{ github.ref_name }}"
gist_file_name: fmsync-code-coverage-${{ github.ref_name }}.svg
file_path: tests/TestResults/badge_shieldsio_linecoverage_green.svg
- name: Run codacy-coverage-reporter
if: github.actor != 'dependabot[bot]'
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: tests/TestResults/Cobertura.xml
- name: Build Windows Installer
run: ./Build/build-windows-installer.ps1
shell: pwsh
- name: Upload Windows Artifact
if: needs.check-release-requirement.outputs.needs-release == 'true'
uses: actions/upload-artifact@v3
with:
name: windows-installer
path: ./Installer/Elzik.FmSync.WindowsInstaller/bin/x64/Release/en-US/fmsync*.msi
build-macos:
runs-on: macos-latest
needs: check-release-requirement
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Build & Test
run: ./Build/build-and-test.ps1
shell: pwsh
- name: Build OSX Installer
run: ./Build/build-osx-installer.ps1
shell: pwsh
- name: Upload macOS Artifact
if: needs.check-release-requirement.outputs.needs-release == 'true'
uses: actions/upload-artifact@v3
with:
name: macos-installer
path: ./Installer/Elzik.FmSync.OsxInstaller/x64/Release/fmsync-osx*.zip
release:
runs-on: ubuntu-latest
needs: [build-windows, build-macos, check-release-requirement]
if: needs.check-release-requirement.outputs.needs-release == 'true'
steps:
- uses: actions/checkout@v4
- name: Tag With SemVer
run: |
git tag "v${{ needs.check-release-requirement.outputs.semantic-version }}"
git push --tags
- uses: actions/download-artifact@v3
with:
name: windows-installer
path: ./windows-installer
- uses: actions/download-artifact@v3
with:
name: macos-installer
path: ./macos-installer
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.check-release-requirement.outputs.semantic-version }}
generate_release_notes: true
prerelease: ${{ github.ref_name != 'main' }}
files: |
./windows-installer/fmsync*.msi
./macos-installer/fmsync-osx*.zip