Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8772d838d8 | |||
| 6454b79270 | |||
| 354e54a6d3 | |||
| 8d5b48e100 | |||
| 85ec200a13 | |||
| 260b8f0217 | |||
| a5f83dc2f2 | |||
| 1337eba8c0 | |||
| d9e8b9e41f | |||
| 1537bff629 | |||
| 6e4ffdba76 | |||
| 74ec6a0ed2 | |||
| 5794b57cbe | |||
| f174960b80 |
@@ -1,41 +1,47 @@
|
|||||||
name: Release
|
name: Release SDSAT
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- "v*.*.*"
|
- "v*.*.*"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
- uses: actions/setup-python@v5
|
- uses: actions/setup-python@v5
|
||||||
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 . --fix
|
||||||
pytest -q
|
pytest -q
|
||||||
|
|
||||||
- name: Build SDSAT tar.gz
|
- name: Build SDSAT tar.gz with metadata (no __init__)
|
||||||
run: |
|
run: |
|
||||||
mkdir -p dist buildtmp/{bin,logs,update}
|
set -eux
|
||||||
|
|
||||||
# Copie scripts
|
mkdir -p dist buildtmp/
|
||||||
cp -r scripts buildtmp/bin/
|
|
||||||
|
|
||||||
# Supprime tous les __init__.py
|
# Copie uniquement le contenu de scripts/ dans buildtmp/bin
|
||||||
find buildtmp/scripts/bin -name "__init__.py" -delete
|
cp -r scripts/. buildtmp/
|
||||||
|
|
||||||
# Génère le fichier de metadata
|
# Exclure __init__.py and remove buildtmp/__pycache__
|
||||||
|
find buildtmp/ -name "__init__.py" -delete
|
||||||
|
rm -R "buildtmp/__pycache__"
|
||||||
|
|
||||||
|
# Metadata
|
||||||
cat > buildtmp/BUILD_INFO.txt <<EOF
|
cat > buildtmp/BUILD_INFO.txt <<EOF
|
||||||
REPO=${{ gitea.event.repository.name }}
|
REPO=${{ gitea.event.repository.name }}
|
||||||
TAG=${{ gitea.ref_name }}
|
TAG=${{ gitea.ref_name }}
|
||||||
@@ -43,38 +49,78 @@ jobs:
|
|||||||
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 (with changelog) + 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 -euo pipefail
|
||||||
API="${GITEA_SERVER_URL}/api/v1"
|
API="${GITEA_SERVER_URL}/api/v1"
|
||||||
|
|
||||||
# Create release (ignore if exists)
|
# 1) Trouver le tag précédent (semver vX.Y.Z), différent du tag courant
|
||||||
|
PREV_TAG=$(git tag --sort=-creatordate | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | grep -v "^${TAG}$" | head -n 1 || true)
|
||||||
|
|
||||||
|
if [ -n "${PREV_TAG}" ]; then
|
||||||
|
RANGE="${PREV_TAG}..${TAG}"
|
||||||
|
COMMITS=$(git log --pretty=format:"- %s (%h)" "${RANGE}")
|
||||||
|
FILES=$(git diff --name-status "${RANGE}")
|
||||||
|
else
|
||||||
|
RANGE="initial (up to ${TAG})"
|
||||||
|
COMMITS=$(git log --pretty=format:"- %s (%h)" "${TAG}")
|
||||||
|
FILES=$(git show --name-status --pretty="" "${TAG}")
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 2) Construire le body Markdown
|
||||||
|
cat > /tmp/release_body.md <<EOF
|
||||||
|
## Changes (${RANGE})
|
||||||
|
|
||||||
|
${COMMITS}
|
||||||
|
|
||||||
|
## Files changed
|
||||||
|
\`\`\`
|
||||||
|
${FILES}
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
## Build info
|
||||||
|
- Repo: ${REPO}
|
||||||
|
- Tag: ${TAG}
|
||||||
|
- Commit: ${{ gitea.sha }}
|
||||||
|
- Built at (UTC): $(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# 3) Créer le JSON payload (via python pour éviter les soucis d'escaping)
|
||||||
|
python -c 'import json; tag=open("/dev/stdin").read().strip()' <<< "${TAG}" >/dev/null 2>&1 || true
|
||||||
|
python -c 'import json; import pathlib; tag=pathlib.Path("/tmp/tag.txt").read_text().strip() if pathlib.Path("/tmp/tag.txt").exists() else ""' >/dev/null 2>&1 || true
|
||||||
|
echo "${TAG}" > /tmp/tag.txt
|
||||||
|
|
||||||
|
python -c 'import json, pathlib; tag=pathlib.Path("/tmp/tag.txt").read_text().strip(); body=pathlib.Path("/tmp/release_body.md").read_text(); print(json.dumps({"tag_name":tag,"name":tag,"body":body,"draft":False,"prerelease":False}))' \
|
||||||
|
> /tmp/release_payload.json
|
||||||
|
|
||||||
|
# 4) Créer la release (si déjà existante, 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 @/tmp/release_payload.json \
|
||||||
>/tmp/release_create.json || true
|
>/tmp/release.json || true
|
||||||
|
|
||||||
# Get release by tag
|
# 5) Récupérer l'ID de la release (par tag) et uploader l'asset
|
||||||
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"
|
||||||
|
curl -sS -X POST "${API}/repos/${OWNER}/${REPO}/releases/${RID}/assets?name=$(basename "${ASSET}")" \
|
||||||
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