initial version
This commit is contained in:
7
Dockerfile
Normal file
7
Dockerfile
Normal file
@@ -0,0 +1,7 @@
|
||||
FROM alpine:3.10
|
||||
|
||||
RUN apk --no-cache add git jq curl
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 haya14busa
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
23
action.yml
Normal file
23
action.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
name: 'Bump version in code to latest semantic ver release'
|
||||
description: 'Bump version in code to latest semantic ver release. (e.g. REVIEWDOG=0.9.17 in Dockerfile)'
|
||||
author: 'haya14busa'
|
||||
inputs:
|
||||
github_token:
|
||||
description: 'GITHUB_TOKEN to get latest version with GitHub Release API'
|
||||
default: '${{ github.token }}'
|
||||
file:
|
||||
description: 'target file'
|
||||
required: true
|
||||
version_name:
|
||||
description: 'target version name. e.g. REVIEWDOG_VERSION'
|
||||
required: true
|
||||
repo:
|
||||
description: 'target GitHub repository. e.g. reviewdog/reviewdog'
|
||||
required: true
|
||||
runs:
|
||||
using: 'docker'
|
||||
image: 'Dockerfile'
|
||||
# Ref: https://haya14busa.github.io/github-action-brandings/
|
||||
branding:
|
||||
icon: 'refresh-cw'
|
||||
color: 'orange'
|
||||
53
entrypoint.sh
Executable file
53
entrypoint.sh
Executable file
@@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
if [ ! -z "${GITHUB_WORKSPACE}" ]; then
|
||||
cd "${GITHUB_WORKSPACE}" || exit
|
||||
fi
|
||||
|
||||
FILE="${INPUT_FILE:-Dockerfile}"
|
||||
REPO="${INPUT_REPO:-reviewdog/reviewdog}"
|
||||
VERSION_NAME="${INPUT_VERSION_NAME:-REVIEWDOG_VERSION}"
|
||||
|
||||
# Get current version.
|
||||
CURRENT_VERSION=$(grep -oP "${VERSION_NAME}=\K\d+\.\d+\.\d+" "${FILE}")
|
||||
if [ -z "${CURRENT_VERSION}" ]; then
|
||||
echo "cannot parse ${VERSION_NAME}"
|
||||
exit 1
|
||||
fi
|
||||
echo "Current ${VERSION_NAME}=${CURRENT_VERSION}"
|
||||
|
||||
# Get latest semantic version release tag name from GitHub Release API.
|
||||
GITHUB_AUTH_HEADER=""
|
||||
if [ ! -z "${INPUT_GITHUB_TOKEN}" ]; then
|
||||
GITHUB_AUTH_HEADER="-H \"Authorization: token ${INPUT_GITHUB_TOKEN}\""
|
||||
echo "Use INPUT_GITHUB_TOKEN to get release data."
|
||||
else
|
||||
echo "INPUT_GITHUB_TOKEN is not available. Subscequent GitHub API call can fail due to API limit."
|
||||
fi
|
||||
|
||||
LATEST_VERSION=$(\
|
||||
curl -s ${GITHUB_AUTH_HEADER} https://api.github.com/repos/${REPO}/releases | \
|
||||
jq -r '.[] | .tag_name' | \
|
||||
sed 's/^v//' | \
|
||||
grep -P '\d+\.\d+\.\d+' | \
|
||||
sort --version-sort --reverse | \
|
||||
head -n1
|
||||
)
|
||||
if [ -z "${LATEST_VERSION}" ]; then
|
||||
echo "cannot get latest ${REPO} version"
|
||||
exit 1
|
||||
fi
|
||||
echo "Latest ${VERSION_NAME}=${LATEST_VERSION}"
|
||||
|
||||
if [ "${CURRENT_VERSION}" = "${LATEST_VERSION}" ]; then
|
||||
echo "${VERSION_NAME} is latest. Nothing to do."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Updating ${VERSION_NAME} to ${LATEST_VERSION} in ${FILE}"
|
||||
sed -i "s/\(${VERSION_NAME}=\)\([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}"
|
||||
echo "::set-output name=latest::${LATEST_VERSION}"
|
||||
Reference in New Issue
Block a user