forked from pact-foundation/pact-net
-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (122 loc) · 5.84 KB
/
ci.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
144
name: CI
on: [push, pull_request]
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
NUGET_FEED: https://api.nuget.org/v3/index.json
jobs:
build-dotnet:
name: ${{ matrix.alpine == true && 'linux-musl' || matrix.debian == true && 'linux-glibc' || matrix.os }}-${{ matrix.arch }}-dotnet-build-test
strategy:
fail-fast: false
matrix:
os:
- windows-latest
- ubuntu-latest
- macos-12
- macos-14
alpine: [false]
debian: [false]
include:
- arch: x64
- arch: ARM64
os: macos-14
- os: ubuntu-latest
alpine: true
arch: x64
- os: ubuntu-latest
debian: true
arch: x64
# - os: ubuntu-latest
# alpine: true
# arch: ARM64
## Skipped as .NET does not work with QEMU https://github.com/dotnet/core/blob/main/release-notes/8.0/supported-os.md#qemu
# - os: ubuntu-latest
# debian: true
# arch: ARM64
## Skipped as .NET does not work with QEMU https://github.com/dotnet/core/blob/main/release-notes/8.0/supported-os.md#qemu
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x" # runners already have .Net Framework installed as well
- name: Cache FFI dependencies
if: ${{ matrix.alpine != true && matrix.debian != true }}
id: cache
uses: actions/cache@v4
with:
key: cache-ffi-${{ hashFiles('build/download-native-libs.sh') }}
enableCrossOsArchive: true
path: |
build/linux
build/macos
build/windows
- name: Set up QEMU
if: matrix.alpine == true && matrix.arch == 'ARM64'
uses: docker/setup-qemu-action@v3
- name: Pull interop dependencies
if: ${{ steps.cache.outputs.cache-hit != 'true' && matrix.alpine != true && matrix.debian != true }}
run: bash -c "build/download-native-libs.sh"
- name: Restore
if: ${{ matrix.alpine != true && matrix.debian != true }}
run: dotnet restore
- name: Build
if: ${{ matrix.alpine != true && matrix.debian != true }}
run: dotnet build --no-restore
- name: Test
if: ${{ matrix.alpine != true && matrix.debian != true }}
run: dotnet test --no-build --verbosity normal
- name: test linux amd64 musl
if: ${{ matrix.alpine == true && matrix.arch == 'x64' }}
run: |
docker run --platform=linux/amd64 --rm -v $PWD:/app mcr.microsoft.com/dotnet/sdk:8.0-alpine /bin/sh -c 'apk add --no-cache curl bash gzip && cd /app && build/download-native-libs.sh && dotnet restore && dotnet build --no-restore && dotnet test --no-build --verbosity normal'
- name: test linux amd64 debian
if: ${{ matrix.debian == true && matrix.arch == 'x64' }}
run: |
docker run --platform=linux/amd64 --rm -v $PWD:/app mcr.microsoft.com/dotnet/sdk:8.0 /bin/bash -c 'apt-get update && apt-get install --yes curl gzip && cd /app && build/download-native-libs.sh && dotnet restore && dotnet build --no-restore && dotnet test --no-build --verbosity normal'
## Skipped as .NET does not work with QEMU https://github.com/dotnet/core/blob/main/release-notes/8.0/supported-os.md#qemu
- name: test linux arm64 musl
if: ${{ matrix.alpine == true && matrix.arch == 'ARM64' }}
run: |
docker run --platform=linux/arm64 --rm -v $PWD:/app mcr.microsoft.com/dotnet/sdk:8.0-alpine /bin/sh -c 'apk add --no-cache curl bash gzip && cd /app && build/download-native-libs.sh && dotnet restore && dotnet build --no-restore && dotnet test --no-build --verbosity normal'
# Skipped as .NET does not work with QEMU https://github.com/dotnet/core/blob/main/release-notes/8.0/supported-os.md#qemu
- name: test linux arm64 musl
if: ${{ matrix.debian == true && matrix.arch == 'ARM64' }}
run: |
docker run --platform=linux/arm64 --rm -v $PWD:/app mcr.microsoft.com/dotnet/sdk:8.0 /bin/bash -c 'apt-get update && apt-get install --yes curl gzip && cd /app && build/download-native-libs.sh && dotnet restore && dotnet build --no-restore && dotnet test --no-build --verbosity normal'
- name: Pack
if: matrix.os == 'windows-latest'
run: dotnet pack --verbosity normal -c Release --no-restore --include-source --version-suffix alpha.${{ github.run_number }} -o ./dist
- name: Upload Artifact
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: nupkgs
path: ./dist/*.*
release:
needs: build-dotnet
if: github.ref_type == 'tag'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x" # runners already have .Net Framework installed as well
- name: Pull interop dependencies
run: bash -c "build/download-native-libs.sh"
- name: Pack
run: |
VERSION="${{ github.ref_name }}"
echo "Version: $VERSION"
dotnet pack -c Release --include-source -p:Version=$VERSION -o ./dist src/PactNet/PactNet.csproj
dotnet pack -c Release --include-source -p:Version=$VERSION -o ./dist src/PactNet.Abstractions/PactNet.Abstractions.csproj
dotnet pack -c Release --include-source -o ./dist src/PactNet.Output.Xunit/PactNet.Output.Xunit.csproj
- name: Push
run: dotnet nuget push ./dist/*.nupkg --source $NUGET_FEED --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }}
- name: Release
uses: softprops/action-gh-release@v1
with:
files: dist/*.*