Merge pull request #7 from haya14busa/more-pattern

Support more patterns
This commit is contained in:
haya14busa
2020-01-19 17:18:59 +09:00
committed by GitHub
2 changed files with 8 additions and 2 deletions

View File

@@ -10,7 +10,7 @@ REPO="${INPUT_REPO:-reviewdog/reviewdog}"
VERSION_NAME="${INPUT_VERSION_NAME:-REVIEWDOG_VERSION}" VERSION_NAME="${INPUT_VERSION_NAME:-REVIEWDOG_VERSION}"
# Get current version. # Get current version.
CURRENT_VERSION=$(grep -oP "${VERSION_NAME}=\K\d+\.\d+\.\d+" "${FILE}") CURRENT_VERSION=$(grep -oP "${VERSION_NAME}(=|:?\s+)\v?\K\d+\.\d+\.\d+" "${FILE}" | head -n1)
if [ -z "${CURRENT_VERSION}" ]; then if [ -z "${CURRENT_VERSION}" ]; then
echo "cannot parse ${VERSION_NAME}" echo "cannot parse ${VERSION_NAME}"
exit 1 exit 1
@@ -47,7 +47,7 @@ if [ "${CURRENT_VERSION}" = "${LATEST_VERSION}" ]; then
fi fi
echo "Updating ${VERSION_NAME} to ${LATEST_VERSION} in ${FILE}" echo "Updating ${VERSION_NAME} to ${LATEST_VERSION} in ${FILE}"
sed -i "s/\(${VERSION_NAME}=\)\([0-9]\+\.[0-9]\+\.\?[0-9]\+\)/\1${LATEST_VERSION}/" "${FILE}" sed -i "s/\(${VERSION_NAME}\(=\|:\?\s\+\)v\?\)\([0-9]\+\.[0-9]\+\.\?[0-9]\+\)/\1${LATEST_VERSION}/" "${FILE}"
echo "Updated. Commit and create Pull-Request as you need." echo "Updated. Commit and create Pull-Request as you need."
echo "::set-output name=current::${CURRENT_VERSION}" echo "::set-output name=current::${CURRENT_VERSION}"

6
testdata/testfile vendored
View File

@@ -1,6 +1,12 @@
This is test file. This is test file.
REVIEWDOG_VERSION=v0.1.0
REVIEWDOG_VERSION=0.1.0 REVIEWDOG_VERSION=0.1.0
ENV REVIEWDOG_VERSION=0.1.0
ENV REVIEWDOG_VERSION 0.1.0
ARG REVIEWDOG_VERSION=0.1.0
yaml:
REVIEWDOG_VERSION: 0.1.0
The above version should be updated to the latest version with this action. The above version should be updated to the latest version with this action.