84 lines
2.5 KiB
YAML
84 lines
2.5 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*.*.*"
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.11"
|
|
|
|
- name: Install tooling
|
|
run: |
|
|
python -m pip install -U pip
|
|
pip install ruff pytest requests
|
|
|
|
- name: Lint + tests
|
|
run: |
|
|
ruff check . --fix
|
|
pytest -q
|
|
|
|
- name: Build SDSAT tar.gz
|
|
run: |
|
|
mkdir -p dist buildtmp/{bin,logs,update}
|
|
|
|
# Copie scripts
|
|
cp -r scripts buildtmp/scripts/bin/
|
|
|
|
pwd
|
|
ls buildtmp/scripts/ -pila
|
|
|
|
# Supprime tous les __init__.py
|
|
find buildtmp/scripts/bin -name "__init__.py" -delete
|
|
|
|
# Génère le fichier de metadata
|
|
cat > buildtmp/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
|
|
|
|
# Création du tar.gz
|
|
tar -czf "dist/SDSAT-${{ gitea.ref_name }}.tar.gz" -C buildtmp .
|
|
|
|
- name: Create release + upload asset (Gitea API)
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
|
OWNER: ${{ gitea.repository_owner }}
|
|
REPO: ${{ gitea.event.repository.name }}
|
|
TAG: ${{ gitea.ref_name }}
|
|
run: |
|
|
set -e
|
|
API="${GITEA_SERVER_URL}/api/v1"
|
|
|
|
# Create release (ignore if exists)
|
|
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
|
|
|
|
# Get release by tag
|
|
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}.zip"
|
|
|
|
curl -sS -X POST "${API}/repos/${OWNER}/${REPO}/releases/${RID}/assets?name=$(basename ${ASSET})" \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-H "Content-Type: application/zip" \
|
|
--data-binary @"${ASSET}" \
|
|
>/dev/null
|