fix(ci): resolve Alpine container issue on ARM64 runner #38
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 and Release | |
| on: | |
| push: | |
| branches: | |
| - master | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| workflow_dispatch: | |
| inputs: | |
| publish_npm: | |
| description: 'Publish to npm' | |
| required: false | |
| type: boolean | |
| default: false | |
| jobs: | |
| linux-gnu-x64: | |
| runs-on: ubuntu-24.04 | |
| container: | |
| image: alibaba-cloud-linux-3-registry.cn-hangzhou.cr.aliyuncs.com/alinux3/alinux3:latest | |
| env: | |
| ZIG_TARGET: x86_64-linux-gnu | |
| steps: | |
| - name: Install prerequisites | |
| run: yum install -y git curl wget xz tar unzip rsync which python3 python3-pip python3-setuptools autoconf automake libtool pkgconfig gcc gcc-c++ make ninja-build cmake file vim procps-ng iputils | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install Node.js | |
| run: | | |
| curl -fsSL https://rpm.nodesource.com/setup_18.x | bash - | |
| yum install -y nodejs | |
| - name: Setup Zig | |
| uses: mlugg/setup-zig@v2 | |
| with: | |
| version: 0.15.2 | |
| - name: Configure Zig environment | |
| run: | | |
| ZIG_BIN=$(command -v zig) | |
| if [ -z "$ZIG_BIN" ]; then | |
| echo "zig binary not found" >&2 | |
| exit 1 | |
| fi | |
| echo "ZIG_BIN=$ZIG_BIN" >> "$GITHUB_ENV" | |
| echo "CC=$ZIG_BIN cc -target $ZIG_TARGET -fno-sanitize=undefined" >> "$GITHUB_ENV" | |
| echo "CXX=$ZIG_BIN c++ -target $ZIG_TARGET -fno-sanitize=undefined" >> "$GITHUB_ENV" | |
| echo "CFLAGS=-fPIC -fno-sanitize=undefined" >> "$GITHUB_ENV" | |
| echo "CXXFLAGS=-fPIC -fno-sanitize=undefined" >> "$GITHUB_ENV" | |
| echo "LDFLAGS=-static-libstdc++ -static-libgcc -fno-sanitize=undefined" >> "$GITHUB_ENV" | |
| - name: Install npm dependencies | |
| run: npm install --no-audit --prefer-offline | |
| - name: Build RocketMQ native deps | |
| run: ./deps/rocketmq/build.sh | |
| - name: Build addon | |
| run: npx cmake-js compile --CDCMAKE_BUILD_TYPE=Release | |
| - name: Package artifact | |
| run: | | |
| mkdir -p Release | |
| strip --strip-all build/rocketmq.node | |
| cp build/rocketmq.node Release/linux-x86_64-gnu-rocketmq.node | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-x86_64-gnu | |
| path: Release/linux-x86_64-gnu-rocketmq.node | |
| linux-gnu-arm64: | |
| runs-on: ubuntu-24.04-arm | |
| container: | |
| image: alibaba-cloud-linux-3-registry.cn-hangzhou.cr.aliyuncs.com/alinux3/alinux3:latest | |
| env: | |
| ZIG_TARGET: aarch64-linux-gnu | |
| steps: | |
| - name: Install prerequisites | |
| run: yum install -y git curl wget xz tar unzip rsync which python3 python3-pip python3-setuptools autoconf automake libtool pkgconfig gcc gcc-c++ make ninja-build cmake file vim procps-ng iputils | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install Node.js | |
| run: | | |
| curl -fsSL https://rpm.nodesource.com/setup_18.x | bash - | |
| yum install -y nodejs | |
| - name: Setup Zig | |
| uses: mlugg/setup-zig@v2 | |
| with: | |
| version: 0.15.2 | |
| - name: Configure Zig environment | |
| run: | | |
| ZIG_BIN=$(command -v zig) | |
| if [ -z "$ZIG_BIN" ]; then | |
| echo "zig binary not found" >&2 | |
| exit 1 | |
| fi | |
| echo "ZIG_BIN=$ZIG_BIN" >> "$GITHUB_ENV" | |
| echo "CC=$ZIG_BIN cc -target $ZIG_TARGET -fno-sanitize=undefined" >> "$GITHUB_ENV" | |
| echo "CXX=$ZIG_BIN c++ -target $ZIG_TARGET -fno-sanitize=undefined" >> "$GITHUB_ENV" | |
| echo "CFLAGS=-fPIC -fno-sanitize=undefined" >> "$GITHUB_ENV" | |
| echo "CXXFLAGS=-fPIC -fno-sanitize=undefined" >> "$GITHUB_ENV" | |
| echo "LDFLAGS=-static-libstdc++ -static-libgcc -fno-sanitize=undefined" >> "$GITHUB_ENV" | |
| - name: Install npm dependencies | |
| run: npm install --no-audit --prefer-offline | |
| - name: Build RocketMQ native deps | |
| run: ./deps/rocketmq/build.sh | |
| - name: Build addon | |
| run: npx cmake-js compile --CDCMAKE_BUILD_TYPE=Release | |
| - name: Package artifact | |
| run: | | |
| mkdir -p Release | |
| strip --strip-all build/rocketmq.node | |
| cp build/rocketmq.node Release/linux-aarch64-gnu-rocketmq.node | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-aarch64-gnu | |
| path: Release/linux-aarch64-gnu-rocketmq.node | |
| linux-musl-x64: | |
| runs-on: ubuntu-24.04 | |
| container: | |
| image: alpine:latest | |
| env: | |
| ZIG_TARGET: x86_64-linux-musl | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install system dependencies | |
| run: apk add --no-cache nodejs npm bash build-base cmake ninja python3 curl unzip git autoconf automake libtool pkgconfig | |
| - name: Setup Zig | |
| uses: mlugg/setup-zig@v2 | |
| with: | |
| version: 0.15.2 | |
| - name: Configure Zig environment | |
| run: | | |
| ZIG_BIN=$(command -v zig) | |
| if [ -z "$ZIG_BIN" ]; then | |
| echo "zig binary not found" >&2 | |
| exit 1 | |
| fi | |
| echo "ZIG_BIN=$ZIG_BIN" >> "$GITHUB_ENV" | |
| echo "CC=$ZIG_BIN cc -target $ZIG_TARGET -fno-sanitize=undefined" >> "$GITHUB_ENV" | |
| echo "CXX=$ZIG_BIN c++ -target $ZIG_TARGET -fno-sanitize=undefined" >> "$GITHUB_ENV" | |
| echo "CFLAGS=-fPIC -fno-sanitize=undefined" >> "$GITHUB_ENV" | |
| echo "CXXFLAGS=-fPIC -fno-sanitize=undefined" >> "$GITHUB_ENV" | |
| echo "LDFLAGS=-static-libstdc++ -static-libgcc -fno-sanitize=undefined" >> "$GITHUB_ENV" | |
| - name: Install npm dependencies | |
| run: npm install --no-audit --prefer-offline | |
| - name: Build RocketMQ native deps | |
| run: ./deps/rocketmq/build.sh | |
| - name: Build addon | |
| run: npx cmake-js compile --CDCMAKE_BUILD_TYPE=Release | |
| - name: Package artifact | |
| run: | | |
| mkdir -p Release | |
| strip --strip-all build/rocketmq.node | |
| cp build/rocketmq.node Release/linux-x86_64-musl-rocketmq.node | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-x86_64-musl | |
| path: Release/linux-x86_64-musl-rocketmq.node | |
| linux-musl-arm64: | |
| runs-on: ubuntu-24.04-arm | |
| env: | |
| ZIG_TARGET: aarch64-linux-musl | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 18 | |
| - name: Install system dependencies | |
| run: sudo apt-get update && sudo apt-get install -y build-essential cmake ninja-build python3 curl unzip git autoconf automake libtool pkg-config | |
| - name: Setup Zig | |
| uses: mlugg/setup-zig@v2 | |
| with: | |
| version: 0.15.2 | |
| - name: Configure Zig environment | |
| run: | | |
| ZIG_BIN=$(command -v zig) | |
| if [ -z "$ZIG_BIN" ]; then | |
| echo "zig binary not found" >&2 | |
| exit 1 | |
| fi | |
| echo "ZIG_BIN=$ZIG_BIN" >> "$GITHUB_ENV" | |
| echo "CC=$ZIG_BIN cc -target $ZIG_TARGET -fno-sanitize=undefined" >> "$GITHUB_ENV" | |
| echo "CXX=$ZIG_BIN c++ -target $ZIG_TARGET -fno-sanitize=undefined" >> "$GITHUB_ENV" | |
| echo "CFLAGS=-fPIC -fno-sanitize=undefined" >> "$GITHUB_ENV" | |
| echo "CXXFLAGS=-fPIC -fno-sanitize=undefined" >> "$GITHUB_ENV" | |
| echo "LDFLAGS=-static-libstdc++ -static-libgcc -fno-sanitize=undefined" >> "$GITHUB_ENV" | |
| - name: Install npm dependencies | |
| run: npm install --no-audit --prefer-offline | |
| - name: Build RocketMQ native deps | |
| run: ./deps/rocketmq/build.sh | |
| - name: Build addon | |
| run: npx cmake-js compile --CDCMAKE_BUILD_TYPE=Release | |
| - name: Package artifact | |
| run: | | |
| mkdir -p Release | |
| strip --strip-all build/rocketmq.node | |
| cp build/rocketmq.node Release/linux-aarch64-musl-rocketmq.node | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-aarch64-musl | |
| path: Release/linux-aarch64-musl-rocketmq.node | |
| macos-universal: | |
| runs-on: macos-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 18 | |
| - name: Install build tools | |
| run: brew install cmake ninja xz autoconf automake libtool pkg-config | |
| - name: Install npm dependencies | |
| run: npm install --no-audit --prefer-offline | |
| - name: Build RocketMQ native deps | |
| run: ./deps/rocketmq/build.sh | |
| - name: Build addon | |
| run: | | |
| npx cmake-js compile --CDCMAKE_BUILD_TYPE=Release \ | |
| --CDCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \ | |
| --CDCMAKE_OSX_DEPLOYMENT_TARGET=11 \ | |
| --CDCMAKE_SKIP_DEPENDENCY_TRACKING=ON | |
| - name: Package artifact | |
| run: | | |
| mkdir -p Release | |
| strip -S -x build/rocketmq.node | |
| cp build/rocketmq.node Release/darwin-universal-rocketmq.node | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: darwin-universal | |
| path: Release/darwin-universal-rocketmq.node | |
| release: | |
| needs: [linux-gnu-x64, linux-gnu-arm64, linux-musl-x64, linux-musl-arm64, macos-universal] | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master') | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Prepare Release directory | |
| run: | | |
| mkdir -p Release | |
| find artifacts -name "*.node" -exec cp {} Release/ \; | |
| ls -lh Release/ | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ startsWith(github.ref, 'refs/tags/v') && github.ref_name || format('build-{0}', github.sha) }} | |
| name: ${{ startsWith(github.ref, 'refs/tags/v') && github.ref_name || format('Build {0}', github.sha) }} | |
| draft: false | |
| prerelease: ${{ !startsWith(github.ref, 'refs/tags/v') }} | |
| files: Release/*.node | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| publish-npm: | |
| needs: release | |
| runs-on: ubuntu-latest | |
| if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) || (github.event_name == 'workflow_dispatch' && inputs.publish_npm) | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 18 | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Prepare Release directory | |
| run: | | |
| mkdir -p Release | |
| find artifacts -name "*.node" -exec cp {} Release/ \; | |
| ls -lh Release/ | |
| - name: Publish to npm | |
| run: npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |