@@ -9,9 +9,10 @@ usage() {
9
9
cat << EOF
10
10
$this : download go binaries for nektos/act
11
11
12
- Usage: $this [-b bindir] [-d] [tag]
12
+ Usage: $this [-b bindir] [-d] [-f] [ tag]
13
13
-b sets bindir or installation directory, Defaults to ./bin
14
14
-d turns on debug logging
15
+ -f forces installation, bypassing version checks
15
16
[tag] is a tag from
16
17
https://github.com/nektos/act/releases
17
18
If tag is missing, then the latest will be used.
@@ -24,10 +25,11 @@ parse_args() {
24
25
# over-ridden by flag below
25
26
26
27
BINDIR=${BINDIR:- ./ bin}
27
- while getopts " b:dh ?x" arg; do
28
+ while getopts " b:dfh ?x" arg; do
28
29
case " $arg " in
29
30
b) BINDIR=" $OPTARG " ;;
30
31
d) log_set_priority 10 ;;
32
+ f) FORCE_INSTALL=" true" ;;
31
33
h | \? ) usage " $0 " ;;
32
34
x) set -x ;;
33
35
esac
@@ -124,6 +126,37 @@ adjust_arch() {
124
126
esac
125
127
true
126
128
}
129
+ check_installed_version () {
130
+ # Check if force install flag is set
131
+ if [ " ${FORCE_INSTALL} " = " true" ]; then
132
+ log_info " force install enabled. Skipping version check."
133
+ return
134
+ fi
135
+
136
+ # Check if the binary exists
137
+ if is_command " $BINARY " ; then
138
+ # Extract installed version using cut
139
+ INSTALLED_VERSION=$( $BINARY --version | cut -d' ' -f3)
140
+
141
+ if [ -z " $INSTALLED_VERSION " ]; then
142
+ log_err " failed to detect installed version. Proceeding with installation."
143
+ return
144
+ fi
145
+
146
+ log_info " found installed version: $INSTALLED_VERSION "
147
+
148
+ # Compare versions
149
+ if [ " $INSTALLED_VERSION " = " $VERSION " ]; then
150
+ log_info " $BINARY version $INSTALLED_VERSION is already installed."
151
+ exit 0
152
+ else
153
+ log_debug " updating $BINARY from version $INSTALLED_VERSION to $VERSION ..."
154
+ fi
155
+ else
156
+ log_debug " $BINARY is not installed. Proceeding with installation..."
157
+ fi
158
+ }
159
+
127
160
128
161
cat /dev/null << EOF
129
162
------------------------------------------------------------------------
@@ -380,6 +413,8 @@ get_binaries
380
413
381
414
tag_to_version
382
415
416
+ check_installed_version
417
+
383
418
adjust_format
384
419
385
420
adjust_os
0 commit comments