From 4ddc8dd18cf688d7354b3f9f50e6d512f07affe1 Mon Sep 17 00:00:00 2001 From: Ilia Date: Sat, 16 Dec 2023 11:37:07 +0300 Subject: [PATCH] feat(ci): upload artifacts and make release --- .github/workflows/build.yml | 14 ++++++++++ .github/workflows/cmake.yml | 50 +++++++++++++++++++++++++---------- .github/workflows/release.yml | 43 ++++++++++++++++++++++++++++++ run.sh | 0 4 files changed, 93 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml mode change 100644 => 100755 run.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..395906c8 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,14 @@ +name: Build + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + name: Build + uses: ./.github/workflows/cmake.yml + with: + build_type: Release diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 502dd486..bd01c399 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -1,25 +1,33 @@ name: CMake on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - BUILD_TYPE: Release + workflow_call: + inputs: + build_type: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + description: Type of build (Debug, Release, RelWithDebInfo, MinSizeRel) + type: string + default: Debug + upload_artifacts: + description: Should upload artifacts or not + type: boolean + default: false jobs: build: # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. # You can convert this to a matrix build if you need cross-platform coverage. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix - runs-on: ubuntu-latest + strategy: + matrix: + include: + - os: ubuntu-latest + + runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 - + - uses: actions/checkout@v4 + - name: Install packages # If libluajit-5.1-dev is not available, use this: # git clone https://luajit.org/git/luajit.git @@ -32,10 +40,24 @@ jobs: sudo ln -s /usr/include/luajit-2.1 /usr/include/lua - name: Configure CMake - # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only + # required if you are using a single-configuration generator such as + # make. + # # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{inputs.build_type}} - name: Build # Build your program with the given configuration - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + run: | + cmake --build ${{github.workspace}}/build --config ${{inputs.build_type}} + mv ${{github.workspace}}/build/VoxelEngine VoxelEngine + + - name: Upload artifacts + if: ${{ inputs.upload_artifacts }} + uses: actions/upload-artifact@v4 + with: + name: VoxelEngine + path: | + VoxelEngine + res/* diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..a1186ce3 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,43 @@ +# adopted from https://github.com/PrismLauncher/PrismLauncher +name: Release + +on: + push: + tags: + - "v*" + +jobs: + build_release: + name: Build Release + uses: ./.github/workflows/cmake.yml + with: + build_type: Release + upload_artifacts: true + + create_release: + needs: build_release + runs-on: ubuntu-latest + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: VoxelEngine + - name: Pack artifacts + run: | + chmod +x VoxelEngine + zip -r VoxelEngine.zip res VoxelEngine + - name: Grab and store version + run: | + tag_name=$(echo ${{ github.ref }} | grep -oE "v[^/]+$") + echo "VERSION=$tag_name" >> $GITHUB_ENV + + - name: Create release + uses: softprops/action-gh-release@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + tag_name: ${{ github.ref }} + name: VoxelEngine ${{ env.VERSION }} + draft: true + prerelease: false + files: | + VoxelEngine.zip diff --git a/run.sh b/run.sh old mode 100644 new mode 100755