f0896d775d
- crea gemelli X-github.yml per ogni reusable con action da github.com (fallback mirror gitea.com) - python-dependency-check/outdated: audit in venv isolata (fix falsi positivi da runner ML) - python-dependency-check/outdated: deduplica issue (commento invece di nuova issue) - examples: aggiungi ci-github.yml e release-github.yml in tutte le cartelle Fixes #3 @3h
71 lines
2.2 KiB
YAML
71 lines
2.2 KiB
YAML
name: Python Auto Release
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
working-directory:
|
|
description: 'Directory di lavoro se il progetto non è in root'
|
|
type: string
|
|
default: '.'
|
|
|
|
jobs:
|
|
python-auto-release:
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: ${{ inputs.working-directory }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: https://github.com/actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0
|
|
token: ${{ gitea.token }}
|
|
|
|
- name: Generate changelog
|
|
id: changelog
|
|
run: |
|
|
CURRENT_TAG=${GITHUB_REF#refs/tags/}
|
|
PREV_TAG=$(git tag --sort=-version:refname | sed -n '2p')
|
|
|
|
if [ -z "$PREV_TAG" ]; then
|
|
CHANGELOG=$(git log --pretty=format:"- %s (%h)" "$CURRENT_TAG")
|
|
else
|
|
CHANGELOG=$(git log --pretty=format:"- %s (%h)" "${PREV_TAG}..${CURRENT_TAG}")
|
|
fi
|
|
|
|
echo "$CHANGELOG" > /tmp/changelog.txt
|
|
echo "current_tag=$CURRENT_TAG" >> $GITHUB_OUTPUT
|
|
|
|
- name: Read app name from pyproject.toml
|
|
id: app-info
|
|
run: |
|
|
APP_NAME=$(python3 -c "
|
|
import re, pathlib
|
|
content = pathlib.Path('pyproject.toml').read_text()
|
|
m = re.search(r'^name\s*=\s*[\"\'](.*?)[\"\']', content, re.MULTILINE)
|
|
print(m.group(1) if m else 'app')
|
|
" 2>/dev/null || echo 'app')
|
|
echo "name=$APP_NAME" >> $GITHUB_OUTPUT
|
|
|
|
- name: Create release
|
|
env:
|
|
GITEA_TOKEN: ${{ gitea.token }}
|
|
SERVER_URL: ${{ gitea.server_url }}
|
|
REPOSITORY: ${{ gitea.repository }}
|
|
run: |
|
|
CURRENT_TAG=${{ steps.changelog.outputs.current_tag }}
|
|
APP_NAME=${{ steps.app-info.outputs.name }}
|
|
CHANGELOG=$(cat /tmp/changelog.txt)
|
|
|
|
curl -s -X POST \
|
|
-H "Content-Type: application/json" \
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
"$SERVER_URL/api/v1/repos/$REPOSITORY/releases" \
|
|
-d "{
|
|
\"tag_name\": \"$CURRENT_TAG\",
|
|
\"name\": \"$APP_NAME $CURRENT_TAG\",
|
|
\"body\": $(echo "$CHANGELOG" | jq -Rs .),
|
|
\"draft\": false,
|
|
\"prerelease\": false
|
|
}"
|