From 724d54aa67d2678aa1464629ecbc169578cd7f76 Mon Sep 17 00:00:00 2001 From: Yunze Xu Date: Sun, 18 May 2025 21:08:18 +0800 Subject: [PATCH 1/4] ci: release Alpine binaries --- .github/workflows/release-linux.yaml | 70 ++++++++++++++++++++++++++++ docker/alpine/Dockerfile | 23 +++++++++ docker/alpine/build.sh | 25 ++++++++++ 3 files changed, 118 insertions(+) create mode 100644 .github/workflows/release-linux.yaml create mode 100644 docker/alpine/Dockerfile create mode 100755 docker/alpine/build.sh diff --git a/.github/workflows/release-linux.yaml b/.github/workflows/release-linux.yaml new file mode 100644 index 0000000..5efd291 --- /dev/null +++ b/.github/workflows/release-linux.yaml @@ -0,0 +1,70 @@ +# Copyright 2025 Yunze Xu +# +# Licensed 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: Release Linux binaries + +on: + push: + tags: + - 'v*' + # TODO: remove the following condition + pull_request: + branches: + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + release-alpine: + name: Build binaries on Alpine + runs-on: ubuntu-latest + timeout-minutes: 300 + + strategy: + matrix: + platform: [amd64, arm64] + + steps: + - name: actions/checkout@v3 + with: + fetch-depth: 0 + submodules: recursive + + - uses: docker/setup-qemu-action@v2 + - uses: docker/setup-buildx-action@v2 + - uses: docker/build-push-action@v3 + with: + context: ./docker/alpine + load: true + tags: build:latest + platforms: linux/${{matrix.platform}} + build-args: ARCH=${{matrix.platform}} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: build binaries on ${{ matrix.platform }} + run: | + docker run --rm -v $PWD:/app build /app/docker/alpine/build.sh + + - name: upload + uses: actions/upload-artifact@master + with: + name: snctl-cpp-alpine-${{ matrix.platform }} + path: | + snctl-cpp + sncloud.ini + install.sh diff --git a/docker/alpine/Dockerfile b/docker/alpine/Dockerfile new file mode 100644 index 0000000..ac16543 --- /dev/null +++ b/docker/alpine/Dockerfile @@ -0,0 +1,23 @@ +# Copyright 2025 Yunze Xu +# +# Licensed 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. + +FROM alpine:3.21 + +ARG ARCH +ENV ARCH=${ARCH} + +RUN apk update +# These tools are required by vcpkg and dependencies like openssl +RUN apk add gcc g++ cmake git curl ninja make zip perl linux-headers bash pkgconfig +WORKDIR /app diff --git a/docker/alpine/build.sh b/docker/alpine/build.sh new file mode 100755 index 0000000..e699d63 --- /dev/null +++ b/docker/alpine/build.sh @@ -0,0 +1,25 @@ +#!/bin/ash +# Copyright 2025 Yunze Xu +# +# Licensed 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. + +set -e + +cd /app +if [ $ARCH == "arm64" ]; then + export VCPKG_FORCE_SYSTEM_BINARIES=1 +fi +./vcpkg/bootstrap-vcpkg.sh +cmake -B build-$ARCH +cmake --build build-$ARCH +cp ./build-$ARCH/snctl-cpp . From e895050a6b08f82fd52bd333b0a0ca41a71eb58a Mon Sep 17 00:00:00 2001 From: Yunze Xu Date: Sun, 18 May 2025 21:09:10 +0800 Subject: [PATCH 2/4] fix --- .github/workflows/release-linux.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-linux.yaml b/.github/workflows/release-linux.yaml index 5efd291..7154da2 100644 --- a/.github/workflows/release-linux.yaml +++ b/.github/workflows/release-linux.yaml @@ -39,7 +39,7 @@ jobs: platform: [amd64, arm64] steps: - - name: actions/checkout@v3 + - uses: actions/checkout@v3 with: fetch-depth: 0 submodules: recursive From 338916220e93bcffd35a27251ecd5e1f29f4f04b Mon Sep 17 00:00:00 2001 From: Yunze Xu Date: Sun, 18 May 2025 21:11:49 +0800 Subject: [PATCH 3/4] fix --- docker/alpine/build.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docker/alpine/build.sh b/docker/alpine/build.sh index e699d63..258fe2c 100755 --- a/docker/alpine/build.sh +++ b/docker/alpine/build.sh @@ -16,9 +16,7 @@ set -e cd /app -if [ $ARCH == "arm64" ]; then - export VCPKG_FORCE_SYSTEM_BINARIES=1 -fi +export VCPKG_FORCE_SYSTEM_BINARIES=1 ./vcpkg/bootstrap-vcpkg.sh cmake -B build-$ARCH cmake --build build-$ARCH From 56c2d9efa5f931d42efcafb2b478b6fbfddca2d5 Mon Sep 17 00:00:00 2001 From: Yunze Xu Date: Sun, 18 May 2025 21:14:15 +0800 Subject: [PATCH 4/4] address TODO --- .github/workflows/release-linux.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/release-linux.yaml b/.github/workflows/release-linux.yaml index 7154da2..b169429 100644 --- a/.github/workflows/release-linux.yaml +++ b/.github/workflows/release-linux.yaml @@ -18,10 +18,6 @@ on: push: tags: - 'v*' - # TODO: remove the following condition - pull_request: - branches: - - main concurrency: group: ${{ github.workflow }}-${{ github.ref }}