Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
chore: update release CI script
Browse files Browse the repository at this point in the history
  • Loading branch information
Nambers committed Apr 6, 2023
1 parent d3aa35a commit 34c6b3c
Showing 1 changed file with 172 additions and 29 deletions.
201 changes: 172 additions & 29 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,54 +12,59 @@ on:
description: pre-release
default: false
type: boolean
skipTest:
description: skip-test
type: boolean
default: false
required: false
# skipTest:
# description: skip-test
# type: boolean
# default: false
# required: false

jobs:
build-libLoader-msvc-4-windows:
if: ${{ github.event.inputs.clean == 'false' }}
runs-on: windows-2019
steps:
- name: checkout
uses: actions/checkout@v2
- name: checkout
uses: actions/checkout@v3
- name: Set up MSVC
uses: ilammy/msvc-dev-cmd@v1.12.0
with:
arch: amd64
vsversion: 2019
- name: configure
run: mkdir cpp/build && cd cpp/build && cmake -DCMAKE_BUILD_TYPE=Release -DGOOGLE_TEST=OFF ..
- name: build with msvc
run: cd ./cpp && cmake --build build --target generateSingleHeaders && cmake --build build --config Release --target Loader
- name: build with gcc
run: ./scripts/WIN/cppBuilds.bat libLoaderNative
- name: copy out
run: copy ./cpp/build/Release/*.dll && copy ./cpp/build/Release/*.lib
- name: upload
uses: actions/upload-artifact@v3
with:
name: libLoaderdll
path: ./cpp/build/Release/libLoader.dll
path: |
./*.dll
./*.lib
build-libLoader-gcc-4-linux:
if: ${{ github.event.inputs.clean == 'false' }}
runs-on: ubuntu-20.04
steps:
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up GCC
uses: egor-tensin/setup-gcc@v1
with:
version: 9
platform: x64
- name: configure
env:
cc: gcc
cxx: g++
run: mkdir cpp/build && cd cpp/build && cmake -DCMAKE_BUILD_TYPE=Release -DGOOGLE_TEST=OFF ..
- name: print glibc version
run: ldd --version
- name: build with gcc
run: cd cpp/build && make generateSingleHeaders && make Loader
run: ./scripts/LINUX/cppBuilds.sh libLoaderNative
- name: copy out
run: cp ./cpp/build/*.so ./ && cp /lib/x86_64-linux-gnu/libcrypt.so.1 ./
- name: upload
uses: actions/upload-artifact@v3
with:
name: libLoaderso
path: ./cpp/build/libLoader.so
path: |
./*.so
./libcrypt.so.1
push-single-include-2-template:
runs-on: ubuntu-20.04
steps:
Expand Down Expand Up @@ -97,16 +102,154 @@ jobs:
FOLDER: ./template # The directory where your assets are generated
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
MESSAGE: ${{ github.event.inputs.v }} # The commit message


build-native:
name: "build Native (${{ matrix.os }})"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- windows-latest
- ubuntu-20.04
include:
- os: windows-latest
targetName: mingwX64
- os: ubuntu-20.04
targetName: linuxX64
env:
isWindows: ${{ startsWith(matrix.os, 'windows') }}
isUbuntu: ${{ startsWith(matrix.os, 'ubuntu') }}
VCPKG_DEFAULT_BINARY_CACHE: ${{ startsWith(matrix.os, 'windows') && 'C:\vcpkg\binary_cache' || '/usr/local/share/vcpkg/binary_cache' }}
steps:
- name: checkout
uses: actions/checkout@v3
- name: Set up JDK 15
uses: actions/setup-java@v2
with:
java-version: '15'
distribution: 'adopt'

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
# with:
# cache-read-only: ${{ github.ref != 'refs/heads/main' }}

- name: Cache konan
uses: pat-s/always-upload-cache@v3
with:
path: ~/.konan
key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Prepare to cache vcpkg
if: ${{ env.isWindows == 'true' }}
run: mkdir -p ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}

- name: Cache vcpkg
if: ${{ env.isWindows == 'true' }}
uses: pat-s/always-upload-cache@v3
with:
path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
key: ${{ runner.os }}-vcpkg-binary-cache-${{ github.job }}
restore-keys: |
${{ runner.os }}-vcpkg-binary-cache-
- name: Install OpenSSL on Ubuntu
if: ${{ env.isUbuntu == 'true' }}
run: sudo apt install libssl-dev -y

# Prepare environment for linking on Windows
- name: Setup Memory Environment on Windows
if: ${{ env.isWindows == 'true' }}
run: >
wmic pagefileset where name="D:\\pagefile.sys" set InitialSize=1024,MaximumSize=9216
shell: cmd
continue-on-error: true

- name: Install OpenSSL & cURL on Windows
if: ${{ env.isWindows == 'true' }}
run: |
echo "set(VCPKG_BUILD_TYPE release)" | Out-File -FilePath "$env:VCPKG_INSTALLATION_ROOT\triplets\x64-windows.cmake" -Encoding utf8 -Append
vcpkg install openssl:x64-windows curl[core,ssl]:x64-windows
New-Item -Path $env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\lib\crypto.lib -ItemType SymbolicLink -Value $env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\lib\libcrypto.lib
New-Item -Path $env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\lib\ssl.lib -ItemType SymbolicLink -Value $env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\lib\libssl.lib
New-Item -Path $env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\lib\curl.lib -ItemType SymbolicLink -Value $env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\lib\libcurl.lib
echo "$env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: chmod
if: ${{ env.isUbuntu == 'true' }}
run: chmod -R 777 *
- name: replace def file
uses: Nambers/ReplaceStringInFile@v1.3
with:
path: ${{ github.workspace }}/kotlin/shared/src/nativeInterop/cinterop/localMiraiCP.def
oldString: GITHUB_WORKSPACE
newString: ${{ github.workspace }}
escapeBackslash: true
showFileContent: true
# - name: replace MiraiCP lib path of def file linux
# if: ${{ env.isUbuntu == 'true' }}
# run: sed -i 's|GITHUB_WORKSPACE|${{ github.workspace }}|g' '${{ github.workspace }}/kotlin/shared/src/nativeInterop/cinterop/localMiraiCP.def' && cat ${{ github.workspace }}/kotlin/shared/src/nativeInterop/cinterop/localMiraiCP.def
# - name: replace MiraiCP lib path of def file win
# if: ${{ env.isWindows == 'true' }}
# run: $path = "${{ github.workspace }}"; $path=$path.Replace("`\", "/"); (Get-Content ${{ github.workspace }}\kotlin\shared\src\nativeInterop\cinterop\localMiraiCP.def) -replace 'GITHUB_WORKSPACE', $path | Set-Content -encoding ASCII ${{ github.workspace }}\kotlin\shared\src\nativeInterop\cinterop\localMiraiCP.def && type ${{ github.workspace }}/kotlin/shared/src/nativeInterop/cinterop/localMiraiCP.def
- name: compile native
run: cd ./kotlin/ && ./gradlew MiraiCP-loader:compileKotlinNative --warning-mode all --info --stacktrace
- name: libLoaderNativeWin
if: ${{ env.isWindows == 'true' }}
uses: actions/download-artifact@v3
with:
name: libLoaderdll
path: ${{ github.workspace }}
- name: libLoaderNativeLinux
if: ${{ env.isUbuntu == 'true' }}
uses: actions/download-artifact@v3
with:
name: libLoaderso
path: ${{ github.workspace }}
- name: link native
run: cd ./kotlin/ && ./gradlew MiraiCP-loader:linkDebugExecutableNative --warning-mode all --info --stacktrace

- name: packing - linux
if: ${{ env.isUbuntu == 'true' }}
run: |
zip -j LoaderNativeLinux.zip \
${{ github.workspace }}/kotlin/loader/build/bin/native/debugExecutable/*.kexe \
libcrypt.so.1 \
libLoaderNative.so \
${{ github.workspace }}/kotlin/loader/src/nativeMain/kotlin/scripts/runMiraiCP.sh \;
- name: packing -win
if: ${{ env.isWindows == 'true' }}
run: copy ${{ github.workspace }}/kotlin/loader/build/bin/native/debugExecutable/*.exe && tar -cvf LoaderNativeWindows.zip *.exe libLoaderNative.dll
- name: upload
if: ${{ env.isWindows == 'true' }}
uses: actions/upload-artifact@v3
with:
name: winOutput
path: |
./LoaderNativeWindows.zip
./libLoader.dll
- name: upload
if: ${{ env.isUbuntu == 'true' }}
uses: actions/upload-artifact@v3
with:
name: linuxOutput
path: |
./LoaderNativeLinux.zip
./libLoader.so

publish-release:
needs: [build-libLoader-msvc-4-windows, build-libLoader-gcc-4-linux]
needs: [build-native]
runs-on: ubuntu-20.04
steps:
- name: loadTest
if: ${{ !github.event.inputs.skipTest }}
uses: ./.github/workflows/loadTest.yml
# - name: loadTest
# if: ${{ !github.event.inputs.skipTest }}
# uses: ./.github/workflows/loadTest.yml
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: permission
run: chmod -R 777 *
- name: Set up JDK 15
Expand All @@ -130,16 +273,16 @@ jobs:
run: cat release.log
- uses: actions/download-artifact@v3
with:
name: libLoaderdll
name: winOutput
path: ./
- uses: actions/download-artifact@v3
with:
name: libLoaderso
name: linuxOutput
path: ./
- name: Create Release
uses: ncipollo/release-action@v1.8.6
with:
artifacts: ./kotlin/loader/build/libs/MiraiCP-loader-*.jar,./kotlin/plugin/build/mirai/MiraiCP-plugin-*.mirai2.jar,./libLoader.dll,./libLoader.so
artifacts: ./kotlin/loader/build/libs/MiraiCP-loader-*.jar,./kotlin/plugin/build/mirai/MiraiCP-plugin-*.mirai2.jar,./libLoader.dll,./libLoader.so,./LoaderNativeLinux.zip,./LoaderNativeWindows.zip
bodyfile: release.log
tag: ${{ github.event.inputs.v }}
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down

0 comments on commit 34c6b3c

Please sign in to comment.