From b64231ec5feb62cabdf813baf8a093887231ba4f Mon Sep 17 00:00:00 2001 From: swfz Date: Thu, 12 Mar 2020 01:01:36 +0900 Subject: [PATCH 1/2] feat: add version pattern --- entrypoint.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 99dafff..f652ced 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+)v?\K\d+\.\d+(\.\d+)?" "${FILE}" | head -n1) if [ -z "${CURRENT_VERSION}" ]; then echo "cannot parse ${VERSION_NAME}" exit 1 @@ -29,7 +29,7 @@ list_releases() { LATEST_VERSION=$(\ list_releases | \ jq -r '.[] | .tag_name' | \ - grep -oP '\d+\.\d+\.\d+$' | \ + grep -oP '\d+\.\d+(\.\d+)?$' | \ sort --version-sort --reverse | \ head -n1 ) @@ -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\+\)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}" From 8907f95f88355a68a4365ad13c1ba72b8b5e06e1 Mon Sep 17 00:00:00 2001 From: swfz Date: Thu, 12 Mar 2020 01:02:07 +0900 Subject: [PATCH 2/2] feat: add test pattern --- .github/workflows/test.yml | 14 ++++++++++++++ testdata/testfile | 2 ++ 2 files changed, 16 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9d5a1f0..83aa787 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,3 +32,17 @@ jobs: - name: Check diff run: git diff + + not_semver: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: ./ + id: depup + with: + file: testdata/testfile + version_name: TMUX_VERSION + repo: tmux/tmux + + - name: Check diff + run: git diff diff --git a/testdata/testfile b/testdata/testfile index 33f8ca0..eb921a6 100644 --- a/testdata/testfile +++ b/testdata/testfile @@ -14,3 +14,5 @@ The above version should be updated to the latest version with this action. Other test cases. REDPEN_VERSION=1.10.1 + +TMUX_VERSION=3.0