-
Notifications
You must be signed in to change notification settings - Fork 1
138 lines (125 loc) · 3.78 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
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [ published ]
workflow_dispatch:
jobs:
build:
strategy:
matrix:
platform:
- name: Linux (amd64)
os: ubuntu-latest
# - name: macOS (amd64, arm64)
# os: macos-latest
# cmake_options: -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"
# - name: Windows (amd64)
# os: windows-latest
name: "Build: ${{ matrix.platform.name }}"
runs-on: ${{ matrix.platform.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Build
id: build
run: |
mkdir build
cd build
BUILD_TYPE="${{env.BUILD_TYPE}}"
BUILD_TYPE="${BUILD_TYPE:-RelWithDebInfo}"
LIBGIT2_SRC="${GITHUB_WORKSPACE}/libgit2"
SHA=${SHA:-$(git --git-dir="${LIBGIT2_SRC}/.git" rev-parse --short=7 HEAD)}
LIBGIT2_BASENAME="git2-${SHA}"
case $(uname -s) in
Darwin)
PLATFORM="osx"
LIBGIT2_FILENAME="lib${LIBGIT2_BASENAME}.dylib"
;;
MINGW*)
PLATFORM="win-x64"
LIBGIT2_FILENAME="${BUILD_TYPE}/${LIBGIT2_BASENAME}.dll"
;;
Linux)
PLATFORM="linux-x64"
LIBGIT2_FILENAME="lib${LIBGIT2_BASENAME}.so"
;;
*)
echo "Unknown platform" 1>&2
false
;;
esac
cmake "${LIBGIT2_SRC}" \
-DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_TESTS=OFF \
-DUSE_SSH=OFF \
-DUSE_BUNDLED_ZLIB=ON \
-DLIBGIT2_FILENAME="${LIBGIT2_BASENAME}" \
${{ matrix.platform.cmake_options }}
cmake --build . --config ${BUILD_TYPE}
echo "platform=${PLATFORM}" >> $GITHUB_OUTPUT
echo "path=build/${LIBGIT2_FILENAME}" >> $GITHUB_OUTPUT
shell: bash
- name: Upload Library
uses: actions/upload-artifact@v4
with:
name: ${{steps.build.outputs.platform}}
path: ${{steps.build.outputs.path}}
package:
needs: build
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup
run: |
mkdir -p tmp
mkdir -p build/runtimes/linux-x64/native
choco install nuget.commandline
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: tmp
- name: Set up Artifacts
run: |
mv tmp/linux-x64/* build/runtimes/linux-x64/native
- name: Calculate Version
id: version
run: |
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
SHA=$(git rev-parse --short HEAD)
VERSION="$(git describe --tags | \
sed -e "s/^v//" | \
sed -e "s/-g[0-9a-f]*$//" | \
sed -e "s/-[0-9]*$//")-pr${{ github.event.number }}-${SHA}"
else
VERSION=$(git describe --tags | \
sed -e "s/^v//" | \
sed -e "s/-g[0-9a-f]*$//" | \
sed -e "s/-\([0-9]*\)$/\.\1/")
fi
echo "Version ${VERSION}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
shell: bash
- name: Build Package
id: build
run: |
cd build
mkdir images
cp -R ../images/* ./images/
. ..\generate_props.ps1
nuget pack -version ${{steps.version.outputs.version}} -basepath . ..\dogged.native.binaries.nuspec
Write-Host "package=dogged.native.binaries.${{steps.version.outputs.version}}.nupkg" >> $Env:GITHUB_OUTPUT
- name: Upload Package
uses: actions/upload-artifact@v4
with:
name: nuget
path: build/${{steps.build.outputs.package}}/Dogged.Native.Binaries.${{steps.version.outputs.version}}.nupkg