diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index d960f53..0159b6b 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -1,13 +1,18 @@ -name: Builds +name: Linux on: + workflow_call: + inputs: + upload_url: + required: false + type: string push: branches: [ main ] pull_request: branches: [ main ] jobs: - unix: + build: runs-on: ubuntu-latest steps: @@ -20,10 +25,21 @@ jobs: sudo apt-get install -y clang sudo apt-get install -y ninja-build - - name: Install libs - run: sudo apt-get install -y libtbb-dev - - name: Configure and build run: | cmake --preset linux64-release cmake --build build + + - name: Upload binary to release (optional) + if: ${{ inputs.upload_url }} + id: upload-release-binary + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ inputs.upload_url }} + asset_path: build/clang-format-all + asset_name: clang-format-all-linux64 + asset_content_type: application/executable + + diff --git a/.github/workflows/make_release.yml b/.github/workflows/make_release.yml new file mode 100644 index 0000000..6479c11 --- /dev/null +++ b/.github/workflows/make_release.yml @@ -0,0 +1,50 @@ +name: Make release + +on: + workflow_dispatch: + inputs: + tag: + description: 'A version tag' + default: '0.0' + required: true + type: string + +jobs: + create_release: + name: Create Release + runs-on: ubuntu-latest + outputs: + upload_url: ${{ steps.create_release.outputs.upload_url }} + steps: + - uses: actions/checkout@v2 + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ inputs.tag }} + release_name: Release ${{ inputs.tag }} + body: | + Autogenerated release + draft: false + prerelease: false + + + release_linux_artifact: + name: Build and upload Linux binary + needs: create_release + if: ${{ needs.create_release.outputs.upload_url }} + uses: ./.github/workflows/linux.yml + with: + upload_url: ${{ needs.create_release.outputs.upload_url }} + + release_win64_artifact: + name: Build and upload Windows binary + needs: create_release + if: ${{ needs.create_release.outputs.upload_url }} + uses: ./.github/workflows/windows.yml + with: + upload_url: ${{ needs.create_release.outputs.upload_url }} + diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 0d5703c..902adaa 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -1,13 +1,18 @@ -name: Builds +name: Windows on: + workflow_call: + inputs: + upload_url: + required: false + type: string push: branches: [ main ] pull_request: branches: [ main ] jobs: - windows: + build: runs-on: windows-latest steps: @@ -22,4 +27,16 @@ jobs: - name: Configure and build run: | cmake --preset win64-release - cmake --build build \ No newline at end of file + cmake --build build + + - name: Upload binary to release (optional) + if: ${{ inputs.upload_url }} + id: upload-release-binary + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ inputs.upload_url }} + asset_path: build/clang-format-all.exe + asset_name: clang-format-all-win64.exe + asset_content_type: application/executable diff --git a/CMakeLists.txt b/CMakeLists.txt index e315a8f..841167b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,8 +15,3 @@ install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION "${CMAKE_CURRENT_SOURCE_DIR} enable_testing() add_test(NAME HelloHelp COMMAND $ --help WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) - -if(UNIX AND NOT CMAKE_CROSSCOMPILING) -find_library(TBB_LIB NAMES tbb) -target_link_libraries(${PROJECT_NAME} "tbb") -endif() \ No newline at end of file diff --git a/CMakePresets.json b/CMakePresets.json index 44d28b9..3f39967 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -101,4 +101,4 @@ "cacheVariables": { "CMAKE_BUILD_TYPE": "RelWithDebInfo" } } ] -} \ No newline at end of file +} diff --git a/README.md b/README.md index c804b4b..57cb371 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,9 @@ There are no special dependencies, project can be easily compiled for Windows an Pre-build download available thru [releases](https://github.com/GloryOfNight/clang-format-all/releases) page. # Build -On Linux: `sh ./scripts/build_unix.sh` NOTE: you might need to install libtbb for successfull build! +On Linux: `cmake --preset linux64-release && cmake --build build` NOTE: you might need to install libtbb for successfull build! -On Windows (git bash): `./scripts/build_win.bat` +On Windows: `cmake --preset win64-release && cmake --build build` # Options - `--help` print help with available arguments list @@ -29,3 +29,8 @@ example command (git bash, windows): If you found this useful, give it a star. Stars, yay ⭐ If you encounter issue, use Issues section above and write everything about it. + + +### Main branch +[![Windows](https://github.com/GloryOfNight/clang-format-all/actions/workflows/windows.yml/badge.svg)](https://github.com/GloryOfNight/clang-format-all/actions/workflows/windows.yml) +[![Linux](https://github.com/GloryOfNight/clang-format-all/actions/workflows/linux.yml/badge.svg)](https://github.com/GloryOfNight/clang-format-all/actions/workflows/linux.yml)