Skip to content

Commit

Permalink
Add: CI for build
Browse files Browse the repository at this point in the history
  • Loading branch information
nutti committed Dec 10, 2023
1 parent 5b58d07 commit ca86e81
Show file tree
Hide file tree
Showing 5 changed files with 424 additions and 0 deletions.
167 changes: 167 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
---
# yamllint disable rule:line-length
workflows:
version: 2.1
build:
jobs:
- functional-test-plugin:
context:
- unreal-engine-ci
matrix:
parameters:
unreal-engine-version: ["5.3.0"]
version: ["full"]
- build-plugin:
context:
- unreal-engine-ci
matrix:
parameters:
unreal-engine-version: [
"4.27.0", "5.0.0", "5.1.0", "5.2.0", "5.3.0"
]
version: ["free", "full"]
- build-sample:
context:
- unreal-engine-ci
matrix:
parameters:
unreal-engine-version: ["5.3.0"]
version: ["full"]

version: 2.1
jobs:
# functional-test-plugin:
# parameters:
# unreal-engine-version:
# type: string
# version:
# type: string
# docker:
# - image: ghcr.io/epicgames/unreal-engine:dev-slim-<< parameters.unreal-engine-version >>
# auth:
# username: $GHCR_USERNAME
# password: $GHCR_PASSWORD
# steps:
# - checkout
# - run:
# name: Run scripts for the license removing
# command: bash tools/remove_license.sh BlueprintToRSTDoc << parameters.version >>
# - run:
# name: Run scripts for the code removing
# command: bash tools/remove_code.sh BlueprintToRSTDoc << parameters.unreal-engine-version >> << parameters.version >> .
# - run:
# name: "Run scripts for the release"
# command: bash tools/replace_engine_version.sh BlueprintToRSTDoc << parameters.unreal-engine-version >>
# - run:
# name: "Copy plugin"
# command: |
# mkdir ${PWD}/tests/functional_test/FunctionalTest/Plugins
# cp -r BlueprintToRSTDoc ${PWD}/tests/functional_test/FunctionalTest/Plugins
# - run:
# name: "Build project"
# command: |
# /home/ue4/UnrealEngine/Engine/Build/BatchFiles/RunUAT.sh BuildCookRun \
# -utf8output \
# -platform=Linux \
# -clientconfig=Shipping \
# -serverconfig=Shipping \
# -project=${PWD}/tests/functional_test/FunctionalTest/FunctionalTest.uproject \
# -noP4 \
# -nodebuginfo \
# -allmaps \
# -cook \
# -build \
# -stage \
# -prereqs \
# -pak \
# -archive \
# -archivedirectory=/tmp/Packaged
# - run:
# name: "Functional test against Plugin"
# command: |
# /home/ue4/UnrealEngine/Engine/Binaries/Linux/UnrealEditor \
# ${PWD}/tests/functional_test/FunctionalTest/FunctionalTest.uproject \
# -unattended \
# -nopause \
# -NullRHI \
# -ExecCmds="Automation RunTests BlueprintToRSTDoc; Quit" \
# -testexit="Automation Test Queue Empty" \
# -log=RunTests.log \
# -ReportOutputPath="/tmp/FunctionalTestsReport"

