This repository was archived by the owner on Jun 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpublish_hook.pl
executable file
·48 lines (38 loc) · 1.57 KB
/
publish_hook.pl
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
#! /usr/bin/perl
# Author: Fiorentino Salvatore
# In the commit of pull request just insert: update_package_[ major | minor | patch ]
$regex1 = 'Author:\s+(?<author_username>[\w\-]+)\s+.+\nDate:\s+(?<day>\w+)\s(?<mounth>\w+)\s(?<day_number>\w+)\s(?<hour>\d{2}):(?<minute>\d{2}):(?<second>\d{2})\s(?<year>\d{4}).+\n+(?<message>(.|\n)+?)\ndiff';
$regex2 = 'Author:\s+(?<author_username>[\w\-]+)\s+.+\nDate:\s+(?<day>\w+)\s(?<mounth>\w+)\s(?<day_number>\w+)\s(?<hour>\d{2}):(?<minute>\d{2}):(?<second>\d{2})\s(?<year>\d{4}).+\n+(?<message>(.|\n)+?)';
$regex_inner_message_update_version = 'update_package_((?<major>major)|(?<minor>minor)|(?<patch>patch))';
$regex_bump_commit = 'ci: version bump to \d+.\d+.\d+' ;
$sha = shift ;
$output_git_log = `git show $sha` ;
if($output_git_log =~ /$regex1/gm or $output_git_log =~ /$regex2/gm){
$author_username = $+{author_username};
$day = $+{day};
$mounth = $+{mounth};
$day_number = $+{day_number};
$hour = $+{hour};
$minute = $+{minute};
$second = $+{second};
$year = $+{year};
$message = $+{message};
if($message =~ /$regex_inner_message_update_version/gm){
if($+{major}){
print("version=major\n")
}elsif($+{minor}){
print("version=minor\n")
}else{
print("version=patch\n")
}
}elsif( $message =~ /$regex_bump_commit/gm ){
print("status=failed\n") ;
exit ;
}else{
# Default
print("version=patch\n")
}
print("status=success\n") ;
}else{
die "Message doesn't match regex message\n";
}