diff --git a/.github/workflows/release-linux.yaml b/.github/workflows/release-linux.yaml new file mode 100644 index 0000000..b169429 --- /dev/null +++ b/.github/workflows/release-linux.yaml @@ -0,0 +1,66 @@ +# 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*' + +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: + - uses: 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..258fe2c --- /dev/null +++ b/docker/alpine/build.sh @@ -0,0 +1,23 @@ +#!/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 +export VCPKG_FORCE_SYSTEM_BINARIES=1 +./vcpkg/bootstrap-vcpkg.sh +cmake -B build-$ARCH +cmake --build build-$ARCH +cp ./build-$ARCH/snctl-cpp .