feat: Build and Publish refactor #59
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: 'Build Binary' | |
| description: | | |
| This workflow builds the binary files for Linux. The build binaries are stored as artifact | |
| and may be reused by other workflows. | |
| on: | |
| push: | |
| branches: [ 'main' ] | |
| tags: [ '*' ] | |
| pull_request: | |
| branches: [ '*' ] | |
| jobs: | |
| build-binary: | |
| name: 'Build binary' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 'Checkout repository' | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: 'Check tag' | |
| id: 'check-tag' | |
| run: | | |
| TAG="$GITHUB_REF_NAME" | |
| if [[ "$TAG" =~ ^v(0|[1-9][[:digit:]]*)\.(0|[1-9][[:digit:]]*)\.(0|[1-9][[:digit:]]*)(-(alpha|rc|beta|experimental)\.[1-9][[:digit:]]*)?$ ]]; then | |
| echo "Tag is a valid version tag." | |
| echo "IS_VALID_VERSION_TAG=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "Tag is not a valid version tag." | |
| echo "IS_VALID_VERSION_TAG=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: 'Setup GCC' | |
| uses: egor-tensin/setup-gcc@v2 | |
| with: | |
| version: '14' | |
| platform: 'x64' | |
| - name: 'Setup CMake' | |
| uses: jwlawson/actions-setup-cmake@v2 | |
| with: | |
| cmake-version: '3.31.x' | |
| - name: 'Configure CMake' | |
| env: | |
| CXX: g++ | |
| run: | | |
| cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release | |
| - name: 'Build' | |
| id: 'build' | |
| run: | | |
| cmake --build build --config Release | |
| . build/env.sh | |
| echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_OUTPUT | |
| - name: 'Upload artifacts' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: libcpp_bindings_linux_x86_64 | |
| path: build/libcpp_bindings_linux.so* | |
| outputs: | |
| is_valid_version_tag: ${{ steps.check-tag.outputs.IS_VALID_VERSION_TAG }} | |
| package_version: ${{ steps.build.outputs.PACKAGE_VERSION }} | |
| trigger-publish: | |
| name: 'Trigger Publish' | |
| needs: ['build-binary'] | |
| uses: ./.github/workflows/publish_jsr.yml | |
| with: | |
| publish: ${{ needs.build-binary.outputs.is_valid_version_tag == 'true' }} | |
| version: ${{ needs.build-binary.outputs.package_version }} | |
| artifact-name: libcpp_bindings_linux_x86_64 | |
| permissions: | |
| contents: read | |
| id-token: write |