Update .gitea/workflows/release.yml
All checks were successful
CI / test (push) Successful in 12s

This commit is contained in:
2026-02-14 10:19:24 +01:00
parent 15a2cf3116
commit 9d4db87c8b

View File

@@ -1,4 +1,4 @@
name: Release SDSAT name: Release
on: on:
push: push:
@@ -15,45 +15,55 @@ jobs:
with: with:
python-version: "3.11" python-version: "3.11"
- name: Install deps - name: Install tooling
run: | run: |
python -m pip install -U pip python -m pip install -U pip
pip install -r requirements.txt pip install ruff pytest requests
pip install -r requirements-dev.txt
- name: Lint + Tests - name: Lint + tests
run: | run: |
ruff check . ruff check . --fix
pytest -q pytest -q
- name: Build release package - name: Build zip
run: | run: |
mkdir -p dist mkdir -p dist
zip -r dist/SDSAT-${{ gitea.ref_name }}.zip scripts pyproject.toml requirements.txt zip -r "dist/SDSAT-${{ gitea.ref_name }}.zip" scripts pyproject.toml || true
# Crée une release Gitea + upload l'asset # Si requirements.txt existe, on le met aussi
- name: Create Gitea release (and upload asset) if [ -f requirements.txt ]; then
zip -ur "dist/SDSAT-${{ gitea.ref_name }}.zip" requirements.txt
fi
- name: Create release + upload asset (Gitea API)
env: env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
GITEA_SERVER_URL: ${{ gitea.server_url }}
OWNER: ${{ gitea.repository_owner }} OWNER: ${{ gitea.repository_owner }}
REPO: ${{ gitea.event.repository.name }} REPO: ${{ gitea.event.repository.name }}
TAG: ${{ gitea.ref_name }} TAG: ${{ gitea.ref_name }}
GITEA_SERVER_URL: ${{ gitea.server_url }}
run: | run: |
set -e set -e
API="${GITEA_SERVER_URL}/api/v1" API="${GITEA_SERVER_URL}/api/v1"
# create release
# Create release (ignore if exists)
curl -sS -X POST "${API}/repos/${OWNER}/${REPO}/releases" \ curl -sS -X POST "${API}/repos/${OWNER}/${REPO}/releases" \
-H "Authorization: token ${GITEA_TOKEN}" \ -H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"draft\":false,\"prerelease\":false}" \ -d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"draft\":false,\"prerelease\":false}" \
>/tmp/release.json >/tmp/release_create.json || true
RID=$(python -c "import json;print(json.load(open('/tmp/release.json'))['id'])") # Get release by tag
curl -sS "${API}/repos/${OWNER}/${REPO}/releases/tags/${TAG}" \
-H "Authorization: token ${GITEA_TOKEN}" \
>/tmp/release_get.json
# upload asset RID=$(python -c "import json;print(json.load(open('/tmp/release_get.json'))['id'])")
curl -sS -X POST "${API}/repos/${OWNER}/${REPO}/releases/${RID}/assets?name=SDSAT-${TAG}.zip" \
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 "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/zip" \ -H "Content-Type: application/zip" \
--data-binary @dist/SDSAT-${TAG}.zip \ --data-binary @"${ASSET}" \
>/dev/null >/dev/null