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 }} 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/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 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..e4e8386 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -27,13 +27,23 @@ list_releases() { curl -s "https://api.github.com/repos/${REPO}/releases" 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_releases | \ - jq -r '.[] | .tag_name' | \ - grep -oP '\d+\.\d+(\.\d+)?(-[^'\''\"\s]*)?$' | \ + list_versions | \ + grep -oP '\d+(\.\d+)+(-[^'\''\"\s]*)?$'| \ sort --version-sort --reverse | \ head -n1 \ -)" + )" + if [ -z "${LATEST_VERSION}" ]; then echo "cannot get latest ${REPO} version" exit 1 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