✨ Extends version matching with quotes and - annotated tags"
In this commit I added support to match the version when it is enclosed in quotes (Example: REVIEWDOG_VERSION = "v0.1.0"). I also added support for version tags that contain a - annotation text (example: REVIEWDOG=v0.1.0-nightly20201208+12faa31). You can check out the regex syntax on https://regex101.com/r/t1JcmL/10.
This commit is contained in:
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
# Files to ignore
|
||||
|
||||
# Folders to ignore
|
||||
.vscode/
|
||||
@@ -1,6 +1,6 @@
|
||||
FROM alpine:3.10
|
||||
|
||||
RUN apk --no-cache add git jq curl grep coreutils
|
||||
RUN apk --no-cache add git jq curl grep coreutils perl
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ REPO="${INPUT_REPO:-reviewdog/reviewdog}"
|
||||
VERSION_NAME="${INPUT_VERSION_NAME:-REVIEWDOG_VERSION}"
|
||||
|
||||
# Get current version.
|
||||
CURRENT_VERSION=$(grep -oP "${VERSION_NAME}(=|:?\s+)v?\K\d+\.\d+(\.\d+)?" "${FILE}" | head -n1)
|
||||
CURRENT_VERSION=$(grep -oP "${VERSION_NAME}(?:\s?=\s?|:?\s+)\"?v?\K\d+\.\d+(\.\d+)?(-[^\"\s]*)?" "${FILE}" | head -n1)
|
||||
if [ -z "${CURRENT_VERSION}" ]; then
|
||||
echo "cannot parse ${VERSION_NAME}"
|
||||
exit 1
|
||||
@@ -45,7 +45,7 @@ if [ "${CURRENT_VERSION}" = "${LATEST_VERSION}" ]; then
|
||||
fi
|
||||
|
||||
echo "Updating ${VERSION_NAME} to ${LATEST_VERSION} in ${FILE}"
|
||||
sed -i "s/\(${VERSION_NAME}\(=\|:\?\s\+\)v\?\)\([0-9]\+\.[0-9]\+\(\.\?[0-9]\+\)\?\)/\1${LATEST_VERSION}/" "${FILE}"
|
||||
perl -i -pe "s/${VERSION_NAME}(?:\s?=\s?|:?\s+)\"?v?\K\d+\.\d+(\.\d+)?(-[^\"\s]*)?/${LATEST_VERSION}/g" "${FILE}"
|
||||
|
||||
echo "Updated. Commit and create Pull-Request as you need."
|
||||
echo "::set-output name=current::${CURRENT_VERSION}"
|
||||
|
||||
Reference in New Issue
Block a user