-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (66 loc) · 2.43 KB
/
release.yml
File metadata and controls
75 lines (66 loc) · 2.43 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
name: Create Release
on:
push:
branches:
- master
# 1. FIX ACCESSO: Concede i permessi di scrittura per creare la release
permissions:
contents: write
jobs:
check_commit:
runs-on: ubuntu-latest
outputs:
is_release: ${{ steps.check.outputs.is_release }}
steps:
- name: Checkout code
uses: actions/checkout@v4 # Aggiornato alla v4
with:
fetch-depth: 2
- name: Check commit message
id: check
run: |
message=$(git log --format=%B -n 1 ${{ github.sha }})
echo "Commit message: $message"
if [[ $message == "updated version"* ]]; then
echo "is_release=true" >> $GITHUB_OUTPUT
echo "Commit message starts with 'updated version'"
else
echo "is_release=false" >> $GITHUB_OUTPUT
echo "Commit message does not start with 'updated version'"
fi
release:
needs: check_commit
if: needs.check_commit.outputs.is_release == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4 # Aggiornato alla v4
with:
fetch-depth: 0
- name: Get commit message
run: |
COMMIT_MESSAGE=$(git log --format=%B -n 1 ${{ github.sha }})
echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" >> $GITHUB_ENV
echo "Commit message: $COMMIT_MESSAGE"
- name: Get version
run: |
VERSION=$(echo $COMMIT_MESSAGE | awk 'BEGIN{FS=" "} {print $NF}')
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Version: $VERSION"
- name: Get release description
run: |
# 2. FIX CRASH: Aggiunto "|| true" alla fine per evitare l'exit code 1 se non ci sono altri commit
DESCRIPTION=$(git log ${{ github.event.before }}..${{ github.sha }} --pretty=format:'- %s' | grep -v "updated version" || true)
echo "DESCRIPTION<<EOF" >> $GITHUB_ENV
echo "$DESCRIPTION" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "Release description: $DESCRIPTION"
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2 # Nuova action ufficiale aggiornata
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Usa il token automatico di GitHub, non serve il tuo PAT
with:
tag_name: ${{ env.VERSION }}
name: Release ${{ env.VERSION }}
body: ${{ env.DESCRIPTION }}