-
-
Notifications
You must be signed in to change notification settings - Fork 36
212 lines (186 loc) · 7.8 KB
/
Copy pathmain.yml
File metadata and controls
212 lines (186 loc) · 7.8 KB
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
name: Bundle packages
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main
- v*.*.*
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
DOTNET_INSTALL_DIR: ${{ github.workspace }}/.dotnet
DOTNET_VERSION: "10.0.x"
IS_PRE_RELEASE: ${{ !(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/v')) }}
jobs:
env-context:
runs-on: ubuntu-latest
outputs:
is-pre-release: ${{ steps.set.outputs.is_pre_release }}
dotnet-version: ${{ steps.set.outputs.dotnet_version }}
is-version-branch: ${{ steps.set.outputs.is_version_branch }}
skip-unix: ${{ steps.set.outputs.skip_unix }}
skip-windows: ${{ steps.set.outputs.skip_windows }}
skip-osx: ${{ steps.set.outputs.skip_osx }}
steps:
- name: Checkout repository
uses: actions/checkout@v5.0.1
with:
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
- name: Set env for the reusable workflows
id: set
run: |
echo "is_pre_release=$IS_PRE_RELEASE" >> $GITHUB_OUTPUT
echo "dotnet_version=$DOTNET_VERSION" >> $GITHUB_OUTPUT
if [[ ${{ github.ref }} =~ ^refs/heads/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "is_version_branch=true" >> $GITHUB_OUTPUT
else
echo "is_version_branch=false" >> $GITHUB_OUTPUT
fi;
# Skip build for specific OS
git log -1 --pretty=format:"%B" | cat
for os in unix windows osx; do
if git log -1 --pretty=format:"%B" | grep -Eq "\[(skip|no) $os\]|\[$os skip\]"; then
echo "skip_$os=true" >> $GITHUB_OUTPUT
echo "Skip build for $os"
else
echo "skip_$os=false" >> $GITHUB_OUTPUT
echo "Building for $os"
fi
done
LinuxBuild:
needs: env-context
uses: ./.github/workflows/unix.yml
secrets: inherit
with:
is-pre-release: ${{ fromJSON(needs.env-context.outputs.is-pre-release) }}
dotnet-version: ${{ needs.env-context.outputs.dotnet-version }}
is-version-branch: ${{ fromJSON(needs.env-context.outputs.is-version-branch) }}
skip: ${{ fromJSON(needs.env-context.outputs.skip-unix) }}
WindowsBuild:
needs: env-context
uses: ./.github/workflows/windows.yml
secrets: inherit
with:
is-pre-release: ${{ fromJSON(needs.env-context.outputs.is-pre-release) }}
dotnet-version: ${{ needs.env-context.outputs.dotnet-version }}
is-version-branch: ${{ fromJSON(needs.env-context.outputs.is-version-branch) }}
skip: ${{ fromJSON(needs.env-context.outputs.skip-windows) }}
MacOSBuild:
needs: env-context
uses: ./.github/workflows/macos.yml
secrets: inherit
with:
is-pre-release: ${{ fromJSON(needs.env-context.outputs.is-pre-release) }}
dotnet-version: ${{ needs.env-context.outputs.dotnet-version }}
is-version-branch: ${{ fromJSON(needs.env-context.outputs.is-version-branch) }}
skip: ${{ fromJSON(needs.env-context.outputs.skip-osx) }}
TestAndPushPackages:
needs: [env-context, LinuxBuild, WindowsBuild, MacOSBuild]
strategy:
matrix:
os: [ubuntu-latest]
defaults:
run:
working-directory: unix
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5.0.1
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: NuGet - set credentials
uses: ./.github/actions/set-credentials
with:
api-key-github: ${{ secrets.API_KEY_GITHUB }}
api-key-nuget: ${{ secrets.API_KEY_NUGET }}
api-user-github: ${{ secrets.API_USER_GITHUB }}
api-user-nuget: ${{ secrets.API_USER_NUGET }}
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v5.0.0
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- uses: actions/download-artifact@v6.0.0
with:
name: packages-core
path: nuget
merge-multiple: true
- uses: actions/download-artifact@v6.0.0
with:
name: packages-unix-x64
path: nuget
merge-multiple: true
- uses: actions/download-artifact@v6.0.0
with:
name: packages-unix-arm64
path: nuget
merge-multiple: true
- uses: actions/download-artifact@v6.0.0
with:
name: packages-win-x64
path: nuget
merge-multiple: true
- uses: actions/download-artifact@v6.0.0
with:
name: packages-osx-x64
path: nuget
merge-multiple: true
- uses: actions/download-artifact@v6.0.0
with:
name: packages-osx-arm64
path: nuget
merge-multiple: true
- name: Remove old formats
run: |
rm -rf ${{ github.workspace }}/tests/gdal-formats
- uses: actions/download-artifact@v6.0.0
with:
pattern: formats-*
path: "tests/gdal-formats"
- name: Build bundle
run: |
make -f generate-projects-makefile generate-final-bundle PRERELEASE=${{ env.IS_PRE_RELEASE }} BUILD_NUMBER_TAIL=${{ github.run_number }}
make -f publish-makefile pack-bundle-final PRERELEASE=${{ env.IS_PRE_RELEASE }} BUILD_NUMBER_TAIL=${{ github.run_number }}
echo "GDAL_VERSION=$(make -f publish-makefile get-gdal-version)" >> $GITHUB_ENV
echo "PACKAGES_VERSION=$(make -f publish-makefile get-package-version PRERELEASE=${{ env.IS_PRE_RELEASE }} BUILD_NUMBER_TAIL=${{ github.run_number }})" >> $GITHUB_ENV
- name: Run tests from nuget packages
env:
TEST_PROJECT: ${{ github.workspace }}/tests/MaxRev.Gdal.Core.Tests.XUnit/MaxRev.Gdal.Core.Tests.XUnit.csproj
run: |
for project in \
"${{ github.workspace }}/tests/MaxRev.Gdal.Core.Tests.XUnit/MaxRev.Gdal.Core.Tests.XUnit.csproj" \
"${{ github.workspace }}/tests/MaxRev.Gdal.Core.Tests/MaxRev.Gdal.Core.Tests.csproj" \
"${{ github.workspace }}/tests/MaxRev.Gdal.Core.Tests.AzureFunctions/MaxRev.Gdal.Core.Tests.AzureFunctions.csproj"; do
dotnet add "$project" package MaxRev.Gdal.Universal --version ${{ env.PACKAGES_VERSION }} --source local.ci --no-restore
done
dotnet restore --ignore-failed-sources ${{ env.TEST_PROJECT }}
dotnet test --no-restore ${{ env.TEST_PROJECT }}
- name: Store packages as artifact
uses: actions/upload-artifact@v5.0.0
with:
name: packages-final
path: nuget/*.nupkg
overwrite: true
- name: Process gdal formats
working-directory: shared/scripts
run: |
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt
python ./combine-formats.py '${{ github.workspace }}/tests/gdal-formats'
- name: Commit changes
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: EndBug/add-and-commit@v9
with:
author_name: ${{ secrets.COMMIT_AUTHOR }}
author_email: ${{ secrets.COMMIT_EMAIL }}
message: "List of drivers in current version [ci skip]"
add: "${{ github.workspace }}/tests/gdal-formats/**"
tag: "v${{ env.PACKAGES_VERSION }} --force"
- name: Push packages
if: ${{ github.event.pull_request.merged == true || github.ref == 'refs/heads/main' || fromJson(needs.env-context.outputs.is-version-branch) }}
run: |
make -f push-packages-makefile PRERELEASE=${{ env.IS_PRE_RELEASE }} INCLUDE_CORE=1 \
BUILD_NUMBER_TAIL=${{ github.run_number }} API_KEY_GITHUB=${{ secrets.API_KEY_GITHUB }} API_KEY_NUGET=${{ secrets.API_KEY_NUGET }}