- timeout-minutes sul job di tutti e 16 i workflow riusabili: 10 per branch-cleanup, 15-20 per release e manutenzione, 30 per i quality gates e le pubblicazioni, 45 per le immagini Docker, 60 per la build Android - timeout-minutes su 95 passi che dipendono dalla rete (checkout, setup-*, cache, install, audit, login, push, upload): con il solo timeout sul job il log non dice quale passo si è impiantato, con questi sì - valori letterali e non input: su un job che chiama un workflow riusabile timeout-minutes non è una chiave ammessa, quindi il limite può stare solo qui, e i valori scelti sono già ampi rispetto alla durata reale dei job Fixes #23 @1h30m
76 lines
2.5 KiB
YAML
76 lines
2.5 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
|
|
# Il chiamante non puo' dichiararlo: su un job che usa un workflow
|
|
# riusabile timeout-minutes non e' una chiave ammessa (devops/shared-actions#23).
|
|
timeout-minutes: 15
|
|
defaults:
|
|
run:
|
|
working-directory: ${{ inputs.working-directory }}
|
|
steps:
|
|
- name: Checkout
|
|
timeout-minutes: 10
|
|
uses: https://gitea.pzetatouch.it/actions/checkout@v7
|
|
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
|
|
timeout-minutes: 5
|
|
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
|
|
}"
|