Files
ntfy-bridge/.gitea/workflows/ci.yml
T
2026-08-07 09:31:00 -04:00

137 lines
5.2 KiB
YAML

name: CI
on:
push:
branches: [main]
tags: ['v*']
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install V
run: |
set -e
mkdir -p $HOME/.local/bin
echo "Trying to download V from GitHub..."
mkdir -p /opt/v
if curl -fsSL --connect-timeout 10 https://github.com/vlang/v/releases/latest/download/v_linux.zip -o /tmp/v.zip; then
unzip -q /tmp/v.zip -d /opt/v
# V binary may be at /opt/v/v or /opt/v/v/v depending on zip structure
V_BIN=$(find /opt/v -name v -type f | head -1)
if [ -n "$V_BIN" ]; then
ln -sf "$V_BIN" /usr/local/bin/v 2>/dev/null || ln -sf "$V_BIN" $HOME/.local/bin/v
fi
else
echo "GitHub unreachable — installing V from source (no submodules)..."
git clone --depth 1 --single-branch --recurse-submodules=no https://github.com/vlang/v /opt/v 2>/dev/null || true
if [ -f /opt/v/v ]; then
ln -sf /opt/v/v $HOME/.local/bin/v
else
cd /opt/v && make without_tcc 2>/dev/null || make 2>/dev/null || true
ln -sf /opt/v/v $HOME/.local/bin/v 2>/dev/null || true
fi
fi
export PATH="$HOME/.local/bin:$PATH"
echo "V version:" && v version
- name: Install cross-compilers
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq gcc-mingw-w64-x86-64 gcc-aarch64-linux-gnu
- name: Build Linux x86_64
run: |
export PATH="$HOME/.local/bin:$PATH"
mkdir -p build
v -prod -os linux -arch amd64 -o build/ntfy-bridge-linux-x86_64 .
- name: Build Linux arm64 (Raspberry Pi)
run: |
export PATH="$HOME/.local/bin:$PATH"
v -prod -os linux -arch arm64 -o build/ntfy-bridge-linux-arm64 .
- name: Build Windows x86_64
run: |
export PATH="$HOME/.local/bin:$PATH"
v -prod -os windows -arch amd64 -o build/ntfy-bridge-windows-x86_64.exe .
- name: Test
run: |
export PATH="$HOME/.local/bin:$PATH"
v test .
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: binaires
path: build/*
- name: Upload to Nexus raw repository (tags only)
if: startsWith(github.ref, 'refs/tags/v')
env:
NEXUS_URL: ${{ secrets.NEXUS_URL }}
NEXUS_USER: ${{ secrets.NEXUS_USER }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
run: |
set -euo pipefail
VERSION=${GITHUB_REF#refs/tags/}
for FILE in build/ntfy-bridge-*; do
[ -f "$FILE" ] || continue
FNAME=$(basename "$FILE")
echo "==> Uploading ${FNAME} to Nexus (${VERSION})..."
curl -sf -u "${NEXUS_USER}:${NEXUS_PASSWORD}" \
-X PUT \
-H "Content-Type: application/octet-stream" \
--data-binary "@${FILE}" \
"${NEXUS_URL}/repository/raw-hosted/ntfy-bridge/${VERSION}/${FNAME}"
echo " OK"
done
- name: Publish Release (tags only)
if: startsWith(github.ref, 'refs/tags/v')
env:
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: |
set -euo pipefail
VERSION=${GITHUB_REF#refs/tags/}
API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
echo "==> Creating release ${VERSION}..."
# Supprimer release existante (idempotent)
EXISTING=$(curl -sf -H "Authorization: token ${RELEASE_TOKEN}" "${API}/releases/tags/${VERSION}")
EXISTING_ID=$(echo "$EXISTING" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
if [ -n "$EXISTING_ID" ]; then
echo " Deleting existing release #${EXISTING_ID}..."
curl -sf -X DELETE -H "Authorization: token ${RELEASE_TOKEN}" "${API}/releases/${EXISTING_ID}"
fi
# Creer la release
BODY="## ntfy-bridge ${VERSION}\n\nBinaires statiques — zero dependance.\n\n### Linux\n- \`ntfy-bridge-linux-x86_64\` (x86_64)\n- \`ntfy-bridge-linux-arm64\` (Raspberry Pi)\n\n### Windows\n- \`ntfy-bridge-windows-x86_64.exe\`"
RESP=$(curl -sf -X POST \
-H "Authorization: token ${RELEASE_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"tag_name\":\"${VERSION}\",\"name\":\"${VERSION}\",\"body\":\"${BODY}\",\"draft\":false,\"prerelease\":false}" \
"${API}/releases")
RELEASE_ID=$(echo "$RESP" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
echo "Release ID: ${RELEASE_ID}"
# Uploader chaque binaire
for FILE in build/ntfy-bridge-*; do
[ -f "$FILE" ] || continue
FNAME=$(basename "$FILE")
echo " Uploading ${FNAME}..."
curl -sf -X POST \
-H "Authorization: token ${RELEASE_TOKEN}" \
-H "Content-Type: application/octet-stream" \
--data-binary "@${FILE}" \
"${API}/releases/${RELEASE_ID}/assets?name=${FNAME}"
done
echo "==> Release ${VERSION} complete!"