Un seul workflow avec 2 jobs: - build: compile 3 archs + test + upload artifacts (tous les push/PR) → binaires téléchargeables dans l'onglet Actions > Summary > Artifacts - release: seulement sur tag v*, download les artifacts, crée une release Gitea avec les 3 binaires attachés (curl API, idempotent)
101 lines
3.8 KiB
YAML
101 lines
3.8 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: |
|
|
git clone --depth 1 https://github.com/vlang/v /opt/v
|
|
cd /opt/v && make
|
|
ln -s /opt/v/v /usr/local/bin/v
|
|
|
|
- name: Build Linux x86_64
|
|
run: |
|
|
mkdir -p build
|
|
v -prod -os linux -arch amd64 -o build/ntfy-bridge-linux-x86_64 .
|
|
|
|
- name: Build Linux arm64 (Raspberry Pi)
|
|
run: v -prod -os linux -arch arm64 -o build/ntfy-bridge-linux-arm64 .
|
|
|
|
- name: Build Windows x86_64
|
|
run: v -prod -os windows -arch amd64 -o build/ntfy-bridge-windows-x86_64.exe .
|
|
|
|
- name: Test
|
|
run: v test .
|
|
|
|
- name: Verify version
|
|
run: |
|
|
./build/ntfy-bridge-linux-x86_64 --version
|
|
./build/ntfy-bridge-linux-x86_64 --help
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ntfy-bridge-binaires
|
|
path: |
|
|
build/ntfy-bridge-linux-x86_64
|
|
build/ntfy-bridge-linux-arm64
|
|
build/ntfy-bridge-windows-x86_64.exe
|
|
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
needs: build
|
|
steps:
|
|
- name: Download artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: ntfy-bridge-binaires
|
|
path: build
|
|
|
|
- name: Publish Gitea Release
|
|
run: |
|
|
VERSION=${GITHUB_REF#refs/tags/}
|
|
echo "==> Creating release ${VERSION}..."
|
|
chmod +x build/* 2>/dev/null || true
|
|
|
|
# Supprimer release existante (idempotent)
|
|
EXISTING=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
|
"${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/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 -s -f -X DELETE \
|
|
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
|
"${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases/${EXISTING_ID}"
|
|
fi
|
|
|
|
# Creer la release
|
|
RELEASE_RESP=$(curl -s -f -X POST \
|
|
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"tag_name\":\"${VERSION}\",\"name\":\"${VERSION}\",\"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\`\n\n### Installation\n\`\`\`bash\nchmod +x ntfy-bridge-linux-x86_64\nsudo mv ntfy-bridge-linux-x86_64 /usr/local/bin/ntfy-bridge\nntfy-bridge --install-service\n\`\`\`\",\"draft\":false,\"prerelease\":false}" \
|
|
"${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases")
|
|
RELEASE_ID=$(echo "$RELEASE_RESP" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
|
|
echo "Release ID: ${RELEASE_ID}"
|
|
|
|
# Uploader les binaires
|
|
for FILE in build/ntfy-bridge-*; do
|
|
[ -f "$FILE" ] || continue
|
|
FNAME=$(basename "$FILE")
|
|
echo " Uploading ${FNAME}..."
|
|
curl -s -f -X POST \
|
|
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
|
-H "Content-Type: application/octet-stream" \
|
|
--data-binary "@${FILE}" \
|
|
"${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${FNAME}"
|
|
done
|
|
|
|
echo "==> Release ${VERSION} complete!"
|