name: Package Alpine
on:
workflow_call:
inputs:
ref:
required: true
type: string
description: 'Git ref to checkout (tag or branch)'
jobs:
alpine:
strategy:
matrix:
include:
- arch: x86_64
apk_arch: x86_64
runner: ubuntu-latest
runs-on: ${{ matrix.runner }}
container: alpine:latest
steps:
- name: Install dependencies
run: apk add --no-cache alpine-sdk sudo git
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ inputs.ref }}
- name: Get package info
id: pkg
run: |
BIN_NAME=$(grep -A1 '^\[\[bin\]\]' Cargo.toml | grep '^name' | head -1 | sed 's/.*= *"\([^"]*\)".*/\1/' || true)
if [ -z "$BIN_NAME" ]; then
BIN_NAME=$(grep '^name' Cargo.toml | head -1 | sed 's/.*= *"\([^"]*\)".*/\1/')
fi
VERSION="${{ inputs.ref }}"
VERSION="${VERSION#v}"
echo "bin_name=$BIN_NAME" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Download pre-built binary (musl)
uses: actions/download-artifact@v7
with:
name: ${{ steps.pkg.outputs.bin_name }}-linux-musl-${{ matrix.arch }}
path: build
- name: Extract binary
run: |
cd build
tar -xzf *.tar.gz
mv ${{ steps.pkg.outputs.bin_name }} ../
- name: Prepare build directory
run: |
mkdir -p pkg/src/config
# Copy source files to pkg root (where APKBUILD is) so abuild finds them
cp ${{ steps.pkg.outputs.bin_name }} pkg/vane
cp package/alpine/vane.initd pkg/
cp package/alpine/vane.post-install pkg/
cp LICENSE pkg/
# Manually populate src/config for the package() function (since it's not in source array)
cp -r package/default/* pkg/src/config/
# Explicitly copy .env.example as .env
cp package/default/.env.example pkg/src/config/.env
rm -f pkg/src/config/vane.service
# Prepare APKBUILD
cp package/alpine/APKBUILD pkg/
sed -i "s/%VERSION%/${{ steps.pkg.outputs.version }}/g" pkg/APKBUILD
sed -i "s/%ARCH%/${{ matrix.apk_arch }}/g" pkg/APKBUILD
- name: Build package
run: |
cd pkg
adduser -D builder
addgroup builder abuild
chown -R builder:builder .
su builder -c "abuild-keygen -an"
# Install the generated public key to /etc/apk/keys so the package is trusted
cp /home/builder/.abuild/*.rsa.pub /etc/apk/keys/
# Automatically calculate checksums for local files to avoid "missing in checksums" error
su builder -c "abuild checksum"
su builder -c "abuild -F"
- name: Find and rename package
run: |
APK_FILE=$(find /home/builder/packages -name "*.apk" | head -1)
FINAL_NAME="${{ steps.pkg.outputs.bin_name }}-v${{ steps.pkg.outputs.version }}-alpine-${{ matrix.arch }}.apk"
cp "$APK_FILE" "$FINAL_NAME"
- name: Upload artifact
uses: actions/upload-artifact@v6
with:
name: ${{ steps.pkg.outputs.bin_name }}-alpine-${{ matrix.arch }}
path: ${{ steps.pkg.outputs.bin_name }}-v${{ steps.pkg.outputs.version }}-alpine-${{ matrix.arch }}.apk
retention-days: 1