Release x86_64 #2
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: Release x86_64 | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version tag (e.g., v0.80.3)' | |
| required: true | |
| type: string | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-ubuntu-dynamic: | |
| name: Build Ubuntu 24.04 (dynamic) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| library: [c, cpp] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Build ${{ matrix.library }} library | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| build-essential \ | |
| clang-18 \ | |
| cmake \ | |
| git \ | |
| protobuf-compiler \ | |
| libprotobuf-dev \ | |
| libabsl-dev \ | |
| libssl-dev \ | |
| pkg-config | |
| cd /tmp | |
| git clone --depth 1 --branch v1.3.15 https://github.com/eclipse/paho.mqtt.c.git | |
| cd paho.mqtt.c | |
| cmake -Bbuild \ | |
| -DCMAKE_BUILD_TYPE=Release \ | |
| -DPAHO_WITH_SSL=ON \ | |
| -DPAHO_BUILD_DOCUMENTATION=OFF \ | |
| -DPAHO_BUILD_SAMPLES=OFF \ | |
| -DPAHO_BUILD_STATIC=OFF | |
| cmake --build build -j$(nproc) | |
| sudo cmake --install build | |
| cd $GITHUB_WORKSPACE | |
| export CC=clang-18 | |
| export CXX=clang++-18 | |
| cmake -S . -B build-release \ | |
| -DCMAKE_BUILD_TYPE=Release \ | |
| -DBUILD_SHARED_LIBS=ON | |
| cmake --build build-release -j$(nproc) --target sparkplug_${{ matrix.library }} | |
| VERSION="${{ inputs.version }}" | |
| VERSION="${VERSION#v}" | |
| ARCH="x86_64" | |
| PACKAGE_NAME="sparkplug-${{ matrix.library }}-${VERSION}-ubuntu24.04-${ARCH}" | |
| mkdir -p ${PACKAGE_NAME}/{lib,include} | |
| cp build-release/src/libsparkplug_${{ matrix.library }}.so* ${PACKAGE_NAME}/lib/ | |
| if [ "${{ matrix.library }}" = "c" ]; then | |
| mkdir -p ${PACKAGE_NAME}/include/sparkplug | |
| cp include/sparkplug/sparkplug_c.h ${PACKAGE_NAME}/include/sparkplug/ | |
| else | |
| cp -r include/sparkplug ${PACKAGE_NAME}/include/ | |
| fi | |
| printf "%s\n" \ | |
| "# Sparkplug B ${{ matrix.library }} Library (Ubuntu 24.04)" \ | |
| "" \ | |
| "Dynamic library build for Ubuntu 24.04 LTS." \ | |
| "" \ | |
| "## Dependencies" \ | |
| "" \ | |
| "Install runtime dependencies:" \ | |
| "\`\`\`bash" \ | |
| "sudo apt-get install libprotobuf33 libabsl20230802 libpaho-mqtt-c1.3 libssl3" \ | |
| "\`\`\`" \ | |
| "" \ | |
| "## Installation" \ | |
| "" \ | |
| "\`\`\`bash" \ | |
| "sudo cp lib/* /usr/local/lib/" \ | |
| "sudo cp -r include/* /usr/local/include/" \ | |
| "sudo ldconfig" \ | |
| "\`\`\`" \ | |
| > ${PACKAGE_NAME}/README.md | |
| tar czf ${PACKAGE_NAME}.tar.gz ${PACKAGE_NAME} | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ubuntu-${{ matrix.library }}-x86_64 | |
| path: '*.tar.gz' | |
| build-alpine-static: | |
| name: Build Alpine Linux (static musl) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build static musl bundle in Alpine container | |
| run: | | |
| docker run --rm \ | |
| --platform linux/amd64 \ | |
| -v $PWD:/workspace \ | |
| -w /workspace \ | |
| alpine:latest \ | |
| sh -c ' | |
| apk add --no-cache \ | |
| build-base \ | |
| cmake \ | |
| git \ | |
| bash \ | |
| linux-headers \ | |
| openssl-dev \ | |
| openssl-libs-static \ | |
| zlib-static \ | |
| samurai \ | |
| protobuf-dev \ | |
| protoc | |
| git config --global --add safe.directory /workspace | |
| export VERSION="${{ inputs.version }}" | |
| export VERSION="${VERSION#v}" | |
| export ARCH="x86_64" | |
| bash ./scripts/build_static_musl.sh | |
| ' | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: alpine-static-c-x86_64 | |
| path: 'build-static-musl/*.tar.gz' | |
| build-fedora-dynamic: | |
| name: Build Fedora 42 (dynamic) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| library: [c, cpp] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build ${{ matrix.library }} library in Fedora container | |
| run: | | |
| docker run --rm \ | |
| -v $PWD:/workspace \ | |
| -w /workspace \ | |
| fedora:42 \ | |
| sh -c ' | |
| dnf install -y \ | |
| gcc-c++ \ | |
| clang \ | |
| cmake \ | |
| ninja-build \ | |
| git \ | |
| protobuf-devel \ | |
| abseil-cpp-devel \ | |
| paho-c-devel \ | |
| openssl-devel | |
| git config --global --add safe.directory /workspace | |
| export CC=clang | |
| export CXX=clang++ | |
| cmake -S . -B build-release \ | |
| -GNinja \ | |
| -DCMAKE_BUILD_TYPE=Release \ | |
| -DBUILD_SHARED_LIBS=ON | |
| cmake --build build-release -j$(nproc) --target sparkplug_${{ matrix.library }} | |
| VERSION="${{ inputs.version }}" | |
| VERSION="${VERSION#v}" | |
| ARCH="x86_64" | |
| PACKAGE_NAME="sparkplug-${{ matrix.library }}-${VERSION}-fedora42-${ARCH}" | |
| mkdir -p ${PACKAGE_NAME}/{lib,include} | |
| cp build-release/src/libsparkplug_${{ matrix.library }}.so* ${PACKAGE_NAME}/lib/ | |
| if [ "${{ matrix.library }}" = "c" ]; then | |
| mkdir -p ${PACKAGE_NAME}/include/sparkplug | |
| cp include/sparkplug/sparkplug_c.h ${PACKAGE_NAME}/include/sparkplug/ | |
| else | |
| cp -r include/sparkplug ${PACKAGE_NAME}/include/ | |
| fi | |
| printf "%s\n" \ | |
| "# Sparkplug B ${{ matrix.library }} Library (Fedora 42)" \ | |
| "" \ | |
| "Dynamic library build for Fedora 42+." \ | |
| "" \ | |
| "## Dependencies" \ | |
| "" \ | |
| "\`\`\`bash" \ | |
| "sudo dnf install protobuf abseil-cpp paho-c openssl" \ | |
| "\`\`\`" \ | |
| "" \ | |
| "## Installation" \ | |
| "" \ | |
| "\`\`\`bash" \ | |
| "sudo cp lib/* /usr/local/lib64/" \ | |
| "sudo cp -r include/* /usr/local/include/" \ | |
| "sudo ldconfig" \ | |
| "\`\`\`" \ | |
| > ${PACKAGE_NAME}/README.md | |
| tar czf ${PACKAGE_NAME}.tar.gz ${PACKAGE_NAME} | |
| ' | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: fedora-${{ matrix.library }}-x86_64 | |
| path: '*.tar.gz' | |
| create-release: | |
| name: Create GitHub Release | |
| runs-on: ubuntu-latest | |
| needs: [build-ubuntu-dynamic, build-alpine-static, build-fedora-dynamic] | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Display structure of downloaded files | |
| run: ls -R artifacts | |
| - name: Prepare release assets | |
| run: | | |
| mkdir -p release-assets | |
| find artifacts -name '*.tar.gz' -exec cp {} release-assets/ \; | |
| ls -lh release-assets/ | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ inputs.version }} | |
| name: ${{ inputs.version }} (x86_64) | |
| draft: false | |
| generate_release_notes: true | |
| files: release-assets/*.tar.gz |