build-plugin:
parameters:
unreal-engine-version:
type: string
version:
type: string
docker:
- image: ghcr.io/epicgames/unreal-engine:dev-slim-<< parameters.unreal-engine-version >>
auth:
username: $GHCR_USERNAME
password: $GHCR_PASSWORD
steps:
- checkout
- run:
name: Run scripts for the license removing
command: bash tools/remove_license.sh BlueprintToRSTDoc << parameters.version >>
- run:
name: Run scripts for the code removing
command: bash tools/remove_code.sh BlueprintToRSTDoc << parameters.unreal-engine-version >> << parameters.version >> .
- run:
name: "Run scripts for the release"
command: bash tools/replace_engine_version.sh BlueprintToRSTDoc << parameters.unreal-engine-version >>
- run:
name: "Build Plugin"
command: |
/home/ue4/UnrealEngine/Engine/Build/BatchFiles/RunUAT.sh BuildPlugin \
-Plugin=${PWD}/BlueprintToRSTDoc/BlueprintToRSTDoc.uplugin \
-Package=/tmp \
-Rocket
build-sample:
parameters:
unreal-engine-version:
type: string
version:
type: string
docker:
- image: ghcr.io/epicgames/unreal-engine:dev-slim-<< parameters.unreal-engine-version >>
auth:
username: $GHCR_USERNAME
password: $GHCR_PASSWORD
steps:
- checkout
- run:
name: Run scripts for the license removing
command: bash tools/remove_license.sh BlueprintToRSTDoc << parameters.version >>
- run:
name: Run scripts for the code removing
command: bash tools/remove_code.sh BlueprintToRSTDoc << parameters.unreal-engine-version >> << parameters.version >> .
- run:
name: "Run scripts for the release"
command: bash tools/replace_engine_version.sh BlueprintToRSTDoc << parameters.unreal-engine-version >>
- run:
name: "Copy plugin sources"
command: |
mkdir ${PWD}/samples/SampleProject/Plugins
cp -r BlueprintToRSTDoc ${PWD}/samples/SampleProject/Plugins
- run:
name: "Build Sample"
command: |
/home/ue4/UnrealEngine/Engine/Build/BatchFiles/RunUAT.sh BuildCookRun \
-utf8output \
-platform=Linux \
-clientconfig=Shipping \
-serverconfig=Shipping \
-project=${PWD}/samples/SampleProject/SampleProject.uproject \
-noP4 \
-nodebuginfo \
-allmaps \
-cook \
-build \
-stage \
-prereqs \
-pak \
-archive \
-archivedirectory=/tmp/Packaged
100 changes: 100 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Release

on:
workflow_dispatch:
push:
branches:
- main
- 'run-ci/**'
tags:
- 'v*'
pull_request:

jobs:
plugin-pack:
name: Pack plugin sources
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
unreal_engine_version:
["4.27.0", "5.0.0", "5.1.0", "5.2.0", "5.3.0"]
version:
["free", "full"]
steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Run scripts for the license removing
run: |
bash tools/remove_license.sh BlueprintToRSTDoc ${{ matrix.version }}
- name: Run scripts for the code removing
run: |
bash tools/remove_code.sh BlueprintToRSTDoc ${{ matrix.unreal_engine_version }} ${{ matrix.version }} .
- name: Run scripts for the release
run: |
bash tools/replace_engine_version.sh BlueprintToRSTDoc ${{ matrix.unreal_engine_version }}
- name: Compress plugin's sources
run: |
mkdir release-plugin-${{ matrix.version }}
zip -r BlueprintToRSTDoc_UE${{ matrix.unreal_engine_version }}_${{ matrix.version }}.zip BlueprintToRSTDoc
mv BlueprintToRSTDoc_UE${{ matrix.unreal_engine_version }}_${{ matrix.version }}.zip release-plugin-${{ matrix.version }}
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: BlueprintToRSTDoc_${{ matrix.version }}
path: "release-plugin-${{ matrix.version }}"

sample-pack:
name: Pack sample sources
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Compress sample project's sources
run: |
mkdir release-sample
cd samples && zip -r SampleProject.zip SampleProject && cd ..
mv samples/SampleProject.zip release-sample
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: SampleProject
path: "release-sample"

publish:
name: Publish
needs: [plugin-pack, sample-pack]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Fetch Artifacts
uses: actions/download-artifact@v2
with:
path: dist
- name: Install hub command
run: |
sudo apt update
sudo apt install -y hub
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_FOR_ACTIONS }}
run: |
set -x
assets=()
for asset in dist/BlueprintToRSTDoc_free/*.zip; do
assets+=("-a" "$asset")
done
for asset in dist/SampleProject/*.zip; do
assets+=("-a" "$asset")
done
tag_name="${GITHUB_REF##*/}"
hub release create "${assets[@]}" -m "$tag_name" "$tag_name"
89 changes: 89 additions & 0 deletions tools/remove_code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env bash
# require: bash version >= 4
# usage example: bash remove_code.sh src 4.27 full output
set -eEu


