Repository navigation
73 lines (64 loc) · 2.7 KB
/
Copy pathrelease.yml
File metadata and controls
73 lines (64 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Publication d'une version (release.yml standard de la team) : pousser sur main un
# tag vX.Y.Z égal à la version de pyproject.toml, après avoir daté sa section
# « ## [X.Y.Z] - AAAA-MM-JJ » dans CHANGELOG.md. La release GitHub reprend cette
# section comme notes et joint l'archive des sources du commit tagué.
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*"]
permissions:
contents: write
jobs:
release:
name: Publication
runs-on: ${{ fromJSON(vars.RUNS_ON_LINUX || '"ubuntu-latest"') }}
env:
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).
- name: Installation de uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
- name: Tag = version de pyproject.toml
run: |
version=$(uv run --no-project --python 3.12 python -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')
if [ "v${version}" != "${TAG}" ]; then
echo "::error::tag ${TAG} différent de la version de pyproject.toml (${version})"
exit 1
fi
echo "VERSION=${version}" >> "${GITHUB_ENV}"
- name: Tag porté par main
run: |
git fetch --no-tags origin main
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
- name: Notes tirées du CHANGELOG
run: |
awk -v titre="## [${VERSION}]" 'index($0, titre) == 1 { dedans = 1; next } dedans && /^## / { exit } dedans' CHANGELOG.md > notes.md
if ! grep -q '[^[:space:]]' notes.md; then
echo "::error::section « ## [${VERSION}] » absente ou vide dans CHANGELOG.md"
exit 1
fi
- name: Archive des sources
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