Merge pull request #21 from rickstaa/improve_version_syntax_parsing
Adds new version matching syntax support
This commit is contained in:
4
.github/workflows/depup.yml
vendored
4
.github/workflows/depup.yml
vendored
@@ -19,7 +19,7 @@ jobs:
|
|||||||
repo: reviewdog/reviewdog
|
repo: reviewdog/reviewdog
|
||||||
|
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
uses: peter-evans/create-pull-request@v2
|
uses: peter-evans/create-pull-request@v3
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
title: "chore(deps): update reviewdog to ${{ steps.depup.outputs.latest }}"
|
title: "chore(deps): update reviewdog to ${{ steps.depup.outputs.latest }}"
|
||||||
@@ -43,7 +43,7 @@ jobs:
|
|||||||
repo: redpen-cc/redpen
|
repo: redpen-cc/redpen
|
||||||
|
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
uses: peter-evans/create-pull-request@v2
|
uses: peter-evans/create-pull-request@v3
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
title: "chore(deps): update redpen to ${{ steps.depup.outputs.latest }}"
|
title: "chore(deps): update redpen to ${{ steps.depup.outputs.latest }}"
|
||||||
|
|||||||
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# Files to ignore
|
||||||
|
|
||||||
|
# Folders to ignore
|
||||||
|
.vscode/
|
||||||
|
*.code-workspace
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
FROM alpine:3.10
|
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
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ jobs:
|
|||||||
repo: reviewdog/reviewdog
|
repo: reviewdog/reviewdog
|
||||||
|
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
uses: peter-evans/create-pull-request@v2
|
uses: peter-evans/create-pull-request@v3
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
title: "chore(deps): update reviewdog to ${{ steps.depup.outputs.latest }}"
|
title: "chore(deps): update reviewdog to ${{ steps.depup.outputs.latest }}"
|
||||||
|
|||||||
@@ -5,12 +5,13 @@ if [ -n "${GITHUB_WORKSPACE}" ]; then
|
|||||||
cd "${GITHUB_WORKSPACE}" || exit
|
cd "${GITHUB_WORKSPACE}" || exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
FILE="${INPUT_FILE:-Dockerfile}"
|
FILE="${INPUT_FILE:-testdata/testfile}"
|
||||||
REPO="${INPUT_REPO:-reviewdog/reviewdog}"
|
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}\s*(=|:?)\s*(\'|\")?v?\K\d+\.\d+(\.\d+)?" "${FILE}" | head -n1)
|
# NOTE: Go to https://regex101.com/r/t1JcmL/13 To see the current regex in action.
|
||||||
|
CURRENT_VERSION=$(grep -oP "${VERSION_NAME}(?:\s*=\s*|:?\s*)[\"|\']?v?\K\d+\.\d+(\.\d+)?(-[^\'\"\s]*)?" "${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
|
||||||
@@ -26,13 +27,13 @@ list_releases() {
|
|||||||
curl -s "https://api.github.com/repos/${REPO}/releases"
|
curl -s "https://api.github.com/repos/${REPO}/releases"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
LATEST_VERSION=$(\
|
LATEST_VERSION="$(\
|
||||||
list_releases | \
|
list_releases | \
|
||||||
jq -r '.[] | .tag_name' | \
|
jq -r '.[] | .tag_name' | \
|
||||||
grep -oP '\d+\.\d+(\.\d+)?$' | \
|
grep -oP '\d+\.\d+(\.\d+)?(-[^'\''\"\s]*)?$' | \
|
||||||
sort --version-sort --reverse | \
|
sort --version-sort --reverse | \
|
||||||
head -n1
|
head -n1 \
|
||||||
)
|
)"
|
||||||
if [ -z "${LATEST_VERSION}" ]; then
|
if [ -z "${LATEST_VERSION}" ]; then
|
||||||
echo "cannot get latest ${REPO} version"
|
echo "cannot get latest ${REPO} version"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -45,8 +46,9 @@ 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}\s*\(=\|:\?\)\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 "Updated. Commit and create Pull-Request as you need."
|
||||||
echo "::set-output name=current::${CURRENT_VERSION}"
|
echo "::set-output name=current::${CURRENT_VERSION}"
|
||||||
echo "::set-output name=latest::${LATEST_VERSION}"
|
echo "::set-output name=latest::${LATEST_VERSION}"
|
||||||
|
echo "::set-output name=repo::${REPO}"
|
||||||
|
|||||||
20
testdata/testfile
vendored
20
testdata/testfile
vendored
@@ -1,12 +1,32 @@
|
|||||||
This is test file.
|
This is test file.
|
||||||
|
|
||||||
REVIEWDOG_VERSION=v0.1.0
|
REVIEWDOG_VERSION=v0.1.0
|
||||||
|
REVIEWDOG_VERSION = v0.1.0
|
||||||
REVIEWDOG_VERSION=0.1.0
|
REVIEWDOG_VERSION=0.1.0
|
||||||
|
REVIEWDOG_VERSION = 0.1.0
|
||||||
|
REVIEWDOG_VERSION="v0.1.0"
|
||||||
|
REVIEWDOG_VERSION='v0.1.0'
|
||||||
|
REVIEWDOG_VERSION = "v0.1.0"
|
||||||
|
REVIEWDOG_VERSION = 'v0.1.0'
|
||||||
|
REVIEWDOG_VERSION="0.1.0"
|
||||||
|
REVIEWDOG_VERSION='0.1.0'
|
||||||
|
REVIEWDOG_VERSION = "0.1.0"
|
||||||
|
REVIEWDOG_VERSION = '0.1.0'
|
||||||
|
REVIEWDOG_VERSION="v0.1.0-nightly20201208+12faa31"
|
||||||
|
REVIEWDOG_VERSION='v0.1.0-nightly20201208+12faa31'
|
||||||
|
REVIEWDOG_VERSION = "v0.1.0-nightly20201208+12faa31"
|
||||||
|
REVIEWDOG_VERSION = 'v0.1.0-nightly20201208+12faa31'
|
||||||
|
REVIEWDOG_VERSION="0.1.0-nightly20201208+12faa31"
|
||||||
|
REVIEWDOG_VERSION='0.1.0-nightly20201208+12faa31'
|
||||||
|
REVIEWDOG_VERSION = "0.1.0-nightly20201208+12faa31"
|
||||||
|
REVIEWDOG_VERSION = '0.1.0-nightly20201208+12faa31'
|
||||||
ENV REVIEWDOG_VERSION=0.1.0
|
ENV REVIEWDOG_VERSION=0.1.0
|
||||||
ENV REVIEWDOG_VERSION 0.1.0
|
ENV REVIEWDOG_VERSION 0.1.0
|
||||||
ARG REVIEWDOG_VERSION=0.1.0
|
ARG REVIEWDOG_VERSION=0.1.0
|
||||||
yaml:
|
yaml:
|
||||||
REVIEWDOG_VERSION: 0.1.0
|
REVIEWDOG_VERSION: 0.1.0
|
||||||
|
REVIEWDOG_VERSION: "0.1.0"
|
||||||
|
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.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user