13
.github/workflows/dockerimage.yml
vendored
Normal file
13
.github/workflows/dockerimage.yml
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
name: Docker Image CI
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Build the Docker image
|
||||
run: docker build . --file Dockerfile --tag ${{ github.repository }}:$(date +%s)
|
||||
40
.github/workflows/reviewdog.yml
vendored
Normal file
40
.github/workflows/reviewdog.yml
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
name: reviewdog
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
jobs:
|
||||
shellcheck:
|
||||
name: runner / shellcheck
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: haya14busa/action-cond@v1
|
||||
id: reporter
|
||||
with:
|
||||
cond: ${{ github.event_name == 'pull_request' }}
|
||||
if_true: "github-pr-review"
|
||||
if_false: "github-check"
|
||||
- uses: reviewdog/action-shellcheck@v1
|
||||
with:
|
||||
github_token: ${{ secrets.github_token }}
|
||||
reporter: ${{ steps.reporter.outputs.value }}
|
||||
level: warning
|
||||
|
||||
hadolint:
|
||||
name: runner / hadolint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: haya14busa/action-cond@v1
|
||||
id: reporter
|
||||
with:
|
||||
cond: ${{ github.event_name == 'pull_request' }}
|
||||
if_true: "github-pr-review"
|
||||
if_false: "github-check"
|
||||
- uses: reviewdog/action-hadolint@v1
|
||||
with:
|
||||
github_token: ${{ secrets.github_token }}
|
||||
reporter: ${{ steps.reporter.outputs.value }}
|
||||
level: warning
|
||||
20
.github/workflows/test.yml
vendored
Normal file
20
.github/workflows/test.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
name: Test
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ./
|
||||
id: autobump
|
||||
with:
|
||||
file: testdata/testfile
|
||||
version_name: REVIEWDOG_VERSION
|
||||
repo: reviewdog/reviewdog
|
||||
|
||||
- name: Check diff
|
||||
run: git diff
|
||||
15
.github/workflows/update_semver.yml
vendored
Normal file
15
.github/workflows/update_semver.yml
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
name: Update Semver
|
||||
on:
|
||||
push:
|
||||
branches-ignore:
|
||||
- '**'
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
jobs:
|
||||
update-semver:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: haya14busa/action-update-semver@v1
|
||||
with:
|
||||
github_token: ${{ secrets.github_token }}
|
||||
7
Dockerfile
Normal file
7
Dockerfile
Normal file
@@ -0,0 +1,7 @@
|
||||
FROM alpine:3.10
|
||||
|
||||
RUN apk --no-cache add git jq curl grep coreutils
|
||||
|
||||
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'
|
||||
54
entrypoint.sh
Executable file
54
entrypoint.sh
Executable file
@@ -0,0 +1,54 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
if [ -n "${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.
|
||||
list_releases() {
|
||||
if [ -n "${INPUT_GITHUB_TOKEN}" ]; then
|
||||
echo "Use INPUT_GITHUB_TOKEN to get release data." >&2
|
||||
curl -s -H "Authorization: token ${INPUT_GITHUB_TOKEN}" "https://api.github.com/repos/${REPO}/releases"
|
||||
else
|
||||
echo "INPUT_GITHUB_TOKEN is not available. Subscequent GitHub API call can fail due to API limit." >&2
|
||||
curl -s "https://api.github.com/repos/${REPO}/releases"
|
||||
fi
|
||||
}
|
||||
LATEST_VERSION=$(\
|
||||
list_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}"
|
||||
6
testdata/testfile
vendored
Normal file
6
testdata/testfile
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
This is test file.
|
||||
|
||||
REVIEWDOG_VERSION=0.1.0
|
||||
|
||||
The above version should be updated to the latest version with this action.
|
||||
|
||||
Reference in New Issue
Block a user