-
-
Notifications
You must be signed in to change notification settings - Fork 1
215 lines (183 loc) · 13 KB
/
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
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
213
214
215
on:
# schedule:
# - cron: '0 0 * * 0'
workflow_dispatch:
repository_dispatch:
types: [webhook]
push:
paths-ignore:
- README.md
- dotnet-install.sh
branches:
- master
permissions:
contents: write
packages: write
env:
ROOTFS_DIR: ${{ github.workspace }}/dotnet-rootfs
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
build:
strategy:
matrix:
dotnet_major_version: [8, 9]
dotnet_arch: [x64]
dotnet_os: [haiku]
dotnet_configuration: [Debug, Release]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Chuck out the trash
uses: insightsengineering/disk-space-reclaimer@v1
- name: Install build dependencies
run: sudo apt install -y liblttng-ust-dev powershell
- name: Determine build ID
id: buildid
run: |
latestRev=""
today=$(date --utc +%Y%m%d)
releaseUrl="${{ github.server_url }}/${{ github.repository }}/releases/tag/net${{ matrix.dotnet_major_version }}-${{ matrix.dotnet_os }}-${{ matrix.dotnet_arch }}-$today."
pageNum=1
while [ -z "$latestRev" ];
do
json=$(curl -s ${{ github.api_url }}/repos/${{ github.repository }}/releases?page=$pageNum)
pageNum=$((pageNum + 1))
if [ $(echo $json | jq length) -eq 0 ]; then
# This means that we've passed the end and reached an empty array
break
fi
if [ $(echo $json | jq 'objects // {} | has("message")') == "true" ]; then
# API has return an error object
echo "Unable to fetch releases from GitHub API"
exit 2
fi
# Store array of revisions
revisions=($(echo $json | jq -e -r ".[] | .html_url | select(contains(\"$today\") and contains(\"${{ matrix.dotnet_configuration }}\") and contains(\"net${{ matrix.dotnet_major_version }}-\"))[${#releaseUrl}:]")) \
|| continue
latestRev=${revisions[0]}
latestRev=${latestRev%-*}
done
if [ -z "$latestRev" ]; then
latestRev=0
fi
latestRev=$((latestRev + 1))
echo buildid=$today.$latestRev >> "$GITHUB_OUTPUT"
- name: Clone .NET Runtime
run: git clone https://github.com/trungnt2910/dotnet-runtime -b haiku-dotnet${{ matrix.dotnet_major_version }} --depth=1 ${{ github.workspace }}/runtime
- name: Build rootfs
run: ${{ github.workspace }}/runtime/eng/common/cross/build-rootfs.sh ${{ matrix.dotnet_arch }} ${{ matrix.dotnet_os }}
- name: Build .NET Runtime
run: |
# The two properties, UseRidGraph and BundledRuntimeIdentifierGraphFile, are required after dotnet/runtime#90695.
# Without these properties set, the building SDK will no longer recognize Haiku as being derived from Unix, and will therefore
# reference incorrect libraries, causing build errors.
#
# Note that the properties, as well as the Microsoft.NETCore.Platforms project, might be removed in the near future.
# At that time, a Haiku-aware SDK might have to be built before building the runtime.
# Alternatively, we might be able to check out the dotnet/dotnet VMR for a source-build solution.
${{ github.workspace }}/runtime/build.sh --ci \
-c ${{ matrix.dotnet_configuration }} \
-arch ${{ matrix.dotnet_arch }} \
-os ${{ matrix.dotnet_os }} -cross -gcc \
/p:OfficialBuildId=${{ steps.buildid.outputs.buildid }} \
/p:UseRidGraph=true \
/p:BundledRuntimeIdentifierGraphFile=${{ github.workspace }}/runtime/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json
- name: Determine .NET version
id: version
run: |
shopt -s extglob
echo version=$(sed -r 's/(.*Microsoft\.NETCore\.App\.Ref\.)(.*?)(\.nupkg)/\2/' <<< $(ls ${{ github.workspace }}/runtime/artifacts/packages/${{ matrix.dotnet_configuration }}/Shipping/Microsoft.NETCore.App.Ref.!(*symbols).nupkg)) >> "$GITHUB_OUTPUT"
- name: Extract tarballs
run: |
shopt -s extglob
mkdir ${{ github.workspace }}/output
pushd ${{ github.workspace }}/output
for f in ${{ github.workspace }}/runtime/artifacts/packages/${{ matrix.dotnet_configuration }}/Shipping/!(*symbols*).tar.gz; do tar xf "$f"; done
popd
- name: Clone .NET SDK
run: git clone https://github.com/trungnt2910/dotnet-sdk -b haiku-dotnet${{ matrix.dotnet_major_version }} --depth=1 ${{ github.workspace }}/sdk
- name: Build .NET SDK
run: |
${{ github.workspace }}/sdk/build.sh --ci --pack -c ${{ matrix.dotnet_configuration }} /p:OSName=${{ matrix.dotnet_os }} /p:Architecture=${{ matrix.dotnet_arch }} /p:OfficialBuildId=${{ steps.buildid.outputs.buildid }}
dotnetVersion=${{ steps.version.outputs.version }}
sdkFeatureBand=$(ls ${{ github.workspace }}/sdk/artifacts/bin/redist/${{ matrix.dotnet_configuration }}/dotnet/sdk)
pushd ${{ github.workspace }}/sdk/artifacts/bin/redist/${{ matrix.dotnet_configuration }}/dotnet/sdk/$sdkFeatureBand
# Update RuntimeIdentifierGraph
cp -f ${{ github.workspace }}/runtime/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json ./RuntimeIdentifierGraph.json
# Patch SDK properties, framework reference pack, and app host pack
# PLEASE DO NOT ASK ME WHAT THESE SED COMMANDS MEAN!
sed -ri "s/<BundledNETCoreAppPackageVersion>.*<\/BundledNETCoreAppPackageVersion>/<BundledNETCoreAppPackageVersion>$dotnetVersion<\/BundledNETCoreAppPackageVersion>/" ./Microsoft.NETCoreSdk.BundledVersions.props
sed -ri "s/<BundledNETCorePlatformsPackageVersion>.*<\/BundledNETCorePlatformsPackageVersion>/<BundledNETCorePlatformsPackageVersion>$dotnetVersion<\/BundledNETCorePlatformsPackageVersion>/" ./Microsoft.NETCoreSdk.BundledVersions.props
sed -ri "s/<NETCoreSdkRuntimeIdentifier>.*<\/NETCoreSdkRuntimeIdentifier>/<NETCoreSdkRuntimeIdentifier>${{ matrix.dotnet_os }}-${{ matrix.dotnet_arch }}<\/NETCoreSdkRuntimeIdentifier>/" ./Microsoft.NETCoreSdk.BundledVersions.props
sed -ri "s/<NETCoreSdkPortableRuntimeIdentifier>.*<\/NETCoreSdkPortableRuntimeIdentifier>/<NETCoreSdkPortableRuntimeIdentifier>${{ matrix.dotnet_os }}-${{ matrix.dotnet_arch }}<\/NETCoreSdkPortableRuntimeIdentifier>/" ./Microsoft.NETCoreSdk.BundledVersions.props
sed -ri "s/(<KnownFrameworkReference Include=\"Microsoft.NETCore.App\".*DefaultRuntimeFrameworkVersion=\")${{ matrix.dotnet_major_version }}[^\"]*(\".* \/>)/\1$dotnetVersion\2/" ./Microsoft.NETCoreSdk.BundledVersions.props
sed -ri "s/(<KnownFrameworkReference Include=\"Microsoft.NETCore.App\".*LatestRuntimeFrameworkVersion=\")${{ matrix.dotnet_major_version }}[^\"]*(\".* \/>)/\1$dotnetVersion\2/" ./Microsoft.NETCoreSdk.BundledVersions.props
sed -ri "s/(<KnownFrameworkReference Include=\"Microsoft.NETCore.App\".*TargetingPackVersion=\")${{ matrix.dotnet_major_version }}[^\"]*(\".* \/>)/\1$dotnetVersion\2/" ./Microsoft.NETCoreSdk.BundledVersions.props
sed -ri "s/(<KnownFrameworkReference Include=\"Microsoft.NETCore.App\".*DefaultRuntimeFrameworkVersion=\"$dotnetVersion\".*RuntimePackRuntimeIdentifiers=\")([^\"]*)(\".* \/>)/\1\2;${{ matrix.dotnet_os }}-${{ matrix.dotnet_arch }}\3/" ./Microsoft.NETCoreSdk.BundledVersions.props
sed -ri "s/(<KnownAppHostPack.* AppHostPackVersion=\")${{ matrix.dotnet_major_version }}[^\"]*(\".* \/>)/\1$dotnetVersion\2/" ./Microsoft.NETCoreSdk.BundledVersions.props
sed -ri "s/(<KnownAppHostPack.* AppHostPackVersion=\"$dotnetVersion\".*AppHostRuntimeIdentifiers=\")([^\"]*)(\".* \/>)/\1\2;${{ matrix.dotnet_os }}-${{ matrix.dotnet_arch }}\3/" ./Microsoft.NETCoreSdk.BundledVersions.props
# Other packs (at the time of writing, crossgen2 and ilcompiler) are not supported on Haiku
popd
- name: Copy .NET SDK
run: |
shopt -s extglob
# SDK
cp -r ${{ github.workspace }}/sdk/artifacts/bin/redist/${{ matrix.dotnet_configuration }}/dotnet/sdk ${{ github.workspace }}/output
# Templates
dotnetVersion=${{ steps.version.outputs.version }}
mkdir -p ${{ github.workspace }}/output/templates/$dotnetVersion
cp ${{ github.workspace }}/sdk/artifacts/packages/${{ matrix.dotnet_configuration }}/Shipping/*Templates!(*symbols*).nupkg ${{ github.workspace }}/output/templates/$dotnetVersion
- name: Clone MSBuild
run: git clone https://github.com/trungnt2910/dotnet-msbuild -b haiku-dotnet${{ matrix.dotnet_major_version }} --depth=1 ${{ github.workspace }}/msbuild
- name: Build MSBuild
run: |
# Do NOT set the OfficialBuildId property for this command. Otherwise, some build error related to some Microsoft internal NuGet feed will occur.
${{ github.workspace }}/msbuild/build.sh --ci --pack --configuration ${{ matrix.dotnet_configuration }} /p:OSName=${{ matrix.dotnet_os }} /p:Architecture=${{ matrix.dotnet_arch }} /p:CreateBootstrap=true
- name: Copy MSBuild
run: |
sdkFeatureBand=$(ls ${{ github.workspace }}/output/sdk)
pwsh -File ${{ github.workspace }}/msbuild/scripts/Deploy-MSBuild.ps1 --configuration ${{ matrix.dotnet_configuration }} --runtime Core --destination ${{ github.workspace }}/output/sdk/$sdkFeatureBand
# Remove unwanted backups
rm -rf ${{ github.workspace }}/output/sdk/$sdkFeatureBand/Backup*
- name: Create .NET tarball
run: |
pushd ${{ github.workspace }}/output
fileName=${{ github.workspace }}/net${{ matrix.dotnet_major_version }}-${{ matrix.dotnet_os }}-${{ matrix.dotnet_arch }}-${{ steps.buildid.outputs.buildid }}-${{ matrix.dotnet_configuration }}
tar -cf $fileName.tar *
gzip -9 < $fileName.tar > $fileName.tar.gz
popd
- name: Upload .NET artifact
uses: actions/upload-artifact@v3
with:
name: net${{ matrix.dotnet_major_version }}-${{ matrix.dotnet_os }}-${{ matrix.dotnet_arch }}-${{ steps.buildid.outputs.buildid }}-${{ matrix.dotnet_configuration }}.tar
path: ${{ github.workspace }}/net${{ matrix.dotnet_major_version }}-${{ matrix.dotnet_os }}-${{ matrix.dotnet_arch }}-${{ steps.buildid.outputs.buildid }}-${{ matrix.dotnet_configuration }}.tar
- name: Upload .NET NuGet packages artifact
uses: actions/upload-artifact@v3
with:
name: net${{ matrix.dotnet_major_version }}-${{ matrix.dotnet_os }}-${{ matrix.dotnet_arch }}-${{ steps.buildid.outputs.buildid }}-${{ matrix.dotnet_configuration }}-nuget
path: ${{ github.workspace }}/runtime/artifacts/packages/${{ matrix.dotnet_configuration }}/Shipping/*.nupkg
- name: Create release
if: ${{ github.ref == 'refs/heads/master' }}
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: net${{ matrix.dotnet_major_version }}-${{ matrix.dotnet_os }}-${{ matrix.dotnet_arch }}-${{ steps.buildid.outputs.buildid }}-${{ matrix.dotnet_configuration }}
prerelease: false
title: .NET ${{ matrix.dotnet_major_version }} for Haiku ${{ matrix.dotnet_arch }} build ${{ steps.buildid.outputs.buildid }} ${{ matrix.dotnet_configuration }}
files: |
${{ github.workspace }}/runtime/artifacts/packages/${{ matrix.dotnet_configuration }}/Shipping/*
${{ github.workspace }}/sdk/artifacts/packages/${{ matrix.dotnet_configuration }}/Shipping/*
${{ github.workspace }}/net${{ matrix.dotnet_major_version }}-${{ matrix.dotnet_os }}-${{ matrix.dotnet_arch }}-${{ steps.buildid.outputs.buildid }}-${{ matrix.dotnet_configuration }}.tar.gz
- name: Publish NuGet packages on GitHub
if: ${{ github.ref == 'refs/heads/master' && matrix.dotnet_configuration == 'Release' }}
run: |
shopt -s extglob
${{ github.workspace }}/runtime/.dotnet/dotnet nuget add source --username ${{ github.repository_owner }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
# Do not upload symbol packages because:
# - No debugging support on Haiku yet.
# - Pushing symbols packages to GitHub Packages seems to fail with 403 Forbidden.
${{ github.workspace }}/runtime/.dotnet/dotnet nuget push ${{ github.workspace }}/runtime/artifacts/packages/${{ matrix.dotnet_configuration }}/Shipping/!(*symbols*).nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source "github" --skip-duplicate
${{ github.workspace }}/runtime/.dotnet/dotnet nuget push ${{ github.workspace }}/sdk/artifacts/packages/${{ matrix.dotnet_configuration }}/Shipping/!(*symbols*).nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source "github" --skip-duplicate