Skip to content

Add c cast

Add c cast #4

name: Build & Publish
on:
push:
branches: ["main", "dev"]
pull_request:
branches: ["main", "dev"]
env:
BUILD_TYPE: Release
jobs:
setup:
permissions:
contents: write
runs-on: ubuntu-latest
outputs:
buildnumber: ${{ steps.buildnumber.outputs.build_number }}
steps:
- name: Generate build number
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
id: buildnumber
uses: onyxmueller/build-tag-number@v1
with:
token: ${{secrets.github_token}}
build_windows:
needs: setup
runs-on: windows-latest
steps:
- name: Prepare env
shell: bash
run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Visual Studio environment
shell: cmd
run: |
:: See https://github.com/microsoft/vswhere/wiki/Find-VC
for /f "usebackq delims=*" %%i in (`vswhere -latest -property installationPath`) do (
call "%%i"\Common7\Tools\vsdevcmd.bat -arch=x64 -host_arch=x64
)
:: Loop over all environment variables and make them global.
for /f "delims== tokens=1,2" %%a in ('set') do (
echo>>"%GITHUB_ENV%" %%a=%%b
)
- uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Build
run: |
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DMONOLM_VERSION="${{ needs.setup.outputs.buildnumber }}" -DMONOLM_PACKAGE="dotnetlm-build-${{ needs.setup.outputs.buildnumber }}-windows-${{ env.GITHUB_SHA_SHORT }}" ..
cmake --build . --target dotnet-lang-module --config ${{ env.BUILD_TYPE }} -- /m:16
- name: Clean build directory
shell: pwsh
run: |
mkdir -p build/output/bin
cp build/${{env.BUILD_TYPE}}/dotnet-lang-module.dll build/output/bin
cp build/dotnet-lang-module.pmodule build/output
- uses: actions/upload-artifact@v3
with:
name: dotnetlm-build-windows-${{ env.GITHUB_SHA_SHORT }}
path: build/output/
build_linux:
needs: setup
runs-on: ubuntu-latest
steps:
- name: Prepare env
shell: bash
run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
- uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Install CURL
run: sudo apt install -y libcurl4-openssl-dev
- name: Build
run: |
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DMONOLM_VERSION="${{ needs.setup.outputs.buildnumber }}" -DMONOLM_PACKAGE="dotnetlm-build-${{ needs.setup.outputs.buildnumber }}-linux-${{ env.GITHUB_SHA_SHORT }}" ..
cmake --build . --target dotnet-lang-module --config ${{ env.BUILD_TYPE }} -- -j16
- name: Clean build directory
run: |
mkdir -p build/output/bin
mv build/libdotnet-lang-module.so build/output/bin
mv build/dotnet-lang-module.pmodule build/output
- uses: actions/upload-artifact@v3
with:
name: dotnetlm-build-linux-${{ env.GITHUB_SHA_SHORT }}
path: build/output/
build_managed:
needs: setup
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Prepare env
shell: bash
run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Main build number
run: echo "BUILD_NUMBER=${{ needs.setup.outputs.buildnumber }}" >> $GITHUB_ENV
- uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Install .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.0.x"
- name: Publish artifacts v${{ env.BUILD_NUMBER }}
run: |
dotnet publish -c Release /p:Version=1.0.${{ env.BUILD_NUMBER }} managed/Plugify
dotnet pack -c Release /p:Version=1.0.${{ env.BUILD_NUMBER }} managed/Plugify
- uses: actions/upload-artifact@v3
with:
name: dotnetlm-build-api-${{ env.GITHUB_SHA_SHORT }}
path: managed/Plugify/bin/Release
publish:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
permissions:
contents: write
needs: ["setup", "build_linux", "build_windows", "build_managed"]
runs-on: ubuntu-latest
steps:
- name: Prepare env
shell: bash
run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Main build number
run: echo "BUILD_NUMBER=${{ needs.setup.outputs.buildnumber }}" >> $GITHUB_ENV
- uses: actions/download-artifact@v3
with:
name: dotnetlm-build-windows-${{ env.GITHUB_SHA_SHORT }}
path: build/windows
- uses: actions/download-artifact@v3
with:
name: dotnetlm-build-linux-${{ env.GITHUB_SHA_SHORT }}
path: build/linux
- uses: actions/download-artifact@v3
with:
name: dotnetlm-build-api-${{ env.GITHUB_SHA_SHORT }}
path: build/api
- name: Add API to Artifacts
run: |
mkdir -p build/linux/api
mkdir -p build/windows/api
cp -r build/api/net8.0/publish/* build/linux/api
cp -r build/api/net8.0/publish/* build/windows/api
- name: Add dotnet runtime
run: |
mkdir -p build/linux/dotnet
curl -s -L https://download.visualstudio.microsoft.com/download/pr/c1371dc2-eed2-47be-9af3-ae060dbe3c7d/bd509e0a87629764ed47608466d183e6/aspnetcore-runtime-8.0.3-linux-x64.tar.gz \
| tar xvz -C build/linux/dotnet
mkdir -p build/windows/dotnet
curl -s -L https://download.visualstudio.microsoft.com/download/pr/086d1dd6-57a5-437a-a1ef-549cf702fb48/dd4a8fe6c53a1016a414d6f2925c1323/aspnetcore-runtime-8.0.3-win-x64.zip -o dotnet.zip
unzip -qq dotnet.zip -d build/windows/dotnet
- name: Zip Builds
run: |
(cd build/linux && zip -qq -r ../../dotnetlm-build-${{ env.BUILD_NUMBER }}-linux-${{ env.GITHUB_SHA_SHORT }}.zip *)
(cd build/windows && zip -qq -r ../../dotnetlm-build-${{ env.BUILD_NUMBER }}-windows-${{ env.GITHUB_SHA_SHORT }}.zip *)
- name: Publish NuGet package
run: |
dotnet nuget push build/api/Plugify.1.0.${{ env.BUILD_NUMBER }}.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
dotnet nuget push build/api/Plugify.1.0.${{ env.BUILD_NUMBER }}.snupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Release
id: release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ env.BUILD_NUMBER }}
files: |
dotnetlm-build-${{ env.BUILD_NUMBER }}-windows-${{ env.GITHUB_SHA_SHORT }}.zip
dotnetlm-build-${{ env.BUILD_NUMBER }}-linux-${{ env.GITHUB_SHA_SHORT }}.zip
- name: Send Notification to Discord
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/[email protected]
with:
args: "A new release of C# (.NET) Language Module has been tagged (v${{ env.BUILD_NUMBER }}) at ${{ steps.release.outputs.url }}"