-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (73 loc) · 2.52 KB
/
Copy pathrelease.yml
File metadata and controls
89 lines (73 loc) · 2.52 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: 'Release workflow'
permissions:
contents: write
on:
pull_request:
types: [closed]
branches:
- main
jobs:
release:
if: >
github.event.pull_request.merged == true &&
github.event.pull_request.head.ref == 'dev'
runs-on: ubuntu-latest
steps:
- name: 'Checkout code'
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 'Configurer Git'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: 'Déterminer la nouvelle version'
id: semver
run: |
set -e
# Récupérer le dernier tag vX.Y.Z
LATEST_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1)
if [[ -z "$LATEST_TAG" ]]; then
VERSION="0.1.0"
else
VERSION="${LATEST_TAG#v}"
MAJOR=$(echo "$VERSION" | cut -d. -f1)
MINOR=$(echo "$VERSION" | cut -d. -f2)
PATCH=$(echo "$VERSION" | cut -d. -f3)
MINOR=$((MINOR + 1))
PATCH=0
VERSION="$MAJOR.$MINOR.$PATCH"
fi
TAG="v$VERSION"
echo "Nouvelle release : $TAG"
# Vérifier si le tag existe déjà
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "❌ Le tag $TAG existe déjà"
exit 1
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: 'Créer le tag'
run: |
git tag "${{ steps.semver.outputs.tag }}"
git push origin "${{ steps.semver.outputs.tag }}"
- name: 'Extraire le changelog'
id: changelog
run: |
VERSION="${{ steps.semver.outputs.version }}"
if [[ -f CHANGELOG.md ]]; then
# Extraire la section du changelog correspondant à cette version
sed -n "/## \[$VERSION\]/,/^## /p" CHANGELOG.md > release_notes.txt
else
echo "Release $VERSION" > release_notes.txt
fi
# Préparer la sortie pour GitHub Actions
echo "release_notes<<EOF" >> $GITHUB_OUTPUT
cat release_notes.txt >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: 'Créer la GitHub Release'
uses: ncipollo/release-action@v1
with:
tag: '${{ steps.semver.outputs.tag }}'
name: '${{ steps.semver.outputs.tag }}'
body: '${{ steps.changelog.outputs.release_notes }}'