feat/release-page #1
1 changed files with 34 additions and 29 deletions
drop github.* context, switch to forgejo.* + FORGEJO_TOKEN env var
The github context was kept for compatibility in yavsc's
.forgejo/workflows/release.yml, but we don't need that here — the
forgejo context is canonical and we want zero GitHub-flavoured
naming in this script.
- All ${{ github.* }} -> ${{ forgejo.* }}
- Env vars GITHUB_API_URL / GITHUB_REPOSITORY / GITHUB_TOKEN
-> FORGEJO_API_URL / FORGEJO_REPOSITORY / FORGEJO_TOKEN
- The token's source (${{ secrets.GITHUB_TOKEN }}) is the one
exception: that's the runtime variable name exposed by the
upstream Action runner, not a naming choice. A comment in the
env block explains why we read it under the legacy name and
immediately re-bind it to FORGEJO_TOKEN.
- Same for $GITHUB_ENV (inter-step env file): runtime-controlled
name, kept under its technical identity with a note.
YAML re-validated with yaml.safe_load.
commit
10f37ac004
|
|
@ -10,15 +10,11 @@
|
||||||
# then publishes a Forgejo release via the REST API and uploads both
|
# then publishes a Forgejo release via the REST API and uploads both
|
||||||
# .deb files as assets.
|
# .deb files as assets.
|
||||||
#
|
#
|
||||||
# Authentication uses ${{ secrets.GITHUB_TOKEN }} (auto-provided by
|
# Authentication: the runner exposes an auto-provided token in the
|
||||||
# the Forgejo runner, scoped to contents: write for the current
|
# secrets context under the name GITHUB_TOKEN (a holdover name from
|
||||||
# repo). A dedicated PAT (${{ secrets.RELEASE_TOKEN }}) was the
|
# the upstream Action runner codebase, NOT a reference to github.com).
|
||||||
# preferred option for least-privilege, but creating repo-level
|
# We store it in the env var FORGEJO_TOKEN to keep the rest of this
|
||||||
# secrets is currently broken on this Forgejo instance
|
# script free of any GitHub-flavoured naming.
|
||||||
# (InsertEncryptedSecret fails with a UTF-8 byte-sequence error,
|
|
||||||
# probably a text-vs-bytea column type on the secret table). Bumping
|
|
||||||
# to Forgejo v16 should fix it; until then, the runner-provided
|
|
||||||
# token keeps the workflow operational.
|
|
||||||
#
|
#
|
||||||
# Why bash + jq + curl, no third-party actions: the runner's docker
|
# Why bash + jq + curl, no third-party actions: the runner's docker
|
||||||
# label points at pazof/yavsc-build-env, a Debian image with jq but
|
# label points at pazof/yavsc-build-env, a Debian image with jq but
|
||||||
|
|
@ -78,7 +74,7 @@ jobs:
|
||||||
|
|
||||||
- name: Clone du repo au tag demandé
|
- name: Clone du repo au tag demandé
|
||||||
env:
|
env:
|
||||||
TAG: ${{ github.event_name == 'push' && github.ref_name || inputs.tag }}
|
TAG: ${{ forgejo.event_name == 'push' && forgejo.ref_name || inputs.tag }}
|
||||||
run: |
|
run: |
|
||||||
if [[ -z "$TAG" ]]; then
|
if [[ -z "$TAG" ]]; then
|
||||||
echo "::error::No tag provided. In workflow_dispatch, set the 'tag' input."
|
echo "::error::No tag provided. In workflow_dispatch, set the 'tag' input."
|
||||||
|
|
@ -173,7 +169,11 @@ jobs:
|
||||||
|
|
||||||
echo "Section CHANGELOG validée pour [$TAG] - $CHANNEL"
|
echo "Section CHANGELOG validée pour [$TAG] - $CHANNEL"
|
||||||
|
|
||||||
# Expose channel + body pour les étapes suivantes via $GITHUB_ENV.
|
# Expose channel + body pour les étapes suivantes via
|
||||||
|
# le fichier d'environnement inter-steps fourni par le
|
||||||
|
# runner (le nom technique de la variable runtime est
|
||||||
|
# GITHUB_ENV, on ne le contrôle pas — c'est un héritage
|
||||||
|
# du runner Action upstream).
|
||||||
echo "RELEASE_CHANNEL=$CHANNEL" >> "$GITHUB_ENV"
|
echo "RELEASE_CHANNEL=$CHANNEL" >> "$GITHUB_ENV"
|
||||||
echo "RELEASE_BODY<<EOF" >> "$GITHUB_ENV"
|
echo "RELEASE_BODY<<EOF" >> "$GITHUB_ENV"
|
||||||
echo "$RELEASE_BODY" >> "$GITHUB_ENV"
|
echo "$RELEASE_BODY" >> "$GITHUB_ENV"
|
||||||
|
|
@ -182,7 +182,7 @@ jobs:
|
||||||
|
|
||||||
- name: Build .deb amd64
|
- name: Build .deb amd64
|
||||||
env:
|
env:
|
||||||
POSTIT_GIT_TAG: ${{ github.event_name == 'push' && github.ref_name || inputs.tag }}
|
POSTIT_GIT_TAG: ${{ forgejo.event_name == 'push' && forgejo.ref_name || inputs.tag }}
|
||||||
POSTIT_RUNTIME: linux-x64
|
POSTIT_RUNTIME: linux-x64
|
||||||
run: |
|
run: |
|
||||||
cd /src/_src
|
cd /src/_src
|
||||||
|
|
@ -191,7 +191,7 @@ jobs:
|
||||||
|
|
||||||
- name: Build .deb arm64
|
- name: Build .deb arm64
|
||||||
env:
|
env:
|
||||||
POSTIT_GIT_TAG: ${{ github.event_name == 'push' && github.ref_name || inputs.tag }}
|
POSTIT_GIT_TAG: ${{ forgejo.event_name == 'push' && forgejo.ref_name || inputs.tag }}
|
||||||
POSTIT_RUNTIME: linux-arm64
|
POSTIT_RUNTIME: linux-arm64
|
||||||
run: |
|
run: |
|
||||||
cd /src/_src
|
cd /src/_src
|
||||||
|
|
@ -202,7 +202,7 @@ jobs:
|
||||||
|
|
||||||
- name: Localiser les .deb produits
|
- name: Localiser les .deb produits
|
||||||
env:
|
env:
|
||||||
LOOKUP_TAG: ${{ github.event_name == 'push' && github.ref_name || inputs.tag }}
|
LOOKUP_TAG: ${{ forgejo.event_name == 'push' && forgejo.ref_name || inputs.tag }}
|
||||||
run: |
|
run: |
|
||||||
cd /src
|
cd /src
|
||||||
DEB_AMD64=$(find . -maxdepth 3 -name "postit_*${LOOKUP_TAG}-1_amd64.deb" \
|
DEB_AMD64=$(find . -maxdepth 3 -name "postit_*${LOOKUP_TAG}-1_amd64.deb" \
|
||||||
|
|
@ -220,10 +220,15 @@ jobs:
|
||||||
|
|
||||||
- name: Publier la release Forgejo via l'API REST
|
- name: Publier la release Forgejo via l'API REST
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
# Le runner expose un token auto-fourni dans le contexte
|
||||||
GITHUB_API_URL: ${{ github.api_url }}
|
# `secrets` sous le nom GITHUB_TOKEN (héritage du runtime
|
||||||
GITHUB_REPOSITORY: ${{ github.repository }}
|
# Action upstream — on ne peut pas le renommer). On le
|
||||||
TAG: ${{ github.event_name == 'push' && github.ref_name || inputs.tag }}
|
# stocke dans FORGEJO_TOKEN pour le reste du script, et
|
||||||
|
# on évite ainsi toute référence "github" dans nos noms.
|
||||||
|
FORGEJO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
FORGEJO_API_URL: ${{ forgejo.api_url }}
|
||||||
|
FORGEJO_REPOSITORY: ${{ forgejo.repository }}
|
||||||
|
TAG: ${{ forgejo.event_name == 'push' && forgejo.ref_name || inputs.tag }}
|
||||||
# RELEASE_BODY peut contenir des retours à la ligne et
|
# RELEASE_BODY peut contenir des retours à la ligne et
|
||||||
# des caractères YAML-réservés (':', '#', etc.) issus du
|
# des caractères YAML-réservés (':', '#', etc.) issus du
|
||||||
# CHANGELOG.md. On le quote en YAML double-quoted string
|
# CHANGELOG.md. On le quote en YAML double-quoted string
|
||||||
|
|
@ -238,11 +243,11 @@ jobs:
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Le runner Forgejo expose l'API sur github.api_url (par
|
# Le runner Forgejo expose l'API sur forgejo.api_url (par
|
||||||
# défaut http://…/api/v1). On retire le suffixe /api/v1
|
# défaut http://…/api/v1). On retire le suffixe /api/v1
|
||||||
# s'il est présent pour dériver la base du serveur, puis
|
# s'il est présent pour dériver la base du serveur, puis
|
||||||
# on reconstruit l'URL de l'API proprement.
|
# on reconstruit l'URL de l'API proprement.
|
||||||
API_BASE="${GITHUB_API_URL%/}"
|
API_BASE="${FORGEJO_API_URL%/}"
|
||||||
API_BASE="${API_BASE%/api/v1}"
|
API_BASE="${API_BASE%/api/v1}"
|
||||||
|
|
||||||
# 1. Vérifier si la release existe déjà pour ce tag.
|
# 1. Vérifier si la release existe déjà pour ce tag.
|
||||||
|
|
@ -251,9 +256,9 @@ jobs:
|
||||||
# tête de fichier.
|
# tête de fichier.
|
||||||
echo "::group::Check existing release for tag $TAG"
|
echo "::group::Check existing release for tag $TAG"
|
||||||
HTTP=$(curl -sS -o /tmp/existing.json -w '%{http_code}' \
|
HTTP=$(curl -sS -o /tmp/existing.json -w '%{http_code}' \
|
||||||
-H "Authorization: token $GITHUB_TOKEN" \
|
-H "Authorization: token $FORGEJO_TOKEN" \
|
||||||
-H "Accept: application/json" \
|
-H "Accept: application/json" \
|
||||||
"$API_BASE/api/v1/repos/$GITHUB_REPOSITORY/releases/tags/$TAG")
|
"$API_BASE/api/v1/repos/$FORGEJO_REPOSITORY/releases/tags/$TAG")
|
||||||
echo "GET releases/tags/$TAG -> HTTP $HTTP"
|
echo "GET releases/tags/$TAG -> HTTP $HTTP"
|
||||||
EXISTING_ID=""
|
EXISTING_ID=""
|
||||||
if [[ "$HTTP" == "200" ]]; then
|
if [[ "$HTTP" == "200" ]]; then
|
||||||
|
|
@ -272,11 +277,11 @@ jobs:
|
||||||
> /tmp/patch.json
|
> /tmp/patch.json
|
||||||
HTTP=$(curl -sS -o /tmp/release.json -w '%{http_code}' \
|
HTTP=$(curl -sS -o /tmp/release.json -w '%{http_code}' \
|
||||||
-X PATCH \
|
-X PATCH \
|
||||||
-H "Authorization: token $GITHUB_TOKEN" \
|
-H "Authorization: token $FORGEJO_TOKEN" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-H "Accept: application/json" \
|
-H "Accept: application/json" \
|
||||||
--data-binary @/tmp/patch.json \
|
--data-binary @/tmp/patch.json \
|
||||||
"$API_BASE/api/v1/repos/$GITHUB_REPOSITORY/releases/$EXISTING_ID")
|
"$API_BASE/api/v1/repos/$FORGEJO_REPOSITORY/releases/$EXISTING_ID")
|
||||||
echo "PATCH release -> HTTP $HTTP"
|
echo "PATCH release -> HTTP $HTTP"
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
else
|
else
|
||||||
|
|
@ -290,11 +295,11 @@ jobs:
|
||||||
> /tmp/post.json
|
> /tmp/post.json
|
||||||
HTTP=$(curl -sS -o /tmp/release.json -w '%{http_code}' \
|
HTTP=$(curl -sS -o /tmp/release.json -w '%{http_code}' \
|
||||||
-X POST \
|
-X POST \
|
||||||
-H "Authorization: token $GITHUB_TOKEN" \
|
-H "Authorization: token $FORGEJO_TOKEN" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-H "Accept: application/json" \
|
-H "Accept: application/json" \
|
||||||
--data-binary @/tmp/post.json \
|
--data-binary @/tmp/post.json \
|
||||||
"$API_BASE/api/v1/repos/$GITHUB_REPOSITORY/releases")
|
"$API_BASE/api/v1/repos/$FORGEJO_REPOSITORY/releases")
|
||||||
echo "POST release -> HTTP $HTTP"
|
echo "POST release -> HTTP $HTTP"
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
fi
|
fi
|
||||||
|
|
@ -317,11 +322,11 @@ jobs:
|
||||||
echo "::group::Upload asset for arch=$arch: $deb"
|
echo "::group::Upload asset for arch=$arch: $deb"
|
||||||
HTTP=$(curl -sS -o /tmp/asset.json -w '%{http_code}' \
|
HTTP=$(curl -sS -o /tmp/asset.json -w '%{http_code}' \
|
||||||
-X POST \
|
-X POST \
|
||||||
-H "Authorization: token $GITHUB_TOKEN" \
|
-H "Authorization: token $FORGEJO_TOKEN" \
|
||||||
-H "Content-Type: application/octet-stream" \
|
-H "Content-Type: application/octet-stream" \
|
||||||
-H "Accept: application/json" \
|
-H "Accept: application/json" \
|
||||||
--data-binary "@$deb" \
|
--data-binary "@$deb" \
|
||||||
"$API_BASE/api/v1/repos/$GITHUB_REPOSITORY/releases/$RELEASE_ID/assets?name=$(basename "$deb")")
|
"$API_BASE/api/v1/repos/$FORGEJO_REPOSITORY/releases/$RELEASE_ID/assets?name=$(basename "$deb")")
|
||||||
echo "POST asset ($arch) -> HTTP $HTTP"
|
echo "POST asset ($arch) -> HTTP $HTTP"
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
|
||||||
|
|
@ -332,4 +337,4 @@ jobs:
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Release publiée : $API_BASE/$GITHUB_REPOSITORY/releases/tag/$TAG"
|
echo "Release publiée : $API_BASE/$FORGEJO_REPOSITORY/releases/tag/$TAG"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue