88 lines
2.7 KiB
YAML
88 lines
2.7 KiB
YAML
name: Release SDSAT
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*.*.*"
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.11"
|
|
|
|
- name: Install deps
|
|
run: |
|
|
python -m pip install -U pip
|
|
pip install -e ".[dev]"
|
|
|
|
- name: Lint + Tests
|
|
run: |
|
|
ruff check . --fix
|
|
pytest -q
|
|
|
|
- name: Build SDSAT tar.gz with metadata (no __init__)
|
|
run: |
|
|
set -eux
|
|
|
|
mkdir -p dist buildtmp/{bin,logs,update}
|
|
|
|
# Copie uniquement le contenu de scripts/ dans buildtmp/bin
|
|
cp -r scripts/. buildtmp/bin/
|
|
|
|
# Exclure __init__.py and remove buildtmp/bin/__pycache__
|
|
find buildtmp/bin -name "__init__.py" -delete
|
|
rm -R "buildtmp/bin/__pycache__"
|
|
|
|
# Metadata
|
|
cat > buildtmp/update/BUILD_INFO.txt <<EOF
|
|
REPO=${{ gitea.event.repository.name }}
|
|
TAG=${{ gitea.ref_name }}
|
|
COMMIT=${{ gitea.sha }}
|
|
BUILT_AT=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
|
EOF
|
|
|
|
tar -czf "dist/SDSAT-${{ gitea.ref_name }}.tar.gz" -C buildtmp .
|
|
|
|
ls -la dist
|
|
tar -tzf "dist/SDSAT-${{ gitea.ref_name }}.tar.gz" | head -n 50
|
|
|
|
- name: Create Gitea release (and upload asset)
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
OWNER: ${{ gitea.repository_owner }}
|
|
REPO: ${{ gitea.event.repository.name }}
|
|
TAG: ${{ gitea.ref_name }}
|
|
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
|
run: |
|
|
set -eux
|
|
API="${GITEA_SERVER_URL}/api/v1"
|
|
|
|
# Create release (si existe déjà, on continue)
|
|
curl -sS -X POST "${API}/repos/${OWNER}/${REPO}/releases" \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"draft\":false,\"prerelease\":false}" \
|
|
>/tmp/release_create.json || true
|
|
|
|
# Récupère l'id de la release par tag (fiable)
|
|
curl -sS "${API}/repos/${OWNER}/${REPO}/releases/tags/${TAG}" \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
>/tmp/release_get.json
|
|
|
|
RID=$(python -c "import json;print(json.load(open('/tmp/release_get.json'))['id'])")
|
|
|
|
ASSET="dist/SDSAT-${TAG}.tar.gz"
|
|
ls -la "${ASSET}"
|
|
|
|
curl -sS -X POST "${API}/repos/${OWNER}/${REPO}/releases/${RID}/assets?name=$(basename "${ASSET}")" \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-H "Content-Type: application/gzip" \
|
|
--data-binary @"${ASSET}" \
|
|
>/dev/null
|