Skip to content

Commit

Permalink
Initialize
Browse files Browse the repository at this point in the history
  • Loading branch information
ogesaku committed Jan 13, 2023
0 parents commit f399b9c
Show file tree
Hide file tree
Showing 55 changed files with 4,640 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space

[*.{yml, json}]
indent_size = 2
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "gradle"
directory: "/"
schedule:
interval: "monthly"
48 changes: 48 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build

on:
workflow_dispatch:
push:

jobs:
build:
runs-on: ubuntu-latest
if: github.event_name != 'push' || startsWith(github.ref, 'refs/tags/') == false
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Skip duplicates and docs
id: skip
uses: fkirc/skip-duplicate-actions@v5
with:
paths_ignore: '["**/README.md", "LICENSE", ".gitignore", ".editorconfig", ".idea/**"]'

- name: Validate gradle wrapper
if: steps.skip.outputs.should_skip != 'true'
uses: gradle/wrapper-validation-action@v1

- name: Setup JDK
if: steps.skip.outputs.should_skip != 'true'
uses: actions/setup-java@v3
with:
java-version: 17
cache: gradle
distribution: temurin

- name: Build with gradle
if: steps.skip.outputs.should_skip != 'true'
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: ./gradlew build jacocoTestReport coveralls --scan

dependabot:
needs: [ build ]
runs-on: ubuntu-latest
if: ${{ github.triggering_actor == 'dependabot' && github.event_name == 'pull_request'}}
steps:
- name: Auto-merge Dependabot PRs
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
173 changes: 173 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
name: Release

on:
workflow_dispatch:
inputs:
version:
type: string
description: |
Release version in semantic format (like: 1.2.3).
Default: a version with incremented patch number.
required: false
publish:
type: choice
description: Artifact publication.
options:
- AUTO
- SKIP
- RELEASE
- SNAPSHOT
required: true
default: AUTO
release:
types: [ published ]

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Validate build succeeded
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
declare -r BUILD_SUCCESS="$(gh api \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/actions/runs?status=success\&head_sha=${{ github.sha }} \
| jq 'limit(1; .workflow_runs[] | select(.name == "Build" and .conclusion == "success"))')"
if [ -z "$BUILD_SUCCESS" ]; then
echo "Commit did not pass Build!"
exit 1
fi
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.CI_TOKEN }}

- name: Get versions
id: versions
env:
NEXT_INPUT_VERSION: ${{ inputs.version }}
TAG_NAME: ${{ github.event.release.tag_name }}
run: |
declare -r GIT_VERSION="$(git tag -l 'v[0-9]*.[0-9]*.[0-9]*' | sort -V | tail -n 1 | cut -c2-)"
declare -r VERSION=${GIT_VERSION:-0.0.0}
declare -r MAJOR="$(echo "$VERSION" | cut -d. -f1)"
declare -r MINOR="$(echo "$VERSION" | cut -d. -f2)"
declare -r PATCH="$(echo "$VERSION" | cut -d. -f3)"
declare -r NEXT_TAG_VERSION="$([[ "$TAG_NAME" =~ v.* ]] \
&& (echo "$TAG_NAME" | cut -c2-) \
|| echo "$TAG_NAME")"
declare -r NEXT_MANUAL_VERSION="${NEXT_INPUT_VERSION:-$NEXT_TAG_VERSION}"
declare -r NEXT_PATCH_VERSION="$MAJOR.$MINOR.$(( $PATCH + 1 ))"
declare -r NEXT_VERSION="${NEXT_MANUAL_VERSION:-$NEXT_PATCH_VERSION}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT
echo -e "VERSION: $VERSION\nNEXT_VERSION: $NEXT_VERSION"
- name: Import GPG key
id: gpg
uses: crazy-max/ghaction-import-gpg@v5
if: |
github.event_name != 'release'
&& github.ref == 'refs/heads/master'
&& inputs.publish != 'SNAPSHOT'
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
git_committer_name: Coditory Bot
git_committer_email: bot@coditory.com

- name: Update version in README (master only)
if: steps.gpg.conclusion == 'success'
env:
PREV_VERSION: ${{ steps.versions.outputs.version }}
NEXT_VERSION: ${{ steps.versions.outputs.next_version }}
run: |
declare -r ESC_PREV_VERSION="${PREV_VERSION//./\\.}"
echo "Changing: $PREV_VERSION -> $NEXT_VERSION"
sed -i "s|${ESC_PREV_VERSION}|${NEXT_VERSION}|" README.md
if [ -n "$(git status --porcelain)" ]; then
git add -A
git commit -a -m "Update version $PREV_VERSION -> $NEXT_VERSION" -m "[ci skip]"
git push origin master
else
echo "Nothing changed. Skipping commit."
fi
- name: Setup JDK
if: inputs.publish != 'SKIP'
uses: actions/setup-java@v3
with:
java-version: 17
cache: gradle
distribution: temurin

- name: Publish release
if: |
github.event_name == 'release'
|| inputs.publish == 'RELEASE'
|| (inputs.publish == 'AUTO' && github.ref == 'refs/heads/master')
env:
NEXT_VERSION: ${{ steps.versions.outputs.next_version }}
SIGNING_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
SIGNING_PASSWORD: ${{ secrets.GPG_PASSPHRASE }}
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
run: |
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -Pversion=$NEXT_VERSION -Ppublish --info
echo "Published release: $NEXT_VERSION"
- name: Generate release notes
id: notes
if: |
github.event_name != 'release'
&& github.ref == 'refs/heads/master'
&& inputs.publish != 'SNAPSHOT'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PREV_VERSION: ${{ steps.versions.outputs.version }}
NEXT_VERSION: ${{ steps.versions.outputs.next_version }}
run: |
declare -r NOTES="$(gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/releases/generate-notes \
-f tag_name="v$NEXT_VERSION" \
-f target_commitish='master' \
-f previous_tag_name="v$PREV_VERSION" \
| jq -r '.body')"
declare -r ESCAPED="${NOTES//$'\n'/'%0A'}"
echo "notes=$ESCAPED" >> $GITHUB_OUTPUT
- name: Create github release (master only)
if: steps.notes.conclusion == 'success'
uses: ncipollo/release-action@v1
with:
allowUpdates: true
body: ${{ steps.notes.outputs.notes }}
draft: ${{ inputs.publish == 'SKIP' }}
tag: v${{ steps.versions.outputs.next_version }}
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: "build/libs/*.jar"

- name: Publish snapshot
if: |
github.event_name == 'workflow_dispatch'
&& (
inputs.publish == 'SNAPSHOT'
|| inputs.publish == 'AUTO' && github.ref != 'refs/heads/master'
)
env:
NEXT_VERSION: ${{ steps.versions.outputs.next_version }}
SIGNING_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
SIGNING_PASSWORD: ${{ secrets.GPG_PASSPHRASE }}
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
run: |
declare -r MIDDLE="$([ "$GITHUB_REF" == "refs/heads/master" ] && echo "" || echo "-${GITHUB_REF#refs/heads/}")"
./gradlew publishToSonatype -Pversion="${NEXT_VERSION}${MIDDLE}-SNAPSHOT" -Ppublish
echo "Published snapshot: ${NEXT_VERSION}${MIDDLE}-SNAPSHOT"
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Gradle
build
.gradle
!gradle/wrapper/gradle-wrapper.jar

# IntelliJ
out
*.iml
.idea/*
!.idea/codeStyles
50 changes: 50 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Paweł Mendelski

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.
Loading

0 comments on commit f399b9c

Please sign in to comment.