ci: enhance release workflow to resolve and validate release tags dynamically

This commit is contained in:
2026-05-02 23:20:00 +02:00
parent 62e066c754
commit 13787d1af9
+22 -8
View File
@@ -159,6 +159,24 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v6
- name: Resolve release tag
id: tag
shell: bash
run: |
tag="${{ github.ref_name }}"
if [ -z "$tag" ] || [ "$tag" = "main" ]; then
tag="${{ inputs.tag }}"
fi
if [ -z "$tag" ]; then
echo "Tag non disponibile. Imposta l'input 'tag' (es. v2.2.1)." >&2
exit 1
fi
case "$tag" in
v*) ;;
*) tag="v$tag" ;;
esac
echo "tag=$tag" >> "$GITHUB_OUTPUT"
- name: Download artifacts - name: Download artifacts
uses: actions/download-artifact@v8 uses: actions/download-artifact@v8
with: with:
@@ -167,10 +185,7 @@ jobs:
- name: Extract changelog section - name: Extract changelog section
run: | run: |
tag="${{ github.ref_name }}" tag="${{ steps.tag.outputs.tag }}"
if [ -z "$tag" ] || [ "$tag" = "main" ]; then
tag="${{ inputs.tag }}"
fi
version="${tag#v}" version="${tag#v}"
awk -v ver="[$version]" ' awk -v ver="[$version]" '
/^## / && index($0, ver) { found=1; next } /^## / && index($0, ver) { found=1; next }
@@ -191,6 +206,8 @@ jobs:
- name: Create GitHub Release - name: Create GitHub Release
uses: softprops/action-gh-release@v3 uses: softprops/action-gh-release@v3
with: with:
tag_name: ${{ steps.tag.outputs.tag }}
name: ${{ steps.tag.outputs.tag }}
files: | files: |
artifacts/*.zip artifacts/*.zip
artifacts/**/*.dll artifacts/**/*.dll
@@ -200,8 +217,7 @@ jobs:
- name: Update Gitea Release body - name: Update Gitea Release body
env: env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
INPUT_TAG: ${{ inputs.tag }} GITEA_TAG: ${{ steps.tag.outputs.tag }}
GITEA_TAG: ${{ github.ref_name }}
run: | run: |
python3 - <<'PY' python3 - <<'PY'
import json import json
@@ -212,8 +228,6 @@ jobs:
base = "https://gitea.emulab.it/api/v1" base = "https://gitea.emulab.it/api/v1"
repo = "Simone/nsis-plugin-ns7zip" repo = "Simone/nsis-plugin-ns7zip"
tag = os.environ.get("GITEA_TAG", "").strip() tag = os.environ.get("GITEA_TAG", "").strip()
if not tag or tag == "main":
tag = os.environ.get("INPUT_TAG", "").strip()
token = os.environ.get("GITEA_TOKEN", "").strip() token = os.environ.get("GITEA_TOKEN", "").strip()
if not tag: if not tag: