From a04b4ce2564e9d6f19531ca0311fe4ab2d8295e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Skar=C5=BCy=C5=84ski?= Date: Wed, 25 Nov 2020 11:57:06 +0100 Subject: [PATCH 1/2] run test workflow on workflow_dispatch event --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 83aa787..47dfc16 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,6 +4,7 @@ on: branches: - master pull_request: + workflow_dispatch: jobs: test: runs-on: ubuntu-latest From 4d5f0e24c7afc520bf828b98b7b363c7890a645e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Skar=C5=BCy=C5=84ski?= Date: Wed, 25 Nov 2020 12:19:08 +0100 Subject: [PATCH 2/2] skip white spaces and quotes in version regexp --- .github/workflows/test.yml | 14 ++++++++++++++ entrypoint.sh | 4 ++-- testdata/testfile | 3 +++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 47dfc16..296b616 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -47,3 +47,17 @@ jobs: - name: Check diff run: git diff + + quoted_version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: ./ + id: depup + with: + file: testdata/testfile + version_name: POETRY_VERSION + repo: python-poetry/poetry + + - name: Check diff + run: git diff diff --git a/entrypoint.sh b/entrypoint.sh index f652ced..40ecd25 100755 --- a/entrypoint.sh +++ b/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*(\'|\")?v?\K\d+\.\d+(\.\d+)?" "${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}" +sed -i "s/\(${VERSION_NAME}\s*\(=\|:\?\)\s*\('\|\"\)\?v\?\)\([0-9]\+\.[0-9]\+\(\.\?[0-9]\+\)\?\)/\1${LATEST_VERSION}/" "${FILE}" echo "Updated. Commit and create Pull-Request as you need." echo "::set-output name=current::${CURRENT_VERSION}" diff --git a/testdata/testfile b/testdata/testfile index eb921a6..7abc19f 100644 --- a/testdata/testfile +++ b/testdata/testfile @@ -16,3 +16,6 @@ Other test cases. REDPEN_VERSION=1.10.1 TMUX_VERSION=3.0 + +POETRY_VERSION="1.1.3" +ENV POETRY_VERSION='1.1.3'