dae2a74437
- quality-gates, dependency-check, dependency-outdated, npm-publish e auto-release accettano ora working-directory (default "."), applicato via defaults.run a livello di job: copre tutti gli step run senza toccare gli step uses, che devono restare sulla root - Allineate le varianti -github dei cinque workflow - Sblocca i repo dove package.json non e' in root (pzeta-calendar in typescript/, pzeta-king in server/), che finora dovevano rinunciare ai template e reinlineare i job, perdendo la working-directory a ogni riallineamento - Retrocompatibile: con l'input omesso il comportamento resta identico refs #4
60 lines
1.8 KiB
YAML
60 lines
1.8 KiB
YAML
name: Auto Release
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
working-directory:
|
|
description: 'Cartella che contiene package.json, relativa alla root del repo. Default: la root.'
|
|
type: string
|
|
default: '.'
|
|
|
|
jobs:
|
|
auto-release:
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: ${{ inputs.working-directory || '.' }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: https://gitea.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: 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=$(jq -r '.name' package.json)
|
|
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
|
|
}"
|