Skip to content

webhook

webhook #264

Workflow file for this run

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, 10]
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