From 081f844832e7f4a048b4b3947c0358bea61f1bcc Mon Sep 17 00:00:00 2001 From: Christian Heimlich Date: Sun, 1 Sep 2024 17:55:09 -0400 Subject: [PATCH] Switch to reusable workflows --- .github/workflows/build-project.yml | 21 ++++ .github/workflows/build-stex-linux.yml | 95 ------------------- .github/workflows/build-stex-windows.yml | 80 ---------------- .github/workflows/check-release-pr.yml | 10 ++ .github/workflows/generate-release.yml | 19 ++++ .github/workflows/label-pr.yml | 12 +++ .../workflows/master-pull-request-checks.yml | 13 --- .../master-pull-request-merge-reaction.yml | 85 ----------------- .github/workflows/pull-request-labeler.yml | 13 --- .github/workflows/push-reaction.yml | 19 ---- .../tag-release-commit-and-sync-dev.yml | 14 +++ 11 files changed, 76 insertions(+), 305 deletions(-) create mode 100644 .github/workflows/build-project.yml delete mode 100644 .github/workflows/build-stex-linux.yml delete mode 100644 .github/workflows/build-stex-windows.yml create mode 100644 .github/workflows/check-release-pr.yml create mode 100644 .github/workflows/generate-release.yml create mode 100644 .github/workflows/label-pr.yml delete mode 100644 .github/workflows/master-pull-request-checks.yml delete mode 100644 .github/workflows/master-pull-request-merge-reaction.yml delete mode 100644 .github/workflows/pull-request-labeler.yml delete mode 100644 .github/workflows/push-reaction.yml create mode 100644 .github/workflows/tag-release-commit-and-sync-dev.yml diff --git a/.github/workflows/build-project.yml b/.github/workflows/build-project.yml new file mode 100644 index 0000000..ac71ffe --- /dev/null +++ b/.github/workflows/build-project.yml @@ -0,0 +1,21 @@ +name: Build Project +on: + workflow_dispatch: + push: + branches-ignore: + - 'master' + workflow_run: + workflows: Tag and Sync + types: completed + branches: dev + # This is the branch that the original workflow ran on, which is technically dev, due to how + # the "pull_request" trigger works (it works off master correctly for a merged PR but is triggered + # by dev + +jobs: + trigger-build: + name: Build Project + if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' + uses: oblivioncth/actions/.github/workflows/build-cxx-project.yml@v1 + secrets: + ffynnon_access: ${{ secrets.OBYBOT_FFYNNON_ACCESS }} diff --git a/.github/workflows/build-stex-linux.yml b/.github/workflows/build-stex-linux.yml deleted file mode 100644 index 3063c46..0000000 --- a/.github/workflows/build-stex-linux.yml +++ /dev/null @@ -1,95 +0,0 @@ -name: Build Stex - Linux -on: - workflow_call: - secrets: - qt_ffynnon_cred: - description: 'Credentials for getting Qt from Ffynnon' - required: true -env: - qt_install_dir: ${{ github.workspace }}/Qt/Install - stex_src_suffix: Stex/Source - stex_src_dir: ${{ github.workspace }}/Stex/Source - stex_build_dir: ${{ github.workspace }}/Stex/Build - -jobs: - build-stex: - name: Build Stex - Linux (Release) - strategy: - fail-fast: false - matrix: - os: [ubuntu-20.04, ubuntu-22.04] - compiler: [{c: gcc-10, cxx: g++-10, qt: clang12}, {c: gcc-12, cxx: g++-12, qt: clang14}, {c: clang-12, cxx: clang++-12, qt: clang12}, {c: clang-14, cxx: clang++-14, qt: clang14}] - linkage: [{type: shared, cmake_bsl: ON}, {type: static, cmake_bsl: OFF}] - exclude: - - os: ubuntu-20.04 - compiler: {c: gcc-12, cxx: g++-12, qt: clang14} - - os: ubuntu-20.04 - compiler: {c: clang-14, cxx: clang++-14, qt: clang14} - - os: ubuntu-22.04 - compiler: {c: gcc-10, cxx: g++-10, qt: clang12} - - os: ubuntu-22.04 - compiler: {c: clang-12, cxx: clang++-12, qt: clang12} - runs-on: ${{ matrix.os }} - env: - cmake_gen: Ninja Multi-Config - steps: - - name: Set derived variables with shell because GitHub Actions env context sucks - run: | - echo "stex_package_path=${{ env.stex_build_dir }}/out/dist" >> $GITHUB_ENV - stex_install_path="${{ env.stex_build_dir }}/out/install" - echo "stex_install_path=$stex_install_path" >> $GITHUB_ENV - echo "qt_cmake=$qt_install_dir/bin/qt-cmake" >> $GITHUB_ENV - - name: Install Qt (custom build) - uses: oblivioncth/actions/general/install-and-cache-qt-from-ffynnon@dev - with: - version: 6.5.1 - os: linux - compiler: ${{ matrix.compiler.qt }} - linkage: ${{ matrix.linkage.type }} - path: ${{ env.qt_install_dir }} - credentials: ${{ secrets.qt_ffynnon_cred }} - - name: Update package index - run: sudo apt-get update - - name: Install OpenGL lib - run: sudo apt-get install libglu1-mesa-dev - - name: Install XCB Related libs - run: sudo apt-get install libx11-xcb-dev libxkbcommon-dev libxkbcommon-x11-dev libxcb-*-dev - - name: Install libdrm - run: sudo apt-get install libdrm-dev - - name: Install Ninja - run: sudo apt-get install ninja-build - - name: Install Harfbuzz - run: sudo apt-get install libharfbuzz-dev - - name: Install EGL [22.04] - if: matrix.os == 'ubuntu-22.04' - run: sudo apt-get install libegl1-mesa-dev - - name: Checkout Stex - uses: actions/checkout@v4 - with: - path: ${{ env.stex_src_suffix }} - fetch-depth: 0 # Required for verbose versioning to work correctly - - name: Build/Install Stex - working-directory: ${{ env.stex_src_dir }} - run: | - echo Configuring CMake... - "$qt_cmake" -G "$cmake_gen" -S "$stex_src_dir" -B "$stex_build_dir" -D BUILD_SHARED_LIBS="${{ matrix.linkage.cmake_bsl }}" -D CMAKE_CXX_COMPILER="${{ matrix.compiler.cxx }}" -D CMAKE_C_COMPILER="${{ matrix.compiler.c }}" - echo Changing to build directory... - cd "$stex_build_dir" - echo Building Stex Release... - cmake --build . --target all --config Release - echo Installing Stex Release - cmake --install . --config Release - echo Packaging Stex... - cpack -C "Release" - echo Build complete. - - name: Get Stex artifact name - run: | - cpack_name=$(find "${{ env.stex_package_path }}" -type f -name "*.zip") - artifact_name="$(basename "$cpack_name" .zip) [${{ matrix.compiler.cxx }}]" - echo "current_artifact_name=$artifact_name" >> $GITHUB_ENV - - name: Upload Stex build artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ env.current_artifact_name }} - path: ${{ env.stex_install_path }} - if-no-files-found: error diff --git a/.github/workflows/build-stex-windows.yml b/.github/workflows/build-stex-windows.yml deleted file mode 100644 index 16caea3..0000000 --- a/.github/workflows/build-stex-windows.yml +++ /dev/null @@ -1,80 +0,0 @@ -name: Build Stex - Windows -on: - workflow_call: - secrets: - qt_ffynnon_cred: - description: 'Credentials for getting Qt from Ffynnon' - required: true -env: - qt_install_dir: ${{ github.workspace }}/Qt/Install - stex_src_suffix: Stex/Source - stex_src_dir: ${{ github.workspace }}/Stex/Source - stex_build_dir: ${{ github.workspace }}/Stex/Build - -jobs: - build-stex: - name: Build Stex - Windows (Release) - strategy: - fail-fast: false - matrix: - lib_linkage: [shared, static] - include: - - lib_linkage: shared - cmake_bsl: ON - - lib_linkage: static - cmake_bsl: OFF - runs-on: windows-latest - env: - vs_dir: C:/Program Files/Microsoft Visual Studio/2022/Enterprise - cmake_gen: Ninja Multi-Config - steps: - - name: Set derived variables with shell because GitHub Actions env context sucks - run: | - echo "stex_package_path=${{ env.stex_build_dir }}/out/dist" >> $Env:GITHUB_ENV - $stex_install_path="${{ env.stex_build_dir }}/out/install" - echo "stex_install_path=$stex_install_path" >> $Env:GITHUB_ENV - echo "qt_cmake=${Env:qt_install_dir}/bin/qt-cmake.bat" >> $Env:GITHUB_ENV - - name: Install Qt (custom build) - uses: oblivioncth/actions/general/install-and-cache-qt-from-ffynnon@dev - with: - version: 6.5.1 - os: windows - compiler: msvc2022 - linkage: ${{ matrix.lib_linkage }} - path: ${{ env.qt_install_dir }} - credentials: ${{ secrets.qt_ffynnon_cred }} - - name: Checkout Stex - uses: actions/checkout@v4 - with: - path: ${{ env.stex_src_suffix }} - fetch-depth: 0 # Required for verbose versioning to work correctly - - name: Build/Install Stex - working-directory: ${{ env.stex_src_dir }} - shell: cmd - run: | - echo "Setup C++ Build Environment..." - CALL "${{ env.vs_dir }}\Common7\Tools\VsDevCmd.bat" -arch=amd64 - echo "Configure CMake using Qt wrapper..." - CALL "${{ env.qt_cmake }}" -G "${{ env.cmake_gen }}" -S "${{ env.stex_src_dir}}" -B "${{ env.stex_build_dir }}" -D BUILD_SHARED_LIBS=${{ matrix.cmake_bsl }} - echo "Changing to build directory..." - cd "%stex_build_dir%" - echo "Building Stex release..." - cmake --build . --target all --config Release - echo "Installing Stex Release..." - cmake --install . --config Release - echo "Packaging Stex..." - cpack -C "Release" - echo "Build complete." - - name: Remove VC Runtime Redistributable Added by Qt # Required until an option to disable this is added to Qt - run: | - Remove-Item "${{ env.stex_install_path }}/bin/vc_redist*" - - name: Get Stex artifact name - run: | - $artifact_name=$((Get-ChildItem -Path "${{ env.stex_package_path }}" -Filter *.zip)[0].BaseName) - echo "current_artifact_name=$artifact_name" >> $Env:GITHUB_ENV - - name: Upload Stex build artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ env.current_artifact_name }} - path: ${{ env.stex_install_path }} - if-no-files-found: error diff --git a/.github/workflows/check-release-pr.yml b/.github/workflows/check-release-pr.yml new file mode 100644 index 0000000..ec28ae1 --- /dev/null +++ b/.github/workflows/check-release-pr.yml @@ -0,0 +1,10 @@ +name: Check Release PR +on: + pull_request: + types: [opened, synchronize, reopened] + branches: master + +jobs: + check-pr-correctness: + name: Release PR Correctness Check + uses: oblivioncth/actions/.github/workflows/validate-release-pr.yml@v1 diff --git a/.github/workflows/generate-release.yml b/.github/workflows/generate-release.yml new file mode 100644 index 0000000..db607da --- /dev/null +++ b/.github/workflows/generate-release.yml @@ -0,0 +1,19 @@ +name: Generate Release +on: + workflow_run: + workflows: Build Project + types: completed + branches: master + +jobs: + generate-release: + name: Generate Release + permissions: + actions: read + contents: write + pages: write + id-token: write + if: github.event.workflow_run.conclusion == 'success' + uses: oblivioncth/actions/.github/workflows/generate-cxx-release.yml@v1 + with: + artifacts_run_id: ${{ github.event.workflow_run.id }} diff --git a/.github/workflows/label-pr.yml b/.github/workflows/label-pr.yml new file mode 100644 index 0000000..a53d957 --- /dev/null +++ b/.github/workflows/label-pr.yml @@ -0,0 +1,12 @@ +name: Label PR +on: + pull_request_target: + types: [opened, synchronize, reopened] + +jobs: + label-pr: + name: Label pull-request + permissions: + contents: read + pull-requests: write + uses: oblivioncth/actions/.github/workflows/label-pr.yml@v1 diff --git a/.github/workflows/master-pull-request-checks.yml b/.github/workflows/master-pull-request-checks.yml deleted file mode 100644 index e26b5db..0000000 --- a/.github/workflows/master-pull-request-checks.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: Master pull-request checks -on: - pull_request: - types: [opened, synchronize, reopened] - branches: master - -jobs: - check-pr-correctness: - name: Master PR correctness check - runs-on: windows-latest - steps: - - name: Ensure higher version - uses: oblivioncth/actions/cmake/ensure-project-version-gt-tag@dev diff --git a/.github/workflows/master-pull-request-merge-reaction.yml b/.github/workflows/master-pull-request-merge-reaction.yml deleted file mode 100644 index 8b7a712..0000000 --- a/.github/workflows/master-pull-request-merge-reaction.yml +++ /dev/null @@ -1,85 +0,0 @@ -name: Master pull-request merge reaction -on: - pull_request: - types: [closed] - branches: - - 'master' -env: - artifacts_path: ${{ github.workspace }}/Artifacts - zips_path: ${{ github.workspace }}/Zips - -jobs: - tag_master_and_sync_dev: - name: Tag master merge commit, FF back to dev - if: github.event.pull_request.merged == true - runs-on: windows-latest - outputs: - new_version: ${{ steps.get-proj-ver.outputs.version }} - steps: - - name: Get project version - id: get-proj-ver - uses: oblivioncth/actions/cmake/get-project-version@dev - - name: Set Git user to ObyBotCI - uses: oblivioncth/actions/git/set-git-user-to-oby-bot@dev - - name: Tag master with new version tag - uses: oblivioncth/actions/git/tag@dev - with: - tag: 'v${{ steps.get-proj-ver.outputs.version }}' - message: 'Release v${{ steps.get-proj-ver.outputs.version }}' - - name: Move 'latest' tag - uses: oblivioncth/actions/git/move-latest-tag@dev - - name: Fast-forward merge master into to dev - if: always() - uses: oblivioncth/actions/git/merge-branches@dev - with: - source_branch: master - target_branch: dev - ff: only - - build_stex_release_windows: - name: Build Stex Release (Windows) - needs: tag_master_and_sync_dev - if: github.event.pull_request.merged == true - uses: ./.github/workflows/build-stex-windows.yml - secrets: - qt_ffynnon_cred: ${{ secrets.OBYBOT_FFYNNON_CREDS }} - - build_stex_release_linux: - name: Build Stex Release (Linux) - needs: tag_master_and_sync_dev - if: github.event.pull_request.merged == true - uses: ./.github/workflows/build-stex-linux.yml - secrets: - qt_ffynnon_cred: ${{ secrets.OBYBOT_FFYNNON_CREDS }} - - create-release: - name: Create GitHub release - needs: [build_stex_release_windows, build_stex_release_linux, tag_master_and_sync_dev] - if: github.event.pull_request.merged == true - runs-on: ubuntu-latest - steps: - - name: Download built Stex artifacts - uses: actions/download-artifact@v3 - with: - path: ${{ env.artifacts_path }} - - name: Zip up release artifacts - shell: pwsh - run: | - $artifact_folders = Get-ChildItem -Directory -Path "${{ env.artifacts_path }}" - foreach($art_dir in $artifact_folders) - { - $name = $art_dir.name - $path = $art_dir.fullname - 7z a "${{ env.zips_path }}/${name}.zip" "${path}/*" - } - - name: Generate release - uses: softprops/action-gh-release@v2 - with: - name: "Stex Release v${{ needs.tag_master_and_sync_dev.outputs.new_version }}" - tag_name: "v${{ needs.tag_master_and_sync_dev.outputs.new_version }}" - fail_on_unmatched_files: true - generate_release_notes: true - files: | - ${{ env.zips_path }}/*.zip - - \ No newline at end of file diff --git a/.github/workflows/pull-request-labeler.yml b/.github/workflows/pull-request-labeler.yml deleted file mode 100644 index 55df907..0000000 --- a/.github/workflows/pull-request-labeler.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: Pull-request auto-labeler -on: - pull_request: - types: [opened] - -jobs: - label_pr: - name: Label pull-request - runs-on: ubuntu-latest - steps: - - name: Label via convention - uses: oblivioncth/actions/pull-request/label-pr-conventionally@dev - \ No newline at end of file diff --git a/.github/workflows/push-reaction.yml b/.github/workflows/push-reaction.yml deleted file mode 100644 index e2d5b3d..0000000 --- a/.github/workflows/push-reaction.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Stex Push Reaction -on: - workflow_dispatch: - push: - branches-ignore: - - 'master' - -jobs: - trigger-windows-build: - name: Build Stex (Windows) - uses: ./.github/workflows/build-stex-windows.yml - secrets: - qt_ffynnon_cred: ${{ secrets.OBYBOT_FFYNNON_CREDS }} - - trigger-linux-build: - name: Build Stex (Linux) - uses: ./.github/workflows/build-stex-linux.yml - secrets: - qt_ffynnon_cred: ${{ secrets.OBYBOT_FFYNNON_CREDS }} \ No newline at end of file diff --git a/.github/workflows/tag-release-commit-and-sync-dev.yml b/.github/workflows/tag-release-commit-and-sync-dev.yml new file mode 100644 index 0000000..c2589c1 --- /dev/null +++ b/.github/workflows/tag-release-commit-and-sync-dev.yml @@ -0,0 +1,14 @@ +name: Tag and Sync +on: + pull_request: + types: [closed] + branches: + - 'master' + +jobs: + tag-master-and-sync-dev: + name: Tag master merge commit, FF back to dev + if: github.event.pull_request.merged == true + permissions: + contents: write + uses: oblivioncth/actions/.github/workflows/tag-main-and-sync-dev.yml@v1