-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathversion.sh
184 lines (165 loc) · 7.18 KB
/
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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/bin/bash
# PKGBUILD
# README.md links
# workflows on top in env
# manpage.md
# .csproj files
# bookmark-dlp.pupnet.conf
# bookmark-dlp.spec
# package.nix
#TODO: nix version update fix
#TODO: add innosetup support
# Check if the correct number of arguments is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <new_version>"
exit 1
fi
NEW_VERSION=$1
PKGBUILD_FILE=./packaging/PKGBUILD
README_FILE=./README.md
NUGET_YML_FILE=./.github/workflows/nuget.yml
PRERELEASE_YML_FILE=./.github/workflows/prerelease.yml
DOXYGEN_YML_FILE=./.github/workflows/doxygen.yml
PRERELEASE_GITEA_YML_FILE=./.github/workflows/prerelease_gitea.yml
MANPAGE_FILE=./bookmark-dlp.manpage.md
NEW_DATE=$(date +'%Y. %m. %d')
NFBOOKMARK_CSPROJ_FILE=./Nfbookmark/Nfbookmark.csproj
BOOKMARK_DLP_CSPROJ_FILE=./bookmark-dlp/bookmark-dlp.csproj
PUPNET_CONF_FILE=./bookmark-dlp.pupnet.conf
SPEC_FILE1=./packaging/bookmark-dlp_for_official.spec
SPEC_FILE2=./packaging/bookmark-dlp_for_copr.spec
NIX_FILE=./packaging/package.nix
PKGBUILD_SUM_UPDATER=./PKGBUILD_sum_update.sh
# Validate the PKGBUILD file exists
if [ ! -f "$PKGBUILD_FILE" ]; then
echo "Error: File '$PKGBUILD_FILE' not found."
exit 1
fi
# Replace version numbers (_tag, pkgver) in the PKGBUILD file
sed -i -E \
-e "s/^_tag=[0-9]+\.[0-9]+\.[0-9]+/_tag=${NEW_VERSION}/" \
-e "s/^pkgver=[0-9]+\.[0-9]+\.[0-9]+/pkgver=${NEW_VERSION}/" \
"$PKGBUILD_FILE"
echo "Version updated to $NEW_VERSION in $PKGBUILD_FILE."
# Validate the README.md file exists
if [ ! -f "$README_FILE" ]; then
echo "Error: File '$README_FILE' not found."
exit 1
fi
# Replace all occurrences of the version in the file
sed -i -E "s/bookmark-dlp-[0-9]+\.[0-9]+\.[0-9]+/bookmark-dlp-${NEW_VERSION}/g" "$README_FILE"
# Also replace occurrences like "bookmark-dlp_0.4.0" (underscores in certain links)
sed -i -E "s/bookmark-dlp_[0-9]+\.[0-9]+\.[0-9]+/bookmark-dlp_${NEW_VERSION}/g" "$README_FILE"
sed -i -E "s/bookmark-dlp-win-x86-[0-9]+\.[0-9]+\.[0-9]+/bookmark-dlp-win-x86-${NEW_VERSION}/g" "$README_FILE"
sed -i -E "s/bookmark-dlp-win-arm64-[0-9]+\.[0-9]+\.[0-9]+/bookmark-dlp-win-arm64-${NEW_VERSION}/g" "$README_FILE"
sed -i -E "s/bookmark-dlp-linux-x64-[0-9]+\.[0-9]+\.[0-9]+/bookmark-dlp-linux-x64-${NEW_VERSION}/g" "$README_FILE"
sed -i -E "s/bookmark-dlp-linux-arm64-[0-9]+\.[0-9]+\.[0-9]+/bookmark-dlp-linux-arm64-${NEW_VERSION}/g" "$README_FILE"
sed -i -E "s/bookmark-dlp-osx-x64-[0-9]+\.[0-9]+\.[0-9]+/bookmark-dlp-osx-x64-${NEW_VERSION}/g" "$README_FILE"
sed -i -E "s/bookmark-dlp-osx-arm64-[0-9]+\.[0-9]+\.[0-9]+/bookmark-dlp-osx-arm64-${NEW_VERSION}/g" "$README_FILE"
echo "Version updated to $NEW_VERSION in $README_FILE."
# Validate the nuget.yml file exists
if [ ! -f "$NUGET_YML_FILE" ]; then
echo "Error: File '$NUGET_YML_FILE' not found."
exit 1
fi
# Replace the version in the VERSION environment variable
sed -i -E "s/^ VERSION: \"[0-9]+\.[0-9]+\.[0-9]+\"/ VERSION: \"${NEW_VERSION}\"/" "$NUGET_YML_FILE"
echo "VERSION updated to $NEW_VERSION in $NUGET_YML_FILE."
# Validate the doxygen.yml file exists
if [ ! -f "$DOXYGEN_YML_FILE" ]; then
echo "Error: File '$DOXYGEN_YML_FILE' not found."
exit 1
fi
# Replace the version in the VERSION environment variable
sed -i -E "s/^ VERSION: \"[0-9]+\.[0-9]+\.[0-9]+\"/ VERSION: \"${NEW_VERSION}\"/" "$DOXYGEN_YML_FILE"
echo "VERSION updated to $NEW_VERSION in $DOXYGEN_YML_FILE."
# Validate the prerelease.yml file exists
if [ ! -f "$PRERELEASE_YML_FILE" ]; then
echo "Error: File '$PRERELEASE_YML_FILE' not found."
exit 1
fi
# Replace the version in the VERSION environment variable
sed -i -E "s/^ VERSION: \"[0-9]+\.[0-9]+\.[0-9]+\"/ VERSION: \"${NEW_VERSION}\"/" "$PRERELEASE_YML_FILE"
echo "VERSION updated to $NEW_VERSION in $PRERELEASE_YML_FILE."
# Validate the prerelease_gitea.yml file exists
if [ ! -f "$PRERELEASE_GITEA_YML_FILE" ]; then
echo "Error: File '$PRERELEASE_GITEA_YML_FILE' not found."
exit 1
fi
# Replace the version in the VERSION environment variable
sed -i -E "s/^ VERSION: \"[0-9]+\.[0-9]+\.[0-9]+\"/ VERSION: \"${NEW_VERSION}\"/" "$PRERELEASE_GITEA_YML_FILE"
echo "VERSION updated to $NEW_VERSION in $PRERELEASE_GITEA_YML_FILE."
# Validate the manpage.md file exists
if [ ! -f "$MANPAGE_FILE" ]; then
echo "Error: File '$MANPAGE_FILE' not found."
exit 1
fi
# Replace the version number in the header
sed -i -E "s/^% bookmark-dlp\(1\) v[0-9]+\.[0-9]+\.[0-9]+/% bookmark-dlp(1) v${NEW_VERSION}/" "$MANPAGE_FILE"
# Replace the date below the header
sed -i -E "s/^[0-9]{4}\. [0-9]{2}\. [0-9]{2}/${NEW_DATE}/" "$MANPAGE_FILE"
echo "Version updated to $NEW_VERSION and date updated to $NEW_DATE in $MANPAGE_FILE."
# Validate the Nfbookmark csproj file exists
if [ ! -f "$NFBOOKMARK_CSPROJ_FILE" ]; then
echo "Error: File '$NFBOOKMARK_CSPROJ_FILE' not found."
exit 1
fi
# Replace the version inside the <Version> tag
sed -i -E "s|<Version>[0-9]+\.[0-9]+\.[0-9]+</Version>|<Version>${NEW_VERSION}</Version>|" "$NFBOOKMARK_CSPROJ_FILE"
echo "Version updated to $NEW_VERSION in $NFBOOKMARK_CSPROJ_FILE."
# Validate the bookmark-dlp csproj file exists
if [ ! -f "$BOOKMARK_DLP_CSPROJ_FILE" ]; then
echo "Error: File '$BOOKMARK_DLP_CSPROJ_FILE' not found."
exit 1
fi
# Replace the version inside the <Version> tag
sed -i -E "s|<Version>[0-9]+\.[0-9]+\.[0-9]+</Version>|<Version>${NEW_VERSION}</Version>|" "$BOOKMARK_DLP_CSPROJ_FILE"
echo "Version updated to $NEW_VERSION in $BOOKMARK_DLP_CSPROJ_FILE."
# Validate the PupNet configuration file exists
if [ ! -f "$PUPNET_CONF_FILE" ]; then
echo "Error: File '$PUPNET_CONF_FILE' not found."
exit 1
fi
# Replace the AppVersionRelease value
sed -i -E "s/^AppVersionRelease = [0-9]+\.[0-9]+\.[0-9]+/AppVersionRelease = ${NEW_VERSION}/" "$PUPNET_CONF_FILE"
echo "AppVersionRelease updated to $NEW_VERSION in $PUPNET_CONF_FILE."
# Validate the official spec file exists
if [ ! -f "$SPEC_FILE1" ]; then
echo "Error: File '$SPEC_FILE1' not found."
exit 1
fi
# Replace the Version value
sed -i -E "s/^Version: [0-9]+\.[0-9]+\.[0-9]+/Version: ${NEW_VERSION}/" "$SPEC_FILE1"
echo "Version updated to $NEW_VERSION in $SPEC_FILE1."
# Validate the copr spec file exists
if [ ! -f "$SPEC_FILE2" ]; then
echo "Error: File '$SPEC_FILE2' not found."
exit 1
fi
# Replace the Version value
sed -i -E "s/^Version: [0-9]+\.[0-9]+\.[0-9]+/Version: ${NEW_VERSION}/" "$SPEC_FILE2"
echo "Version updated to $NEW_VERSION in $SPEC_FILE2."
# Regenerate manpages:
if ! command -v pandoc 2>&1 >/dev/null
then
echo "pandoc could not be found, not generating manpages"
else
pandoc -s -f markdown -t man "$MANPAGE_FILE" -o bookmark-dlp.1
fi
# Validate the PKGBUILD_SUM_UPDATER file exists
if [ ! -f "$PKGBUILD_SUM_UPDATER" ]; then
echo "Error: File '$PKGBUILD_SUM_UPDATER' not found."
exit 1
fi
# Replace the Version value
sed -i -E "s/^Version=[0-9]+\.[0-9]+\.[0-9]+/Version=${NEW_VERSION}/" "$PKGBUILD_SUM_UPDATER"
echo "Version updated to $NEW_VERSION in $PKGBUILD_SUM_UPDATER."
t
# Validate the nix file exists
if [ ! -f "$NIX_FILE" ]; then
echo "Error: File '$NIX_FILE' not found."
exit 1
fi
# Replace the Version value
sed -i -E "s/^version = "[0-9]\+\.[0-9]\+\.[0-9]\+"/version = "${NEW_VERSION}/"" "$SPEC_FILE"
echo "Version updated to $NEW_VERSION in $NIX_FILE."