From bbfd8c9caca78ef781cd27760c83de14df061503 Mon Sep 17 00:00:00 2001 From: Tsuyoshi CHO Date: Sun, 14 Feb 2021 13:55:28 +0900 Subject: [PATCH 1/6] Add support tag checker --- action.yml | 4 ++++ entrypoint.sh | 28 +++++++++++++++++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/action.yml b/action.yml index 7fcaf23..28532f8 100644 --- a/action.yml +++ b/action.yml @@ -14,6 +14,10 @@ inputs: repo: description: 'target GitHub repository. e.g. reviewdog/reviewdog' required: true + tag: + description: 'Check tags instead of releases.' + default: 'false' + required: false runs: using: 'docker' image: 'Dockerfile' diff --git a/entrypoint.sh b/entrypoint.sh index 4b47069..b306b64 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -27,13 +27,27 @@ list_releases() { curl -s "https://api.github.com/repos/${REPO}/releases" fi } -LATEST_VERSION="$(\ - list_releases | \ - jq -r '.[] | .tag_name' | \ - grep -oP '\d+\.\d+(\.\d+)?(-[^'\''\"\s]*)?$' | \ - sort --version-sort --reverse | \ - head -n1 \ -)" + +LATEST_VERSION="${CURRENT_VERSION}" +if [ "${INPUT_TAG:-false}" = "true" ]; then + echo "Check remote tag instead of release" >&2 + LATEST_VERSION="$(\ + git ls-remote -q --tags "https://github.com/${REPO}.git" | \ + awk '{ print $2 }' | \ + grep -oP '\d+\.\d+(\.\d+)*(-[^'\''\"\s]*)?$' | \ + sort --version-sort --reverse | \ + head -n1 \ + )" +else + LATEST_VERSION="$(\ + list_releases | \ + jq -r '.[] | .tag_name' | \ + grep -oP '\d+\.\d+(\.\d+)*(-[^'\''\"\s]*)?$' | \ + sort --version-sort --reverse | \ + head -n1 \ + )" +fi + if [ -z "${LATEST_VERSION}" ]; then echo "cannot get latest ${REPO} version" exit 1 From 06537dd0a515268e0d3edd8ba2d8a09d20e69c5f Mon Sep 17 00:00:00 2001 From: Tsuyoshi CHO Date: Sun, 14 Feb 2021 13:57:41 +0900 Subject: [PATCH 2/6] Add tag checker test --- .github/workflows/test.yml | 15 +++++++++++++++ testdata/testfile | 2 ++ 2 files changed, 17 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 296b616..6f0b26d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -61,3 +61,18 @@ jobs: - name: Check diff run: git diff + + tagged_version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: ./ + id: depup + with: + file: testdata/testfile + version_name: THEMIS_VERSION + repo: thinca/vim-themis + tag: true + + - name: Check diff + run: git diff diff --git a/testdata/testfile b/testdata/testfile index 3d1c073..2e9cf8e 100644 --- a/testdata/testfile +++ b/testdata/testfile @@ -39,3 +39,5 @@ TMUX_VERSION=3.0 POETRY_VERSION="1.1.3" ENV POETRY_VERSION='1.1.3' + +THEMIS_VERSION=1.5 From 5538f76c192b3e38edd4756f3722d23ec760056f Mon Sep 17 00:00:00 2001 From: Tsuyoshi CHO Date: Sun, 14 Feb 2021 14:02:48 +0900 Subject: [PATCH 3/6] Add tag sample --- .github/workflows/depup.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/depup.yml b/.github/workflows/depup.yml index e56ac80..7e63e02 100644 --- a/.github/workflows/depup.yml +++ b/.github/workflows/depup.yml @@ -53,3 +53,27 @@ jobs: This PR is auto generated by [depup workflow](https://github.com/${{ github.repository }}/actions?query=workflow%3A${{ github.workflow }}). branch: depup/${{ steps.depup.outputs.repo }} + + themis: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: ./ + id: depup + with: + file: testdata/testfile + version_name: THEMIS_VERSION + repo: thinca/vim-themis + tag: true + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + title: "chore(deps): update ${{ steps.depup.outputs.repo }} to ${{ steps.depup.outputs.latest }}" + commit-message: "chore(deps): update ${{ steps.depup.outputs.repo }} to ${{ steps.depup.outputs.latest }}" + body: | + Update ${{ steps.depup.outputs.repo }} to [${{ steps.depup.outputs.latest }}](https://github.com/${{ steps.depup.outputs.repo }}/releases/tag/v${{ steps.depup.outputs.latest }}) + + This PR is auto generated by [depup workflow](https://github.com/${{ github.repository }}/actions?query=workflow%3A${{ github.workflow }}). + branch: depup/${{ steps.depup.outputs.repo }} From b7620405b1a1f0802200d4ef0568740255a6b1ff Mon Sep 17 00:00:00 2001 From: Tsuyoshi CHO Date: Sun, 14 Feb 2021 14:02:55 +0900 Subject: [PATCH 4/6] Update README --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index d243d56..0170979 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,10 @@ inputs: repo: description: 'target GitHub repository. e.g. reviewdog/reviewdog' required: true + tag: + description: 'Check tags instead of releases.' + default: 'false' + required: false ``` ## Example usage From bb1dcffbd3e5ec39a2ebe0e7c6b824b7e9b59c39 Mon Sep 17 00:00:00 2001 From: Tsuyoshi CHO Date: Sun, 14 Feb 2021 16:42:19 +0900 Subject: [PATCH 5/6] fix review suggest : create listup function --- entrypoint.sh | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index b306b64..bfb2a56 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -28,25 +28,21 @@ list_releases() { fi } -LATEST_VERSION="${CURRENT_VERSION}" -if [ "${INPUT_TAG:-false}" = "true" ]; then - echo "Check remote tag instead of release" >&2 - LATEST_VERSION="$(\ - git ls-remote -q --tags "https://github.com/${REPO}.git" | \ - awk '{ print $2 }' | \ - grep -oP '\d+\.\d+(\.\d+)*(-[^'\''\"\s]*)?$' | \ - sort --version-sort --reverse | \ - head -n1 \ - )" -else - LATEST_VERSION="$(\ - list_releases | \ - jq -r '.[] | .tag_name' | \ - grep -oP '\d+\.\d+(\.\d+)*(-[^'\''\"\s]*)?$' | \ - sort --version-sort --reverse | \ - head -n1 \ - )" -fi +# Return version list from tags(refs/tags/vA.B.C and vA.B.C^{}) or releases +list_versions() { + if [ "${INPUT_TAG:-false}" = "true" ]; then + git ls-remote -q --tags "https://github.com/${REPO}.git" | awk '{ print $2 }' + else + list_releases | jq -r '.[] | .tag_name' + fi +} + +LATEST_VERSION="$(\ + list_versions | \ + grep -oP '\d+\.\d+(\.\d+)*(-[^'\''\"\s]*)?$' | \ + sort --version-sort --reverse | \ + head -n1 \ + )" if [ -z "${LATEST_VERSION}" ]; then echo "cannot get latest ${REPO} version" From de1e7065a07f40b2951bf97e8fcea7b47c75a9b9 Mon Sep 17 00:00:00 2001 From: haya14busa Date: Mon, 15 Feb 2021 21:22:12 +0900 Subject: [PATCH 6/6] Update entrypoint.sh --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index bfb2a56..e4e8386 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -39,7 +39,7 @@ list_versions() { LATEST_VERSION="$(\ list_versions | \ - grep -oP '\d+\.\d+(\.\d+)*(-[^'\''\"\s]*)?$' | \ + grep -oP '\d+(\.\d+)+(-[^'\''\"\s]*)?$'| \ sort --version-sort --reverse | \ head -n1 \ )"