Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
- name: Checkout du dépôt
uses: actions/checkout@v7

- name: Garde-fous de publication sur tag
run: python3 tests/test_workflow_release.py

- name: Dépendances système (FreeRDP 3)
# Le shim cffi (_shim.c) est compilé à l'installation du package
# (setup.py → build_ffi.py → pkg-config freerdp3/freerdp-client3/
Expand Down
17 changes: 13 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
name: Release

"on":
workflow_dispatch:
inputs:
tag:
description: Tag vX.Y.Z déjà validé et livré dans main
required: true
type: string
push:
tags: ["v*"]

Expand All @@ -14,14 +20,15 @@ permissions:
jobs:
release:
name: Publication
runs-on: ${{ fromJSON(vars.RUNS_ON_LINUX || '{"group":"maison","labels":["self-hosted","linux"]}') }}
runs-on: ${{ fromJSON(vars.RUNS_ON_LINUX || '"ubuntu-latest"') }}
env:
TAG: ${{ github.ref_name }}
TAG: ${{ inputs.tag || github.ref_name }}
DEPOT: ${{ github.event.repository.name }}
steps:
- name: Checkout du dépôt
uses: actions/checkout@v7
with:
ref: refs/tags/${{ env.TAG }}
fetch-depth: 0

# python3 du runner maison trop ancien pour tomllib (Python ≥ 3.11).
Expand All @@ -40,7 +47,7 @@ jobs:
- name: Tag porté par main
run: |
git fetch --no-tags origin main
if ! git merge-base --is-ancestor "${GITHUB_SHA}" FETCH_HEAD; then
if ! git merge-base --is-ancestor "refs/tags/${TAG}^{commit}" FETCH_HEAD; then
echo "::error::le commit tagué ${TAG} n'est pas sur main (passer par le relais dev → main)"
exit 1
fi
Expand All @@ -54,11 +61,13 @@ jobs:
fi

- name: Archive des sources
run: git archive --format=tar.gz --prefix="${DEPOT}-${VERSION}/" -o "${DEPOT}-${VERSION}.tar.gz" "${GITHUB_SHA}"
run: git archive --format=tar.gz --prefix="${DEPOT}-${VERSION}/" -o "${DEPOT}-${VERSION}.tar.gz" "refs/tags/${TAG}^{commit}"

- name: Release GitHub
uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3
with:
tag_name: ${{ env.TAG }}
draft: false
body_path: notes.md
files: ${{ github.event.repository.name }}-*.tar.gz
fail_on_unmatched_files: true
21 changes: 21 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# yamllint : règles du socle Mathilde-Team
extends: default
rules:
line-length: disable # lambdas C++ et templates Jinja sur une ligne
document-start: disable
truthy:
check-keys: false # clé « on: » des workflows
allowed-values: ['true', 'false', 'yes', 'no'] # ESPHome accepte yes/no (restore_value: yes)
comments:
min-spaces-from-content: 1
comments-indentation: disable
indentation:
spaces: 2
indent-sequences: whatever
braces:
max-spaces-inside: 1
brackets:
max-spaces-inside: 1
ignore: |
.venv/
node_modules/
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Format : [Keep a Changelog](https://keepachangelog.com/fr/1.1.0/). Les numéros

## [Non publié]

- CI et publication : repli GitHub autorisé, publication manuelle sur un tag
déjà livré dans main, vérification d’ascendance et archives du tag exact.


### Modifié
- Licence passée de MIT à GPL-3.0-or-later : texte officiel dans `LICENSE`, `license = "GPL-3.0-or-later"` (PEP 639, setuptools ≥ 77) et URLs du dépôt dans `pyproject.toml`, en-têtes SPDX dans les sources, section Licence du README (#68).

Expand Down
57 changes: 57 additions & 0 deletions tests/test_workflow_release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# SPDX-License-Identifier: GPL-3.0-or-later
"""Garde-fous hors réseau de la publication du tag exact depuis GitHub."""

import json
import unittest
from pathlib import Path


class PublicationSurTag(unittest.TestCase):
def setUp(self):
self.workflows = Path(__file__).resolve().parents[1] / ".github" / "workflows"

def test_tag_explicite_et_ascendance_main(self):
texte = (self.workflows / "release.yml").read_text(encoding="utf-8")
self.assertIn(" workflow_dispatch:", texte)
self.assertIn(" TAG: ${{ inputs.tag || github.ref_name }}", texte)
self.assertIn(" ref: refs/tags/${{ env.TAG }}", texte)
self.assertIn(" fetch-depth: 0", texte)
self.assertIn("merge-base --is-ancestor", texte)
self.assertIn("refs/tags/${TAG}^{commit}", texte)
self.assertNotIn("${GITHUB_REF_NAME}", texte)
self.assertNotIn("${GITHUB_SHA}", texte)
self.assertIn(" draft: false", texte)
self.assertIn(" tag_name: ${{ env.TAG }}", texte)
self.assertIn(" fail_on_unmatched_files: true", texte)

def test_repli_github_et_garde_main_conserves(self):
for nom in ("ci.yml", "guard-main.yml", "release.yml"):
texte = (self.workflows / nom).read_text(encoding="utf-8")
repli = "fromJSON(vars.RUNS_ON_LINUX || '\"ubuntu-latest\"')"
direct = any(
ligne.strip()
in (
"runs-on: ubuntu-latest",
"runs-on: ubuntu-24.04",
"runs-on: ubuntu-26.04",
)
for ligne in texte.splitlines()
)
self.assertTrue(repli in texte or direct)
garde = (self.workflows / "guard-main.yml").read_text(encoding="utf-8")
self.assertIn("Garde : PR vers main doit venir de dev", garde)
self.assertIn('!= "dev"', garde)
ci = (self.workflows / "ci.yml").read_text(encoding="utf-8")
regle = json.loads((self.workflows.parent / "branch-protection" / "dev.json").read_text(encoding="utf-8"))[
"required_status_checks"
]
contextes = [check["context"] for check in regle.get("checks", [])]
contextes.extend(regle.get("contexts", []))
self.assertTrue(contextes)
for contexte in contextes:
self.assertIn(contexte, ci + "\n" + garde)
self.assertIn("run: python3 tests/test_workflow_release.py", ci)


if __name__ == "__main__":
unittest.main()
Loading