-
Notifications
You must be signed in to change notification settings - Fork 48
130 lines (113 loc) · 5.34 KB
/
main-ci-build.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
name: Main and Release CI Build
on:
workflow_dispatch:
push:
branches: [ master, main ]
create:
tags:
- 'v*.*'
pull_request:
branches: [ master, main ]
jobs:
build:
permissions: write-all
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: windows-latest
windows: true
runs-on: ${{ matrix.os }}
steps:
- run: |
mkdir artifacts
mkdir artifacts/build
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Mandatory to use the extract version from tag action
- name: Extract version from tag
uses: damienaicheh/[email protected]
- name: Export version
run: |
echo "VERSIONSUFFIX=${{ env.PRE_RELEASE }}" >> $GITHUB_ENV
echo "PRODVERSION=${{ env.MAJOR }}.${{ env.MINOR }}" >> $GITHUB_ENV
echo "PATCHVERSION=${{ env.PATCH }}" >> $GITHUB_ENV
- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build Docker Image TAR file
run: |
mkdir -p artifacts/build/images
DOCKER_BUILDKIT=1 docker build . --build-arg "REVISION=${{ env.PRODVERSION }}.${{ env.PATCHVERSION }}" --build-arg "VERSION=${{ env.PRODVERSION }}" -t azbridge:${{ env.PRODVERSION }} -t azbridge
docker save azbridge:${{ env.PRODVERSION }} > artifacts/build/images/azbridge-oci-image-${{ env.PRODVERSION }}.${{ env.PATCHVERSION }}.tar
if: matrix.os == 'ubuntu-latest'
- name: Build for Windows-x64
run: dotnet msbuild /t:Package /p:WindowsOnly=true /p:RuntimeIdentifier=win-x64 /p:Configuration=Release /p:TargetFramework=net8.0 /p:VersionSuffix=rel
if: matrix.os == 'windows-latest'
- name: Build for Windows-arm64
run: dotnet msbuild /t:Restore,Package /p:WindowsOnly=false /p:RuntimeIdentifier=win-arm64 /p:Configuration=Release /p:TargetFramework=net8.0 /p:VersionSuffix=rel
if: matrix.os == 'windows-latest'
- name: Build for Windows-x86
run: dotnet msbuild /t:Restore,Package /p:WindowsOnly=false /p:RuntimeIdentifier=win-x86 /p:Configuration=Release /p:TargetFramework=net8.0 /p:VersionSuffix=rel
if: matrix.os == 'windows-latest'
- name: Build for macOS-x64
run: dotnet msbuild /t:Package /p:WindowsOnly=false /p:RuntimeIdentifier=osx-x64 /p:Configuration=Release /p:TargetFramework=net8.0 /p:VersionSuffix=rel
if: matrix.os == 'macos-latest'
- name: Build for macOS-arm64
run: dotnet msbuild /t:Package /p:WindowsOnly=false /p:RuntimeIdentifier=osx-arm64 /p:Configuration=Release /p:TargetFramework=net8.0 /p:VersionSuffix=rel
if: matrix.os == 'macos-latest'
- name: Build for Linux-x64
run: dotnet msbuild /t:Package /p:WindowsOnly=false /p:RuntimeIdentifier=linux-x64 /p:Configuration=Release /p:TargetFramework=net8.0 /p:VersionSuffix=rel
if: matrix.os == 'ubuntu-latest'
- name: Build for Linux-arm64
run: dotnet msbuild /t:Restore,Package /p:WindowsOnly=false /p:RuntimeIdentifier=linux-arm64 /p:Configuration=Release /p:TargetFramework=net8.0 /p:VersionSuffix=rel
if: matrix.os == 'ubuntu-latest'
- name: Unit Test Windows x64
env:
AZBRIDGE_TEST_CXNSTRING: ${{ secrets.AZBRIDGE_TEST_CXNSTRING }}
run: dotnet test /p:TargetFramework=net8.0 /p:RuntimeIdentifier=win-x64 /p:Configuration=Debug
if: matrix.os == 'windows-latest'
- name: Unit Test Linux x64
env:
AZBRIDGE_TEST_CXNSTRING: ${{ secrets.AZBRIDGE_TEST_CXNSTRING }}
run: dotnet test /p:TargetFramework=net8.0 /p:RuntimeIdentifier=linux-x64 /p:Configuration=Debug
if: matrix.os == 'ubuntu-latest'
- name: Unit Test macOS arm64
env:
AZBRIDGE_TEST_CXNSTRING: ${{ secrets.AZBRIDGE_TEST_CXNSTRING }}
# W/A for Dns.GetHostEntry(Dns.GetHostName()) exception https://github.com/actions/runner-images/issues/8649
run: |
echo -e "$(ipconfig getifaddr en0) $(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts
./test/unit/macos_unblock_testip.sh
dotnet test /p:TargetFramework=net8.0 /p:RuntimeIdentifier=osx-arm64 /p:Configuration=Debug
if: matrix.os == 'macos-latest'
- uses: actions/upload-artifact@v2
with:
name: XBuild
path: artifacts/build/net8.0
- uses: actions/upload-artifact@v2
with:
name: XBuild
path: artifacts/build/images
if: matrix.os == 'ubuntu-latest'
- name: Integration Tests Docker/Linux
env:
AZBRIDGE_TEST_CXNSTRING: ${{ secrets.AZBRIDGE_TEST_CXNSTRING }}
run: bash ./verify-build.sh
if: matrix.os == 'ubuntu-latest'
- name: Integration Tests Windows
env:
AZBRIDGE_TEST_CXNSTRING: ${{ secrets.AZBRIDGE_TEST_CXNSTRING }}
run: ./verify-build.cmd
if: matrix.os == 'windows-latest'
# create a release if a tag has been pushed
- name: Generate Release
uses: ncipollo/release-action@v1
if: startsWith(github.ref, 'refs/tags/v')
with:
artifacts: "artifacts/build/net8.0/*,artifacts/build/images/*"
generateReleaseNotes: true
allowUpdates: true