File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,10 @@ inputs:
23
23
description : ' Prefix to strip from the tag. For example if `strip_prefix` is set to `v` and the tag is `v1.0.0` the output becomes `1.0.0`.'
24
24
required : false
25
25
default : ' '
26
+ use_tag_commit_hash :
27
+ description : ' When true, uses commit hash in the replacement pattern. For example, replaces `hash # v1` with `hash # v2`.'
28
+ required : false
29
+ default : ' false'
26
30
27
31
outputs :
28
32
is_initial_release :
58
62
INPUT_PATTERN: ${{ inputs.pattern }}
59
63
INPUT_ONLY_MAJOR: ${{ inputs.only_major }}
60
64
INPUT_STRIP_PREFIX: ${{ inputs.strip_prefix }}
65
+ INPUT_USE_TAG_COMMIT_HASH: ${{ inputs.use_tag_commit_hash }}
61
66
62
67
branding :
63
68
icon : arrow-up
Original file line number Diff line number Diff line change 36
36
echo " is_initial_release=false" >> " $GITHUB_OUTPUT "
37
37
fi
38
38
39
+ # Get commit hash for current tag if use_tag_commit_hash is true
40
+ if [[ " $INPUT_USE_TAG_COMMIT_HASH " == " true" ]]; then
41
+ CURRENT_COMMIT_HASH=$( git rev-parse " $CURRENT_TAG " 2> /dev/null || git rev-parse HEAD)
42
+ NEW_COMMIT_HASH=$( git rev-parse " $NEW_TAG " 2> /dev/null || git rev-parse HEAD)
43
+ CURRENT_PATTERN=" $CURRENT_COMMIT_HASH # $CURRENT_TAG "
44
+ NEW_PATTERN=" $NEW_COMMIT_HASH # $NEW_TAG "
45
+ else
46
+ CURRENT_PATTERN=" $PATTERN$CURRENT_TAG "
47
+ NEW_PATTERN=" $PATTERN$NEW_TAG "
48
+ fi
49
+
39
50
if [[ " $INPUT_ONLY_MAJOR " == " true" ]]; then
40
51
NEW_MAJOR_TAG=$( echo " $NEW_TAG " | cut -d. -f1)
41
52
CURRENT_MAJOR_TAG=$( echo " $CURRENT_TAG " | cut -d. -f1)
51
62
for path in $INPUT_PATHS
52
63
do
53
64
echo " Replacing major version $CURRENT_MAJOR_TAG with $NEW_MAJOR_TAG for: $path "
54
- sed -i " s|$PATTERN$CURRENT_MAJOR_TAG \(.[[:digit:]]\)\{0,1\}\(.[[:digit:]]\)\{0,1\}|$PATTERN$NEW_MAJOR_TAG |g" " $path "
65
+ if [[ " $INPUT_USE_TAG_COMMIT_HASH " == " true" ]]; then
66
+ sed -i " s|$CURRENT_PATTERN |$NEW_PATTERN |g" " $path "
67
+ else
68
+ sed -i " s|$PATTERN$CURRENT_MAJOR_TAG \(.[[:digit:]]\)\{0,1\}\(.[[:digit:]]\)\{0,1\}|$PATTERN$NEW_MAJOR_TAG |g" " $path "
69
+ fi
55
70
done
56
71
57
72
cat << EOF >> "$GITHUB_OUTPUT "
68
83
for path in $INPUT_PATHS
69
84
do
70
85
echo " Replacing $CURRENT_TAG with $NEW_TAG for: $path "
71
- sed -i " s|$PATTERN$CURRENT_TAG | $PATTERN$NEW_TAG |g" " $path "
86
+ sed -i " s|$CURRENT_PATTERN | $NEW_PATTERN |g" " $path "
72
87
done
73
88
fi
74
89
You can’t perform that action at this time.
0 commit comments