Skip to content

Commit

Permalink
Add workflow for manually building artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
airhorns committed Feb 16, 2025
1 parent dc4d530 commit 57b9e58
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 1 deletion.
131 changes: 131 additions & 0 deletions .github/workflows/build-artifacts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

name: Build Release Artifacts

on: [push]

jobs:
build-artifacts:
name: Build Release Artifacts
strategy:
fail-fast: false
matrix:
include:
- name: macOS-x86_64
os: macos-13
compiler: clang
arch: x86_64
- name: macOS-arm64
os: macos-14
compiler: clang
arch: arm64
- name: Linux-x86_64
os: ubuntu-22.04
compiler: gcc
arch: x86_64
- name: Linux-arm64
os: ubuntu-22.04
compiler: gcc
arch: arm64
qemu: true

runs-on: ['${{ matrix.os }}-xlarge']
steps:
- uses: actions/checkout@v4

# Setup QEMU for Linux ARM64 builds
- name: Set up QEMU
if: ${{ matrix.qemu }}
uses: docker/setup-qemu-action@v3

# Setup macOS
- name: Setup macOS
if: ${{ startsWith(matrix.os, 'macos') }}
run: |
brew install cmake gcc autoconf automake libtool openssl coreutils
echo "NPROC=$(sysctl -n hw.ncpu)" >> $GITHUB_ENV
echo "CMAKE_EXTRA_DEFS=-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl" >> $GITHUB_ENV
# Setup Linux
- name: Setup Linux
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
sudo apt update
sudo apt install -y ninja-build
echo "NPROC=$(nproc)" >> $GITHUB_ENV
# Build for macOS
- name: Build macOS Binary
if: ${{ startsWith(matrix.os, 'macos') }}
run: |
./x.py build -j$NPROC --compiler ${{ matrix.compiler }} \
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} \
-DPORTABLE=1 \
${{ env.CMAKE_EXTRA_DEFS }}
# Build for Linux x86_64
- name: Build Linux x86_64 Binary
if: ${{ matrix.os == 'ubuntu-22.04' && matrix.arch == 'x86_64' }}
run: |
./x.py build -j$NPROC --compiler ${{ matrix.compiler }} -DPORTABLE=1
# Build for Linux ARM64 using Docker
- name: Build Linux ARM64 Binary
if: ${{ matrix.os == 'ubuntu-22.04' && matrix.arch == 'arm64' }}
run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --use
docker buildx build --platform linux/arm64 \
--build-arg MORE_BUILD_ARGS="-j$NPROC" \
--output type=local,dest=build-arm64 .
mkdir -p build
cp build-arm64/bin/kvrocks build/
# Package artifacts
- name: Package Artifacts
run: |
ARTIFACT_NAME="kvrocks-${{ github.sha }}-${{ matrix.name }}"
mkdir -p "dist/${ARTIFACT_NAME}"
cp build/kvrocks "dist/${ARTIFACT_NAME}/"
cp kvrocks.conf LICENSE NOTICE "dist/${ARTIFACT_NAME}/"
cd dist
tar czf "${ARTIFACT_NAME}.tar.gz" "${ARTIFACT_NAME}"
# Upload artifacts
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: kvrocks-${{ matrix.name }}
path: dist/*.tar.gz
retention-days: 7

create-release:
needs: build-artifacts
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: artifacts/**/*.tar.gz
tag_name: ${{ github.sha }}

2 changes: 1 addition & 1 deletion .github/workflows/kvrocks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

name: CI

on: [push, pull_request]
on: []

# Concurrency strategy:
# github.workflow: distinguish this workflow from others
Expand Down

0 comments on commit 57b9e58

Please sign in to comment.