Skip to content

Commit

Permalink
Add workflow to build and release custom runtimes
Browse files Browse the repository at this point in the history
  • Loading branch information
jpdurot committed Oct 16, 2024
1 parent d9e673e commit 5ab437f
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 10 deletions.
139 changes: 139 additions & 0 deletions .github/workflows/build_and_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: Build and release runtime
on:
pull_request:
workflow_dispatch:
inputs:
tag:
type: string
description: Tagged version to build
push:
tags:
- 'v*-*'

jobs:
env-variables:
outputs:
runtime-version: ${{ steps.set-env.outputs.runtime-version }}
runtime-patch: ${{ steps.set-env.outputs.runtime-patch }}
code-version: ${{ steps.find-ref.outputs.ref-to-checkout }}
runs-on: ubuntu-latest

steps:
- name: Find version to checkout
id: find-ref
run: |
[ -n "${{github.event.inputs.tag}}" ] && TAG="refs/tags/${{github.event.inputs.tag}}"
[ -z "$TAG" ] && [ -n "${{github.ref}}" ] && TAG="${{github.ref}}"
echo ref-to-checkout=${TAG} >> $GITHUB_OUTPUT
- name: Check out runtime source code
uses: actions/checkout@v4
with:
ref: ${{steps.find-ref.outputs.ref-to-checkout}}
- name: Extract runtime version (from code) and patch (from github ref)
id: set-env
run: |
RUNTIME_VERSION=$(sed -n 's#.*<ProductVersion>\(.*\)</ProductVersion>#\1#p' < eng/Versions.props)
VERSION_CHECKOUT=${{steps.find-ref.outputs.ref-to-checkout}}
regex="refs\/.*\/v(.*)-(.*)"
if [[ "$VERSION_CHECKOUT" =~ $regex ]]
then
RUNTIME_PATCH=${BASH_REMATCH[2]}
else
RUNTIME_PATCH=dev
fi
echo RUNTIME_VERSION=${RUNTIME_VERSION}
echo RUNTIME_PATCH=${RUNTIME_PATCH}
echo runtime-version=${RUNTIME_VERSION} >> $GITHUB_OUTPUT
echo runtime-patch=${RUNTIME_PATCH} >> $GITHUB_OUTPUT
build-linux:
runs-on: ubuntu-latest
needs: env-variables
env:
RUNTIME_VERSION: ${{needs.env-variables.outputs.runtime-version}}
RUNTIME_PATCH: ${{needs.env-variables.outputs.runtime-patch}}
CODE_VERSION: ${{needs.env-variables.outputs.code-version}}
container:
image: mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream8
steps:
- name: Check out runtime source code
uses: actions/checkout@v4
with:
ref: ${{env.CODE_VERSION}}
- name: Build for Linux
run: ./build.sh -c Release /p:VersionSuffix=${{env.RUNTIME_PATCH}} /p:StabilizePackageVersion=false /p:OfficialBuildId=20201010.1 /p:NativeOptimizationDataSupported=false
- name : Download dotnet install scripts
run: wget https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.sh
- name: Retrieve official ASP.Net Core runtime
run: |
chmod u+x ./dotnet-install.sh
mkdir -p artifacts/packages/Release/Shipping/aspnetcore-runtime
./dotnet-install.sh --runtime aspnetcore --version ${{env.RUNTIME_VERSION}} --os linux --install-dir artifacts/packages/Release/Shipping/aspnetcore-runtime
- name: Extract generated runtime artifact, add crossgen, symbols, and AspNetCore runtime
run: |
FULL_VERSION=${{env.RUNTIME_VERSION}}-${{env.RUNTIME_PATCH}}
cd artifacts/packages/Release/Shipping
mkdir -p dotnet-runtime
cd dotnet-runtime
tar -xzvf ../dotnet-runtime-${FULL_VERSION}-linux-x64.tar.gz
cd shared/Microsoft.NETCore.App/${FULL_VERSION}
tar -xzvf ../../../../dotnet-crossgen2-${FULL_VERSION}-linux-x64.tar.gz
tar -xzvf ../../../../dotnet-nethost-symbols-linux-x64-${FULL_VERSION}.tar.gz
cd ../../../..
cp -R aspnetcore-runtime/shared/Microsoft.AspNetCore.App dotnet-runtime/shared/Microsoft.AspNetCore.App
mv dotnet-runtime/shared/Microsoft.AspNetCore.App/${{env.RUNTIME_VERSION}} dotnet-runtime/shared/Microsoft.AspNetCore.App/${FULL_VERSION}
sed -i "s/${{env.RUNTIME_VERSION}}/${FULL_VERSION}/g" dotnet-runtime/shared/Microsoft.AspNetCore.App/${FULL_VERSION}/Microsoft.AspNetCore.App.runtimeconfig.json
cd dotnet-runtime
tar -zcvf ../aspnetcore-runtime-${FULL_VERSION}-linux-x64.tar.gz .
- name: Upload runtime artifact
uses: actions/upload-artifact@v4
with:
name: linux-runtime
path: artifacts/packages/Release/Shipping/aspnetcore-runtime-${{env.RUNTIME_VERSION}}-${{env.RUNTIME_PATCH}}-linux-x64.tar.gz
build-windows:
runs-on: windows-latest
needs: env-variables
steps:
- name: Check out runtime source code
uses: actions/checkout@v4
with:
ref: ${{env.CODE_VERSION}}
- name: Build CLR for Windows
run: .\build.cmd clr -c Release /p:OfficialBuildId=20201010.1
- name: Upload mscordaccore artifact
uses: actions/upload-artifact@v4
with:
name: mscordaccore.dll
path: artifacts/bin/coreclr/Linux.x64.Release/x64/mscordaccore.dll
package-and-release:
runs-on: ubuntu-latest
if: needs.env-variables.outputs.runtime-patch != 'dev'
env:
RUNTIME_VERSION: ${{needs.env-variables.outputs.runtime-version}}
RUNTIME_PATCH: ${{needs.env-variables.outputs.runtime-patch}}
needs:
- env-variables
- build-linux
- build-windows
steps:
- name: Download .Net runtime artifact
uses: actions/download-artifact@v4
with:
name: linux-runtime
path: .
- name: Download mscordaccore artifact
uses: actions/download-artifact@v4
with:
name: mscordaccore.dll
path: .
- name: Create release
uses: softprops/action-gh-release@v2
with:
name: v${{env.RUNTIME_VERSION}}-${{env.RUNTIME_PATCH}}
body: Release of custom runtime v${{env.RUNTIME_VERSION}}-${{env.RUNTIME_PATCH}}
files: |
aspnetcore-runtime-${{env.RUNTIME_VERSION}}-${{env.RUNTIME_PATCH}}-linux-x64.tar.gz
mscordaccore.dll
draft: true
10 changes: 0 additions & 10 deletions .github/workflows/manual_build.yml

This file was deleted.

0 comments on commit 5ab437f

Please sign in to comment.