-
Notifications
You must be signed in to change notification settings - Fork 98
/
Copy pathupdate_version.sh
executable file
·49 lines (38 loc) · 1.18 KB
/
update_version.sh
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
#!/bin/bash
# Get current date components
YEAR=$(date +%Y)
MONTH=$(date +%m)
# Calculate major version based on year
# Starting from major version 4 in 2025
BASE_YEAR=2025
BASE_VERSION=4
CURRENT_YEAR=$YEAR
if [ "$CURRENT_YEAR" -lt "$BASE_YEAR" ]; then
# For years before 2025, use version 3
MAJOR_VERSION=3
else
# For 2025 and beyond, calculate the increasing version
YEAR_DIFF=$((CURRENT_YEAR - BASE_YEAR))
MAJOR_VERSION=$((BASE_VERSION + YEAR_DIFF))
fi
# Get Git commit count for current branch
COMMIT_COUNT=$(git rev-list --count HEAD 2>/dev/null || echo "0")
# Get current protocol version from existing file
PROTOCOL_VERSION=$(grep "PROTOCOL_VERESION" version.h | cut -d'"' -f2)
# Create version string
VERSION="${MAJOR_VERSION}.${MONTH}.${COMMIT_COUNT}"
# Create updated version.h file
cat > version.h << EOF
// filepath: /home/ubuntu/work/xfrpc/version.h
// SPDX-License-Identifier: GPL-3.0-only
/*
* Copyright (c) 2023 Dengfeng Liu <liudf0716@gmail.com>
*/
#ifndef XFRPC_VERSION_H
#define XFRPC_VERSION_H
#define VERSION "${VERSION}"
#define PROTOCOL_VERESION "${PROTOCOL_VERSION}"
#define CLIENT_V 1
#endif // XFRPC_VERSION_H
EOF
echo "Updated version to ${VERSION}"