Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support tag checker #33

Merged
merged 6 commits into from
Feb 15, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/depup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
15 changes: 15 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
18 changes: 14 additions & 4 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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+(\.\d+)*(-[^'\''\"\s]*)?$' | \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, wait. I noticed that you changed the regex too.
Can you revert the change or explain why you updated the regex?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why

Some tags have been given a small version that deviates from the rules of semver, so I changed it.

Validity of change

Because, previouse commit split release(semver valid) and tag (semver deviate).

First, I think non-semver ruling tag(x.y.z.?) ignoring rule...but test case support non-semver(for -hoge suffix).
And I tried to support it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I guess I don't get it. Can you list actual real-world examples who uses x.y.z.??

Also, this repo doesn't intend to support non-semver in the first place, so can you propose a change separately?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that -xyz suffix is actually valid semver. https://semver.org/#spec-item-10

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I get it. Hmm... 1.5.2.1 is a super weird tag name...

Ideally, I'd reject such inputs, but maybe it's fine to accept. I left a suggestion to make the regex simpler but LGTM other than that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree.
x.y.z.a ... can be simply drop away.

haya14busa marked this conversation as resolved.
Show resolved Hide resolved
sort --version-sort --reverse | \
head -n1 \
)"
)"

if [ -z "${LATEST_VERSION}" ]; then
echo "cannot get latest ${REPO} version"
exit 1
Expand Down
2 changes: 2 additions & 0 deletions testdata/testfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ TMUX_VERSION=3.0

POETRY_VERSION="1.1.3"
ENV POETRY_VERSION='1.1.3'

THEMIS_VERSION=1.5