Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 85ec200a13 | |||
| 260b8f0217 | |||
| a5f83dc2f2 |
@@ -1,9 +1,10 @@
|
|||||||
name: Release
|
name: Release SDSAT
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- "v*.*.*"
|
- "v*.*.*"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
@@ -15,74 +16,71 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
python-version: "3.11"
|
python-version: "3.11"
|
||||||
|
|
||||||
- name: Install tooling
|
- name: Install deps
|
||||||
run: |
|
run: |
|
||||||
python -m pip install -U pip
|
python -m pip install -U pip
|
||||||
pip install ruff pytest requests
|
pip install -e ".[dev]"
|
||||||
|
|
||||||
- name: Lint + tests
|
- name: Lint + Tests
|
||||||
run: |
|
run: |
|
||||||
ruff check . --fix
|
ruff check .
|
||||||
pytest -q
|
pytest -q
|
||||||
|
|
||||||
- name: Build SDSAT tar.gz
|
- name: Build SDSAT tar.gz with metadata (no __init__)
|
||||||
run: |
|
run: |
|
||||||
|
set -eux
|
||||||
|
|
||||||
mkdir -p dist buildtmp
|
mkdir -p dist buildtmp/{bin,logs,update}
|
||||||
|
|
||||||
# Copie uniquement les scripts dans buildtmp
|
# Copie uniquement le contenu de scripts/ dans buildtmp/bin
|
||||||
cp -r scripts/* buildtmp/
|
cp -r scripts/. buildtmp/bin/
|
||||||
|
|
||||||
# Supprime __init__.py
|
# Exclure __init__.py
|
||||||
find buildtmp/ -name "__init__.py" -delete
|
find buildtmp/bin -name "__init__.py" -delete
|
||||||
|
|
||||||
# Génère le fichier de metadata
|
# Metadata
|
||||||
cat > buildtmp/BUILD_INFO.txt <<EOF
|
cat > buildtmp/update/BUILD_INFO.txt <<EOF
|
||||||
REPO=${{ gitea.event.repository.name }}
|
REPO=${{ gitea.event.repository.name }}
|
||||||
TAG=${{ gitea.ref_name }}
|
TAG=${{ gitea.ref_name }}
|
||||||
COMMIT=${{ gitea.sha }}
|
COMMIT=${{ gitea.sha }}
|
||||||
BUILT_AT=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
BUILT_AT=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Création du tar.gz
|
|
||||||
tar -czf "dist/SDSAT-${{ gitea.ref_name }}.tar.gz" -C buildtmp .
|
tar -czf "dist/SDSAT-${{ gitea.ref_name }}.tar.gz" -C buildtmp .
|
||||||
|
|
||||||
- name: Create release + upload asset (Gitea API)
|
ls -la dist
|
||||||
|
tar -tzf "dist/SDSAT-${{ gitea.ref_name }}.tar.gz" | head -n 50
|
||||||
|
|
||||||
|
- name: Create Gitea release (and upload asset)
|
||||||
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 -eux
|
||||||
API="${GITEA_SERVER_URL}/api/v1"
|
API="${GITEA_SERVER_URL}/api/v1"
|
||||||
|
|
||||||
# Create release (ignore if exists)
|
# Create release (si existe déjà, on continue)
|
||||||
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_create.json || true
|
>/tmp/release_create.json || true
|
||||||
|
|
||||||
# Get release by tag
|
# Récupère l'id de la release par tag (fiable)
|
||||||
curl -sS "${API}/repos/${OWNER}/${REPO}/releases/tags/${TAG}" \
|
curl -sS "${API}/repos/${OWNER}/${REPO}/releases/tags/${TAG}" \
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
>/tmp/release_get.json
|
>/tmp/release_get.json
|
||||||
|
|
||||||
RID=$(python -c "import json;print(json.load(open('/tmp/release_get.json'))['id'])")
|
RID=$(python -c "import json;print(json.load(open('/tmp/release_get.json'))['id'])")
|
||||||
|
|
||||||
ASSET="dist/SDSAT-${TAG}.zip"
|
ASSET="dist/SDSAT-${TAG}.tar.gz"
|
||||||
|
ls -la "${ASSET}"
|
||||||
|
|
||||||
echo "PWD=$(pwd)"
|
curl -sS -X POST "${API}/repos/${OWNER}/${REPO}/releases/${RID}/assets?name=$(basename "${ASSET}")" \
|
||||||
echo "Listing dist:"
|
|
||||||
ls -la dist || true
|
|
||||||
echo "Find tar.gz:"
|
|
||||||
find . -maxdepth 3 -type f \( -name "*.tar.gz" -o -name "*.zip" \) -print -exec ls -la {} \;
|
|
||||||
|
|
||||||
|
|
||||||
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/gzip" \
|
||||||
--data-binary @"${ASSET}" \
|
--data-binary @"${ASSET}" \
|
||||||
>/dev/null
|
>/dev/null
|
||||||
|
|||||||
Reference in New Issue
Block a user