Skip to content

Commit

Permalink
Merge pull request #25 from HyperInspire/feature/ci
Browse files Browse the repository at this point in the history
Auto-Build Actions
  • Loading branch information
tunmx authored May 6, 2024
2 parents 358b388 + 3af7a5c commit 5ee6193
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 31 deletions.
49 changes: 33 additions & 16 deletions .github/workflows/built_release_from_docker.yaml
Original file line number Diff line number Diff line change
@@ -1,68 +1,85 @@
name: Build and Release SDKs

# Trigger the workflow when pushing tags that match the pattern "v*"
on:
push:
tags:
- "v*" # 当推送符合 "v*" 模式的标签时触发
- "v*"

# Set the global GitHub token environment variable
env:
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}

jobs:
build:
name: Compile and Package SDKs
runs-on: ubuntu-latest

steps:
# Step 1: Checkout the repository
- name: Checkout Repository
uses: actions/checkout@v4

# Step 2: Update Git submodules recursively
# Step 2: Synchronize and update submodules recursively
- name: Update submodules
run: |
git submodule sync --recursive # Ensure submodule paths are up-to-date
git submodule update --init --recursive # Initialize and update all submodules
# 使用 Docker Compose 构建项目
# Step 3: Extract the version number from the tag (e.g., "v1.2.3" becomes "1.2.3")
- name: Extract Version Number
id: extract_version
run: echo "VERSION=$(echo ${GITHUB_REF#refs/tags/} | sed 's/^v//')" >> $GITHUB_ENV

# Step 4: Rename directories with the extracted version number
- name: Rename SDK Directories with Version
run: |
mv build/inspireface-linux-armv7-armhf build/inspireface-linux-armv7-armhf-${{ env.VERSION }}
mv build/inspireface-linux-armv7-rv1109rv1126-armhf build/inspireface-linux-armv7-rv1109rv1126-armhf-${{ env.VERSION }}
mv build/inspireface-linux-ubuntu18 build/inspireface-linux-ubuntu18-${{ env.VERSION }}
# Step 5: Build projects using Docker Compose
- name: Build SDKs with Docker Compose
run: docker-compose up

# 压缩每个 SDK 目录
# Step 6: Zip each SDK directory with the version number
- name: Zip SDK Files
run: |
zip -r linux_armv7_armhf.zip build/linux_armv7_armhf/
zip -r linux_rv1109rv1126_armhf.zip build/linux_rv1109rv1126_armhf/
zip -r linux_ubuntu18.zip build/linux_ubuntu18/
zip -r inspireface-linux-armv7-armhf-${{ env.VERSION }}.zip build/inspireface-linux-armv7-armhf-${{ env.VERSION }}
zip -r inspireface-linux-armv7-rv1109rv1126-armhf-${{ env.VERSION }}.zip build/inspireface-linux-armv7-rv1109rv1126-armhf-${{ env.VERSION }}
zip -r inspireface-linux-ubuntu18-${{ env.VERSION }}.zip build/inspireface-linux-ubuntu18-${{ env.VERSION }}
# 上传打包文件以供发布任务使用
# Step 7: Upload the zipped SDK files for the next job
- name: Upload SDK Artifacts
uses: actions/upload-artifact@v2
with:
name: sdk_files
path: |
linux_armv7_armhf.zip
linux_rv1109rv1126_armhf.zip
linux_ubuntu18.zip
inspireface-linux-armv7-armhf-${{ env.VERSION }}.zip
inspireface-linux-armv7-rv1109rv1126-armhf-${{ env.VERSION }}.zip
inspireface-linux-ubuntu18-${{ env.VERSION }}.zip
release:
name: Release SDKs to GitHub
needs: build
runs-on: ubuntu-latest

steps:
# Step 1: Checkout the repository again
- name: Checkout Repository
uses: actions/checkout@v2

# 下载上一个步骤上传的 SDK 文件
# Step 2: Download the previously uploaded SDK files
- name: Download SDK Artifacts
uses: actions/download-artifact@v2
with:
name: sdk_files

