mirror of
https://github.com/Slava-Shchipunov/awg-openwrt.git
synced 2026-03-14 01:13:09 +00:00
209 lines
7.6 KiB
YAML
209 lines
7.6 KiB
YAML
name: Create Release on Tag
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*.*.*"
|
|
workflow_call:
|
|
inputs:
|
|
tag_name:
|
|
required: true
|
|
type: string
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: 'OpenWRT version (e.g., 24.10.5)'
|
|
required: true
|
|
type: string
|
|
targets:
|
|
description: 'Targets (comma-separated, optional)'
|
|
required: false
|
|
type: string
|
|
subtargets:
|
|
description: 'Subtargets (comma-separated, optional)'
|
|
required: false
|
|
type: string
|
|
|
|
|
|
jobs:
|
|
generate-config:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
job-config: ${{ steps.generate-config.outputs.job-config }}
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20.16.0'
|
|
|
|
- name: Get OpenWRT version from inputs or tag
|
|
run: |
|
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
|
echo "VERSION=${{ inputs.version }}" >> $GITHUB_ENV
|
|
|
|
if [ -n "${{ inputs.targets }}" ]; then
|
|
echo "TARGETS=${{ inputs.targets }}" >> $GITHUB_ENV
|
|
fi
|
|
|
|
if [ -n "${{ inputs.subtargets }}" ]; then
|
|
echo "SUBTARGETS=${{ inputs.subtargets }}" >> $GITHUB_ENV
|
|
fi
|
|
|
|
elif [ "${{ github.event_name }}" = "workflow_call" ]; then
|
|
echo "VERSION=${{ inputs.tag_name }}" >> $GITHUB_ENV
|
|
|
|
else
|
|
echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
|
|
fi
|
|
|
|
- name: Install dependencies
|
|
run: npm install
|
|
|
|
- name: Generate Job Config
|
|
id: generate-config
|
|
run: node index.js ${{ env.VERSION }} "${{ env.TARGETS }}" "${{ env.SUBTARGETS }}"
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
build:
|
|
name: "v${{ matrix.build_env.tag }} - ${{ matrix.build_env.pkgarch}} :: ${{ matrix.build_env.target}}/${{ matrix.build_env.subtarget}} build"
|
|
runs-on: ubuntu-latest
|
|
needs: generate-config
|
|
strategy:
|
|
matrix:
|
|
build_env: ${{ fromJson(needs.generate-config.outputs.job-config) }}
|
|
fail-fast: false
|
|
|
|
steps:
|
|
- name: Checkout AWG source code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install Python dependencies
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y python3-pyelftools
|
|
|
|
- name: Cache OpenWrt SDK
|
|
id: cache-sdk
|
|
uses: actions/cache@v4
|
|
env:
|
|
cache-name: "cache-sdk-${{ matrix.build_env.tag }}-${{ matrix.build_env.target}}-${{ matrix.build_env.subtarget}}"
|
|
with:
|
|
path: openwrt-sdk-*/
|
|
key: ${{ runner.os }}-sdk-${{ env.cache-name }}
|
|
|
|
- name: Download and extract OpenWrt SDK
|
|
if: steps.cache-sdk.outputs.cache-hit != 'true'
|
|
run: |
|
|
echo "pkgarch: ${{ matrix.build_env.pkgarch}}, target:${{ matrix.build_env.target}}, subtarget: ${{ matrix.build_env.subtarget}}"
|
|
|
|
# Get the actual SDK filename from the directory listing
|
|
SDK_FILE=$(curl -s "https://downloads.openwrt.org/releases/${{ matrix.build_env.tag }}/targets/${{ matrix.build_env.target}}/${{ matrix.build_env.subtarget}}/" | grep -o "openwrt-sdk-${{ matrix.build_env.tag }}-${{ matrix.build_env.target}}-${{ matrix.build_env.subtarget}}_gcc-[^\"]*_musl[^\"]*\.Linux-x86_64\.tar\.[xz|zst]*" | head -n1)
|
|
|
|
if [ -z "$SDK_FILE" ]; then
|
|
echo "SDK file not found for ${{ matrix.build_env.tag }} ${{ matrix.build_env.target}} ${{ matrix.build_env.subtarget}}"
|
|
exit 1
|
|
fi
|
|
|
|
SDK_DOWNLOAD_URL="https://downloads.openwrt.org/releases/${{ matrix.build_env.tag }}/targets/${{ matrix.build_env.target}}/${{ matrix.build_env.subtarget}}/${SDK_FILE}"
|
|
echo "Downloading SDK: $SDK_DOWNLOAD_URL"
|
|
|
|
wget "$SDK_DOWNLOAD_URL"
|
|
|
|
# Extract based on file extension
|
|
if [[ "$SDK_FILE" == *.tar.zst ]]; then
|
|
tar --zstd -xf "$SDK_FILE"
|
|
elif [[ "$SDK_FILE" == *.tar.xz ]]; then
|
|
tar -xf "$SDK_FILE"
|
|
else
|
|
echo "Unknown archive format: $SDK_FILE"
|
|
exit 1
|
|
fi
|
|
|
|
rm "$SDK_FILE"
|
|
|
|
- name: Setup SDK and feeds
|
|
run: |
|
|
SDK_DIR=$(find . -maxdepth 1 -name "openwrt-sdk-*" -type d | head -n1)
|
|
[ -z "$SDK_DIR" ] && echo "SDK directory not found" && exit 1
|
|
|
|
WORKSPACE_DIR=$(pwd)
|
|
cd "$SDK_DIR"
|
|
|
|
# Remove unstable feeds
|
|
sed -i '/telephony/d' feeds.conf.default
|
|
sed -i '/routing/d' feeds.conf.default
|
|
|
|
# Update only required feeds
|
|
./scripts/feeds update base packages luci
|
|
./scripts/feeds install -p base
|
|
./scripts/feeds install -p packages
|
|
./scripts/feeds install -p luci
|
|
|
|
# Copy packages
|
|
cp -r "$WORKSPACE_DIR/kmod-amneziawg" package/
|
|
cp -r "$WORKSPACE_DIR/amneziawg-tools" package/
|
|
cp -r "$WORKSPACE_DIR/luci-proto-amneziawg" package/
|
|
|
|
# Config
|
|
cat > .config <<EOF
|
|
CONFIG_PACKAGE_kmod-amneziawg=m
|
|
CONFIG_PACKAGE_amneziawg-tools=y
|
|
CONFIG_PACKAGE_luci-proto-amneziawg=y
|
|
CONFIG_PACKAGE_luci-i18n-amneziawg-ru=y
|
|
EOF
|
|
|
|
make defconfig
|
|
|
|
- name: Build AmneziaWG packages
|
|
run: |
|
|
# Find SDK directory
|
|
SDK_DIR=$(find . -maxdepth 1 -name "openwrt-sdk-*" -type d | head -n1)
|
|
cd "$SDK_DIR"
|
|
|
|
echo "Building AmneziaWG packages..."
|
|
|
|
# Build kmod-amneziawg (kernel module)
|
|
echo "Building kmod-amneziawg..."
|
|
make package/kmod-amneziawg/{download,prepare} V=s || true
|
|
make package/kmod-amneziawg/compile V=s || true
|
|
|
|
# Build luci-proto-amneziawg (web interface)
|
|
echo "Building luci-proto-amneziawg..."
|
|
make package/luci-proto-amneziawg/{download,prepare} V=s
|
|
make package/luci-proto-amneziawg/compile V=s
|
|
|
|
# Build amneziawg-tools (userspace tools)
|
|
echo "Building amneziawg-tools..."
|
|
make package/amneziawg-tools/{download,prepare} V=s
|
|
make package/amneziawg-tools/compile V=s
|
|
|
|
echo "Build completed. Checking for built packages..."
|
|
find bin/ -name "*.ipk" | grep -E "(amneziawg|luci-proto-amneziawg|luci-i18n-amneziawg)" | head -10
|
|
|
|
- name: Prepare artifacts
|
|
run: |
|
|
# Find SDK directory
|
|
SDK_DIR=$(find . -maxdepth 1 -name "openwrt-sdk-*" -type d | head -n1)
|
|
|
|
mkdir -p awgrelease
|
|
postfix="v${{ matrix.build_env.tag }}_${{ matrix.build_env.pkgarch}}_${{ matrix.build_env.target}}_${{ matrix.build_env.subtarget}}"
|
|
|
|
# Copy built packages
|
|
find "$SDK_DIR/bin/packages" -name "amneziawg-tools_*.ipk" -exec cp {} awgrelease/amneziawg-tools_${postfix}.ipk \; || echo "amneziawg-tools package not found"
|
|
find "$SDK_DIR/bin/packages" -name "luci-proto-amneziawg_*.ipk" -exec cp {} awgrelease/luci-proto-amneziawg_${postfix}.ipk \; || echo "luci-proto-amneziawg package not found"
|
|
find "$SDK_DIR/bin/packages" -name "luci-i18n-amneziawg-ru_*.ipk" -exec cp {} awgrelease/luci-i18n-amneziawg-ru_${postfix}.ipk \; || echo "luci-i18n-amneziawg-ru package not found"
|
|
find "$SDK_DIR/bin/targets" -name "kmod-amneziawg_*.ipk" -exec cp {} awgrelease/kmod-amneziawg_${postfix}.ipk \; || echo "kmod-amneziawg package not found"
|
|
|
|
echo "Built packages:"
|
|
ls -la awgrelease/
|
|
|
|
- name: Release
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
files: awgrelease/*.ipk
|
|
tag_name: v${{ matrix.build_env.tag }}
|