1 Commits

Author SHA1 Message Date
gns 64aa94ec80 ci: init 2025-12-21 19:47:26 +08:00
+126
View File
@@ -0,0 +1,126 @@
name: Build .NET SDK
on:
workflow_dispatch:
inputs:
fork:
description: 'dotnet VMR fork name'
required: true
type: string
default: dotnet
branch:
description: 'dotnet VMR branch name'
required: true
type: string
default: main
is_rtm:
description: 'is RTM build'
type: boolean
default: false
release:
description: 'publish release'
type: boolean
jobs:
build:
strategy:
matrix:
include:
- name: linux-riscv64
runtime_os: linux
runtime_arch: riscv64
libc: glibc
docker_tag: azurelinux-3.0-net10.0-cross-riscv64
cross_name: riscv64
- name: linux-x64
runtime_os: linux
runtime_arch: x64
libc: glibc
docker_tag: almalinux-10-source-build-amd64
cross_name: /
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Maximize build space
uses: AdityaGarg8/remove-unwanted-software@v4.1
with:
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: 'true'
remove-codeql: 'true'
remove-cached-tools: 'true'
- name: Clone repository
run: |
git clone --single-branch --depth 1 -b ${{ inputs.branch }} https://github.com/${{ inputs.fork }}/dotnet
- name: Apply patches
run: |
# Back-ported.
# Needed for .NET 10 linux-musl-riscv64, remove it once we move on from .NET 10
curl -sSL https://github.com/am11/runtime/commit/fa6e00abe9be4a451d81a29309c933435db8fe40.patch |\
git -C dotnet/ apply -v --directory=src/runtime || true
- name: Build
run: |
export COMPILE_ROOTFS_DIR=' '
if [[ ${{ matrix.cross_name }} != '/' ]]; then
export COMPILE_ROOTFS_DIR="-e ROOTFS_DIR=/crossrootfs/${{ matrix.cross_name }}"
fi
docker run --platform linux/amd64 --rm -v${{ github.workspace }}/dotnet:/dotnet -w /dotnet $COMPILE_ROOTFS_DIR \
mcr.microsoft.com/dotnet-buildtools/prereqs:${{ matrix.docker_tag }} \
./build.sh --clean-while-building --prep -sb --os ${{ matrix.runtime_os }} --rid ${{ matrix.runtime_os }}-${{ matrix.runtime_arch }} \
--arch ${{ matrix.runtime_arch }} ${{ inputs.is_rtm && '--branding rtm' || '' }}
- name: List assets directory
run: |
find "${{ github.workspace }}/dotnet/artifacts"
- name: Upload .NET
uses: actions/upload-artifact@v4
with:
name: dotnet-sdk-${{ matrix.name }}
if-no-files-found: error
compression-level: 0
path: |
${{ github.workspace }}/dotnet/artifacts/assets/Release/dotnet-sdk-*.tar.gz
${{ github.workspace }}/dotnet/artifacts/assets/Release/Private.SourceBuilt.Artifacts.*.tar.gz
release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
if: ${{ inputs.release }}
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Make release
run: |
sudo apt install -y hub
# hub(1) requires release to be created inside a git repo
git clone https://${{ secrets.CLONE_TOKEN }}:x-oauth-basic@github.com/${{ github.repository }}.git repo
cd repo
sdk_paths=$(find ${{ github.workspace }}/artifacts -name 'dotnet-sdk-*.tar.gz')
artifacts=""
for sdk_path in $sdk_paths; do
sdk_filename=$(basename "$sdk_path")
# Extract version: strip prefix/suffix to get e.g. "10.0.100-preview.5.25277.114"
sdk_version=$(echo "$sdk_filename" | sed -E 's/dotnet-sdk-([^-]+(-[^-]+)*)-linux-.+\.tar\.gz/\1/')
artifacts="$artifacts -a $sdk_path"
tag_name="$sdk_version"
done
echo "tag_name: $tag_name"
echo "artifacts: $artifacts"
# docs: https://hub.github.com/hub-release.1.html
hub release create $artifacts --prerelease -m "$tag_name" "$tag_name"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}