mirror of
https://github.com/Mo3he/Axis_Cam_Tailscale.git
synced 2026-07-27 02:23:24 +00:00
150 lines
5.4 KiB
YAML
150 lines
5.4 KiB
YAML
name: Auto Build & Release Tailscale ACAP
|
|
|
|
on:
|
|
schedule:
|
|
- cron: "0 3 * * 1" # Every Monday at 03:00 UTC
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-and-release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
|
|
# 1. Checkout repo
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
persist-credentials: true
|
|
fetch-depth: 0
|
|
|
|
# 2. Get latest Tailscale version
|
|
- name: Get latest Tailscale version
|
|
id: tailscale_version
|
|
run: |
|
|
VERSION=$(curl -s https://api.github.com/repos/tailscale/tailscale/releases/latest | jq -r .tag_name)
|
|
VERSION=${VERSION#v} # remove leading 'v'
|
|
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
|
|
- name: Get current repo version
|
|
id: current
|
|
run: |
|
|
CURRENT=$(find . -path "*/app/manifest.json" -exec jq -r '.acapPackageConf.setup.version' {} \; | sort -u | head -n1)
|
|
echo "CURRENT_VERSION=$CURRENT" >> $GITHUB_ENV
|
|
echo "Current repo version: $CURRENT"
|
|
|
|
- name: Compare versions
|
|
id: compare
|
|
run: |
|
|
echo "Repo version: $CURRENT_VERSION"
|
|
echo "Latest Tailscale version: $RELEASE_VERSION"
|
|
|
|
if [ "$CURRENT_VERSION" = "$RELEASE_VERSION" ]; then
|
|
echo "build_needed=false" >> $GITHUB_ENV
|
|
echo "Already up to date. Skipping build."
|
|
else
|
|
echo "build_needed=true" >> $GITHUB_ENV
|
|
echo "New version detected. Will build."
|
|
fi
|
|
|
|
# 3. Download Tailscale binaries
|
|
- name: Download Tailscale binaries
|
|
if: env.build_needed == 'true'
|
|
run: |
|
|
mkdir -p tailscale_bins
|
|
curl -L "https://pkgs.tailscale.com/stable/tailscale_${RELEASE_VERSION}_arm.tgz" -o tailscale_arm.tgz
|
|
tar -xzf tailscale_arm.tgz -C tailscale_bins --strip-components=1
|
|
mv tailscale_bins/tailscale tailscale_bins/tailscale_arm
|
|
mv tailscale_bins/tailscaled tailscale_bins/tailscaled_arm
|
|
|
|
curl -L "https://pkgs.tailscale.com/stable/tailscale_${RELEASE_VERSION}_arm64.tgz" -o tailscale_arm64.tgz
|
|
tar -xzf tailscale_arm64.tgz -C tailscale_bins --strip-components=1
|
|
mv tailscale_bins/tailscale tailscale_bins/tailscale_arm64
|
|
mv tailscale_bins/tailscaled tailscale_bins/tailscaled_arm64
|
|
|
|
# 4. Build each folder, update manifest, and copy .eap files
|
|
- name: Build all folders
|
|
if: env.build_needed == 'true'
|
|
run: |
|
|
mkdir -p build
|
|
rm -rf releases
|
|
mkdir -p releases
|
|
|
|
for folder in */ ; do
|
|
[[ ! -d "$folder/app" ]] && continue
|
|
FOLDER_NAME="${folder%/}" # remove trailing slash
|
|
echo "Processing folder $FOLDER_NAME"
|
|
|
|
# Detect architecture
|
|
if [[ "$FOLDER_NAME" == arm* ]]; then
|
|
cp tailscale_bins/tailscale_arm "$folder/app/lib/tailscale"
|
|
cp tailscale_bins/tailscaled_arm "$folder/app/lib/tailscaled"
|
|
else
|
|
cp tailscale_bins/tailscale_arm64 "$folder/app/lib/tailscale"
|
|
cp tailscale_bins/tailscaled_arm64 "$folder/app/lib/tailscaled"
|
|
fi
|
|
|
|
# Stage updated binaries for commit
|
|
git add "$folder/app/lib/tailscale" "$folder/app/lib/tailscaled"
|
|
|
|
# Detect variant suffix for .eap naming
|
|
if [[ "$FOLDER_NAME" == *_ROOT ]]; then
|
|
VARIANT="_root"
|
|
elif [[ "$FOLDER_NAME" == *_custom ]]; then
|
|
VARIANT="_custom"
|
|
else
|
|
VARIANT=""
|
|
fi
|
|
|
|
# Update manifest version
|
|
sed -i "s/\"version\": \".*\"/\"version\": \"${RELEASE_VERSION}\"/" "$folder/app/manifest.json"
|
|
|
|
# Docker build
|
|
TAG_NAME=$(echo "$FOLDER_NAME" | tr '[:upper:]' '[:lower:]' | tr '/ ' '_') # lowercase and clean
|
|
echo "Building $TAG_NAME"
|
|
docker build -f "$folder/Dockerfile" --tag "$TAG_NAME" "$folder"
|
|
|
|
# Extract .eap files into build folder
|
|
EAP_OUTPUT="./build/${TAG_NAME}"
|
|
mkdir -p "$EAP_OUTPUT"
|
|
docker cp $(docker create "$TAG_NAME"):/opt/app "$EAP_OUTPUT"
|
|
|
|
# Move all .eap files to releases folder, append variant if needed
|
|
find "$EAP_OUTPUT" -type f -name "*.eap" | while read eap; do
|
|
BASENAME=$(basename "$eap" .eap)
|
|
if [[ -n "$VARIANT" ]]; then
|
|
mv "$eap" "releases/${BASENAME}${VARIANT}.eap"
|
|
else
|
|
mv "$eap" "releases/${BASENAME}.eap"
|
|
fi
|
|
done
|
|
done
|
|
|
|
# Clean up
|
|
rm -rf build tailscale_bins *.tgz
|
|
|
|
# 5. Commit updated manifests and .eap files directly to main
|
|
- name: Commit updates to main
|
|
if: env.build_needed == 'true'
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
|
|
git add */app/manifest.json releases/*
|
|
if git diff --cached --quiet; then
|
|
echo "No changes to commit"
|
|
else
|
|
git commit -m "Update Tailscale to v${RELEASE_VERSION}"
|
|
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/Mo3he/Axis_Cam_Tailscale.git main
|
|
fi
|
|
|
|
# 6. Create GitHub Release with all new .eap files
|
|
- name: Create GitHub Release
|
|
if: env.build_needed == 'true'
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
tag_name: v${{ env.RELEASE_VERSION }}
|
|
name: "Tailscale VPN ${{ env.RELEASE_VERSION }}"
|
|
files: releases/*
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|