# 创建 GitHub Release 并上传 SDK 文件
# Step 3: Create a GitHub Release and upload SDK files with the version number
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: |
linux_armv7_armhf.zip
linux_rv1109rv1126_armhf.zip
linux_ubuntu18.zip
inspireface-linux-armv7-armhf-${{ env.VERSION }}.zip
inspireface-linux-armv7-rv1109rv1126-armhf-${{ env.VERSION }}.zip
inspireface-linux-ubuntu18-${{ env.VERSION }}.zip
12 changes: 6 additions & 6 deletions command/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,32 @@ SCRIPT_DIR=$(pwd) # Project dir
case "$OS_NAME" in
Darwin)
# macOS system
BUILD_DIR="${BUILD_DIR}/macos"
BUILD_DIR="${BUILD_DIR}/inspireface-macos"
;;
Linux)
# Linux system, further identify the distribution if necessary
if [ -f /etc/os-release ]; then
. /etc/os-release
case "$ID" in
ubuntu)
BUILD_DIR="${BUILD_DIR}/linux_ubuntu"
BUILD_DIR="${BUILD_DIR}/inspireface-linux-ubuntu"
;;
centos)
BUILD_DIR="${BUILD_DIR}/linux_centos"
BUILD_DIR="${BUILD_DIR}/inspireface-linux-centos"
;;
*)
# If an unknown Linux distribution, default to generic 'linux'
BUILD_DIR="${BUILD_DIR}/linux"
BUILD_DIR="${BUILD_DIR}/inspireface-linux"
;;
esac
else
# If unable to detect Linux distribution, default to 'linux'
BUILD_DIR="${BUILD_DIR}/linux"
BUILD_DIR="${BUILD_DIR}/inspireface-linux"
fi
;;
*)
# If OS is not recognized, default to 'generic'
BUILD_DIR="${BUILD_DIR}/generic"
BUILD_DIR="${BUILD_DIR}/inspireface-generic"
;;
esac

Expand Down
5 changes: 3 additions & 2 deletions command/build_cross_armv7_armhf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ move_install_files() {
}

SCRIPT_DIR=$(pwd) # Project dir
BUILD_FOLDER_PATH="build/inspireface-linux-armv7-armhf"

mkdir -p build/linux_armv7_armhf
mkdir -p ${BUILD_FOLDER_PATH}
# shellcheck disable=SC2164
cd build/linux_armv7_armhf
cd ${BUILD_FOLDER_PATH}
# export cross_compile_toolchain=/home/jingyuyan/software/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf
cmake -DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_BUILD_TYPE=Release \
Expand Down
6 changes: 4 additions & 2 deletions command/build_cross_rv1109rv1126_armhf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ move_install_files() {
}

SCRIPT_DIR=$(pwd) # Project dir
BUILD_FOLDER_PATH="build/inspireface-linux-armv7-rv1109rv1126-armhf"

mkdir -p build/linux_rv1109rv1126_armhf
mkdir -p ${BUILD_FOLDER_PATH}
# shellcheck disable=SC2164
cd build/linux_rv1109rv1126_armhf
cd ${BUILD_FOLDER_PATH}

# export cross_compile_toolchain=/home/jingyuyan/software/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf
cmake -DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_BUILD_TYPE=Release \
Expand Down
6 changes: 3 additions & 3 deletions command/build_linux_cuda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ move_install_files() {
echo "Files from 'install' moved to $root_dir, and 'install' directory deleted."
}


BUILD_FOLDER_PATH="build/inspireface-linux-cuda"
SCRIPT_DIR=$(pwd) # Project dir

mkdir -p build/linux_cuda
mkdir -p ${BUILD_FOLDER_PATH}
# shellcheck disable=SC2164
cd build/linux_cuda
cd ${BUILD_FOLDER_PATH}

cmake -DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_BUILD_TYPE=Release \
Expand Down
5 changes: 3 additions & 2 deletions command/build_linux_ubuntu18.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ move_install_files() {
echo "Files from 'install' moved to $root_dir, and 'install' directory deleted."
}

BUILD_FOLDER_PATH="build/inspireface-linux-ubuntu18/"
SCRIPT_DIR=$(pwd) # Project dir

mkdir -p build/linux_ubuntu18/
mkdir -p ${BUILD_FOLDER_PATH}
# shellcheck disable=SC2164
cd build/linux_ubuntu18/
cd ${BUILD_FOLDER_PATH}

cmake -DCMAKE_BUILD_TYPE=Release \
-DISF_BUILD_WITH_SAMPLE=ON \
Expand Down

0 comments on commit 5ee6193

Please sign in to comment.