SUPPORTED_VERSIONS=(
"4.26.0" "4.27.0"
"5.0.0" "5.1.0" "5.2.0" "5.3.0"
)

function usage() {
echo "Usage: bash replace_ENGINE_VERSION.sh <source-directory> <engine-version> <full|free> <output-directory>"
}

if [ $# -ne 4 ]; then
usage
exit 1
fi

SOURCE_DIR=${1}
ENGINE_VERSION=${2}
FULL=0
if [ "${3}" = "full" ]; then
FULL=1
fi
OUTPUT_DIR=${4}
TMP_DIR=$(mktemp -d)

supported=0
for v in "${SUPPORTED_VERSIONS[@]}"; do
if [ "${v}" = "${ENGINE_VERSION}" ]; then
supported=1
fi
done
if [ ${supported} -eq 0 ]; then
echo "${ENGINE_VERSION} is not supported."
echo "Supported version is ${SUPPORTED_VERSIONS[*]}"
exit 1
fi

mkdir -p "${OUTPUT_DIR}"

remove_start_version_regex="[^\S]*//[^\S]*@remove-start[^\S]+UE_VERSION=([0-9.,]+)"
remove_start_full_regex="[^\S]*//[^\S]*@remove-start[^\S]+FULL_VERSION=true"
remove_end_regex="[^\S]*//[^\S]*@remove-end"
enable_delete=0
# shellcheck disable=SC2044
for file in $(find "${SOURCE_DIR}" -name "*.cpp" -or -name "*.h" -or -name "*.cs"); do
in_dir_path=$(dirname "${file}")
tmp_dir_path="${TMP_DIR}/${in_dir_path}"
mkdir -p "${tmp_dir_path}"

tmp_file_path="${TMP_DIR}/${file}"
while IFS= read -r line || [ -n "${line}" ]; do
if [[ "$line" =~ $remove_start_version_regex ]]; then
versions=${BASH_REMATCH[1]}
versions=${versions//,/ }

for version in "${versions[@]}"; do
if [[ ${version} = "${ENGINE_VERSION}" ]]; then
enable_delete=1
break
fi
done
elif [ ${FULL} -eq 1 ] && [[ "$line" =~ $remove_start_full_regex ]]; then
enable_delete=1
fi

if [[ $enable_delete -eq 0 ]]; then
echo "${line}" >> "${tmp_file_path}"
fi

if [[ "$line" =~ $remove_end_regex ]]; then
enable_delete=0
fi

done < "${file}"

echo "Remove code in ${file} >> ${tmp_file_path}"
done

# shellcheck disable=SC2044
for file in $(find "${TMP_DIR}" -name "*.cpp" -or -name "*.h" -or -name "*.cs"); do
out_file_path=${file/${TMP_DIR}/${OUTPUT_DIR}}
cp "${file}" "${out_file_path}"
echo "Copy file ${file} -> ${out_file_path}"
done

28 changes: 28 additions & 0 deletions tools/remove_license.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
# require: bash version >= 4
# usage example: bash remove_license.sh src full
set -eEu


function usage() {
echo "Usage: bash remove_license.sh <source-directory> <full|free>"
}

if [ $# -ne 2 ]; then
usage
exit 1
fi

SOURCE_DIR=${1}
FULL=0
if [ "${2}" = "full" ]; then
FULL=1
fi

if [ ${FULL} -eq 1 ]; then
# shellcheck disable=SC2044
for file in $(find "${SOURCE_DIR}" -name "*.cpp" -or -name "*.h" -or -name "*.cs"); do
sed -i -z -e "s/\s*\\*\s*This software is released under the MIT License.*\s*\\*\s*https:\\/\\/opensource.org\\/licenses\\/MIT//g" "${file}"
echo "Removed license in ${file}"
done
fi
Loading

0 comments on commit ca86e81

Please sign in to comment.