diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index e60d847..0ca1030 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -3,8 +3,9 @@ name: Release # Publishes a new version line: official build, then the release on Gitea and # on GitHub with the ISO attached. # -# Triggered when VERSION changes on Main (an intermediate commit that touches -# other files as well does not fire it), and manually from the Actions tab. +# Triggered when VERSION changes on Main (any push that touches VERSION fires +# it, even alongside other files: the path filter is an OR), and manually from +# the Actions tab. on: push: branches: [Main] @@ -57,6 +58,11 @@ jobs: env: FORCE: ${{ inputs.force }} run: | + # The version-line rule reads the released tags: a checkout without + # them (fetch-depth: 0 dropped) would see every VERSION as a new line + # and publish a patch release. + [ -n "$(git tag -l)" ] \ + || { echo "::error::aucun tag dans le checkout — fetch-depth: 0 est requis"; exit 1; } if [ "${FORCE}" = "true" ]; then ./release.sh --check --force else diff --git a/VERSION b/VERSION index 6f4eebd..ac39a10 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.8.1 +0.9.0 diff --git a/release.sh b/release.sh index a61c245..851961f 100755 --- a/release.sh +++ b/release.sh @@ -99,9 +99,11 @@ TAG="v$VERSION" # ─── Nouvelle ligne de version ? ───────────────────────────────────────────── # Previous released version = highest tag, normalized (repo history has both # "0.6.0" and "V0.8.1" spellings). +# sed, not grep: under `set -o pipefail` a tag list without a version would +# end the script here, before the "no tag" case below. PREV_VERSION="$(git -C "$WORK_DIR" tag -l \ - | grep -E '^[vV]?[0-9]+\.[0-9]+\.[0-9]+$' \ - | sed 's/^[vV]//' | sort -V | tail -1)" + | sed -n 's/^[vV]\{0,1\}\([0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\)$/\1/p' \ + | sort -V | tail -1)" if [ -z "$PREV_VERSION" ]; then MODE="release" @@ -174,11 +176,16 @@ GITEA_TOKEN="${GITEA_TOKEN:-$(token_from_notes '^[0-9a-f]{40}$')}" # GitHub classic and fine-grained tokens share no prefix, so both are tried. GITHUB_TOKEN="${GITHUB_TOKEN:-$(token_from_notes 'gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,}')}" -[ -n "$GITEA_TOKEN" ] \ - || die "Token Gitea absent : export GITEA_TOKEN=… ou ajoute-le à $TOKENS_FILE." -[ -n "$GITHUB_TOKEN" ] \ - || die "Token GitHub absent : export GITHUB_TOKEN=… ou ajoute-le à $TOKENS_FILE." -success "Tokens Gitea et GitHub chargés." +# A dry run touches neither forge, so it must stay usable without secrets. +if [ "$DRY_RUN" -eq 1 ]; then + info "[dry-run] jetons non requis." +else + [ -n "$GITEA_TOKEN" ] \ + || die "Token Gitea absent : export GITEA_TOKEN=… ou ajoute-le à $TOKENS_FILE." + [ -n "$GITHUB_TOKEN" ] \ + || die "Token GitHub absent : export GITHUB_TOKEN=… ou ajoute-le à $TOKENS_FILE." + success "Tokens Gitea et GitHub chargés." +fi # ─── Pré-vol des forges ────────────────────────────────────────────────────── # --retry-all-errors: an ISO upload can fail on a DNS hiccup halfway through,