From 69de8727c0404325b6c86dfb54f2fe90cb51da24 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Fri, 14 Jun 2024 16:13:22 +0900 Subject: [PATCH] Add workflow to build for tag release Builds both static/shared versions of library. --- .forgejo/workflows/release-and-assets.yml | 89 +++++++++++++++++++++++ CMakeLists.txt | 2 +- Changelog.md | 5 ++ 3 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 .forgejo/workflows/release-and-assets.yml diff --git a/.forgejo/workflows/release-and-assets.yml b/.forgejo/workflows/release-and-assets.yml new file mode 100644 index 0000000..c27017d --- /dev/null +++ b/.forgejo/workflows/release-and-assets.yml @@ -0,0 +1,89 @@ +name: Build for Releases +on: + push: + tags: + - '*' + +jobs: + ensure-release-exists: + runs-on: any_archLinux + steps: + - name: Ensure that release exists + id: release_exists + run: | + curl -X GET "https://git.seodisparate.com/api/v1/repos/stephenseo/3d_collision_helpers/releases/tags/${GITHUB_REF_NAME}" \ + -H "Authorization: token ${GITHUB_TOKEN}" \ + -H 'accept: application/json' -o release_check_resp.json 2>/dev/null \ + -w '%{http_code}\n' | sed 's/^\([0-9]\+\)/http_code=\1/' > check_release_http_code + test "$(cat check_release_http_code)" = "http_code=404" && \ + curl --fail-with-body -X 'POST' \ + "https://git.seodisparate.com/api/v1/repos/stephenseo/3d_collision_helpers/releases" \ + -H 'accept: application/json' \ + -H "Authorization: token ${GITHUB_TOKEN}" \ + -H 'Content-Type: application/json' \ + -d "{ + \"name\": \"3d_collision_helpers version ${GITHUB_REF_NAME}\", + \"tag_name\": \"${GITHUB_REF_NAME}\" + }" >&/dev/null + + assets-release-x86_64: + needs: ensure-release-exists + runs-on: any_archLinux + steps: + - name: Check and push assets + id: check_release_assets_x86_64 + run: | + THE_CURRENT_WORKING_DIRECTORY="$(pwd)" + curl -X 'GET' \ + "https://git.seodisparate.com/api/v1/repos/stephenseo/3d_collision_helpers/releases/tags/${GITHUB_REF_NAME}" \ + -H "Authorization: token ${GITHUB_TOKEN}" \ + -H 'accept: application/json' > release_info.json + jq '.assets.[].name' < release_info.json | tr -d '"' > assets_list + SHARED_LIB_ASSET_NAME="3d_collision_helpers_${GITHUB_REF_NAME}_shared.tar.zst" + STATIC_LIB_ASSET_NAME="3d_collision_helpers_${GITHUB_REF_NAME}_static.tar.zst" + SHARED_LIB_ASSET_EXISTS=0 + STATIC_LIB_ASSET_EXISTS=0 + for asset in $(cat assets_list); do + if [[ "$asset" == "$SHARED_LIB_ASSET_NAME" ]]; then + SHARED_LIB_ASSET_EXISTS=1 + fi + if [[ "$asset" == "$STATIC_LIB_ASSET_NAME" ]]; then + STATIC_LIB_ASSET_EXISTS=1 + fi + done + test -d "$THE_CURRENT_WORKING_DIRECTORY/3dcolhelpers_cloned" || git clone --depth=1 --no-single-branch https://${GITHUB_TOKEN}@git.seodisparate.com/stephenseo/3d_collision_helpers.git "$THE_CURRENT_WORKING_DIRECTORY/3dcolhelpers_cloned" + pushd "$THE_CURRENT_WORKING_DIRECTORY/3dcolhelpers_cloned" >&/dev/null + if ! (( SHARED_LIB_ASSET_EXISTS )); then + git clean -xfd && git restore . && git checkout ${GITHUB_REF_NAME} + echo 'Building shared libs...' + cmake -S . -B buildRelease -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=On -DCMAKE_INSTALL_PREFIX=/usr + make -C buildRelease + pushd buildRelease + make DESTDIR=out_shared install + cd out_shared + tar --sort=name -cv usr | zstd --ultra -20 > "$THE_CURRENT_WORKING_DIRECTORY/$SHARED_LIB_ASSET_NAME" + popd + curl --fail-with-body -X POST \ + "https://git.seodisparate.com/api/v1/repos/stephenseo/3d_collision_helpers/releases/$(jq .id < $THE_CURRENT_WORKING_DIRECTORY/release_info.json)/assets" \ + -H 'accept: application/json' \ + -H "Authorization: token ${GITHUB_TOKEN}" \ + -H 'Content-Type: multipart/form-data' \ + -F "attachment=@${THE_CURRENT_WORKING_DIRECTORY}/$SHARED_LIB_ASSET_NAME;type=application/zstd" > client_attach.json + fi + if ! (( STATIC_LIB_ASSET_EXISTS )); then + git clean -xfd && git restore . && git checkout ${GITHUB_REF_NAME} + echo 'Building static libs...' + cmake -S . -B buildRelease -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=Off -DCMAKE_INSTALL_PREFIX=/usr + make -C buildRelease + pushd buildRelease + make DESTDIR=out_static install + cd out_static + tar --sort=name -cv usr | zstd --ultra -20 > "$THE_CURRENT_WORKING_DIRECTORY/$STATIC_LIB_ASSET_NAME" + popd + curl --fail-with-body -X POST \ + "https://git.seodisparate.com/api/v1/repos/stephenseo/3d_collision_helpers/releases/$(jq .id < $THE_CURRENT_WORKING_DIRECTORY/release_info.json)/assets" \ + -H 'accept: application/json' \ + -H "Authorization: token ${GITHUB_TOKEN}" \ + -H 'Content-Type: multipart/form-data' \ + -F "attachment=@${THE_CURRENT_WORKING_DIRECTORY}/$STATIC_LIB_ASSET_NAME;type=application/zstd" > client_attach.json + fi diff --git a/CMakeLists.txt b/CMakeLists.txt index 34cf3c6..05817d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ set(SC_3D_CollisionDetectionHelpers_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/src/sc_ add_library(SC_3D_CollisionDetectionHelpers ${SC_3D_CollisionDetectionHelpers_SOURCES}) -set_target_properties(SC_3D_CollisionDetectionHelpers PROPERTIES VERSION 3.2.0 SOVERSION 3) +set_target_properties(SC_3D_CollisionDetectionHelpers PROPERTIES VERSION 3.2.1 SOVERSION 3) target_compile_features(SC_3D_CollisionDetectionHelpers PUBLIC cxx_std_20) if(NOT DEFINED CMAKE_BUILD_TYPE OR "${CMAKE_BUILD_TYPE}" STREQUAL "") diff --git a/Changelog.md b/Changelog.md index a80de55..afebec6 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,10 @@ # Changelog +## Version 3.2.1 + +Add workflow to build shared/static libs available +[here](https://git.seodisparate.com/stephenseo/3d_collision_helpers/releases). + ## Version 3.2.0 Add Vec3 negate and normalize functions.