-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
287 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,17 @@ | ||
name: Build | ||
|
||
on: [pull_request, push, workflow_dispatch] | ||
on: [ pull_request, push, workflow_dispatch ] | ||
|
||
jobs: | ||
deduplicate: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
should_skip: ${{ steps.skip.outputs.should_skip }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Skip duplicates and docs | ||
id: skip | ||
uses: fkirc/skip-duplicate-actions@v5 | ||
with: | ||
concurrent_skipping: same_content_newer | ||
paths_ignore: '["**/README.md", "LICENSE", ".gitignore", ".editorconfig", ".idea/**"]' | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
needs: deduplicate | ||
if: "needs.pre_job.outputs.should_skip != 'true'" | ||
timeout-minutes: 15 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Validate gradle wrapper | ||
uses: gradle/wrapper-validation-action@v1 | ||
- name: Setup Gradle | ||
uses: gradle/gradle-build-action@v2 | ||
|
||
- name: Setup JDK | ||
uses: actions/setup-java@v4 | ||
|
@@ -37,7 +20,70 @@ jobs: | |
cache: gradle | ||
distribution: temurin | ||
|
||
- name: Build with gradle | ||
env: | ||
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} | ||
- name: Build | ||
run: ./gradlew build | ||
|
||
- name: Publish Test Report | ||
if: success() || failure() # run this step even if previous step failed | ||
uses: dorny/test-reporter@v1 | ||
with: | ||
name: Kotest report | ||
path: ./**/build/test-results/test/*.xml | ||
reporter: java-junit | ||
|
||
- name: Publish Coverage Report | ||
uses: codecov/codecov-action@v3 | ||
if: github.repository == 'coditory/klog' && github.ref == 'refs/heads/main' | ||
continue-on-error: true | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
override_commit: ${{ github.event.workflow_run.head_sha }} | ||
override_branch: ${{ github.event.workflow_run.head_branch }} | ||
override_build: ${{ github.event.workflow_run.id }} | ||
files: 'build/reports/kover/report.xml' | ||
|
||
- name: Import GPG Key | ||
id: gpg | ||
uses: crazy-max/ghaction-import-gpg@v5 | ||
if: | | ||
github.repository == 'coditory/klog' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) | ||
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: [email protected] | ||
|
||
- name: Publish Snapshot | ||
run: ./gradlew publishJvmPublicationToSnapshotsRepository | ||
if: github.repository == 'coditory/klog' && github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') | ||
|
||
- name: Publish Release | ||
id: publish-release | ||
run: ./gradlew publishJvmPublicationToReleasesRepository | ||
if: github.repository == 'coditory/klog' && startsWith(github.ref, 'refs/tags/v') && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') | ||
|
||
- name: Generate Release Notes | ||
id: generate-release-notes | ||
if: steps.publish-release.conclusion == 'success' | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
declare -r NOTES="$(gh api \ | ||
--method POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
/repos/${{ github.repository }}/releases/generate-notes \ | ||
-f target_commitish='main' \ | ||
| jq -r '.body')" | ||
declare -r ESCAPED="${NOTES//$'\n'/'%0A'}" | ||
echo "notes=$ESCAPED" >> $GITHUB_OUTPUT | ||
- name: Create github release (main only) | ||
if: steps.generate-release-notes.conclusion == 'success' | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
allowUpdates: true | ||
body: ${{ steps.notes.outputs.notes }} | ||
tag: v${{ steps.versions.outputs.next_version }} | ||
token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Dependabot | ||
|
||
on: [ pull_request_target ] | ||
|
||
jobs: | ||
dependabot: | ||
runs-on: ubuntu-latest | ||
if: github.event.pull_request.user.login == 'dependabot[bot]' | ||
permissions: | ||
pull-requests: write | ||
contents: write | ||
steps: | ||
- name: Dependabot metadata | ||
id: dependabot-metadata | ||
uses: dependabot/[email protected] | ||
|
||
- name: Enable auto-merge for dependabot PRs | ||
run: gh pr merge --auto --rebase "$PR_URL" | ||
env: | ||
PR_URL: ${{ github.event.pull_request.html_url }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Approve patch and minor updates | ||
if: steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major' || steps.dependabot-metadata.outputs.package-ecosystem == 'github-actions' | ||
run: gh pr review $PR_URL --approve -b "Pull request **approved** because **it includes a patch or minor update**" | ||
env: | ||
PR_URL: ${{ github.event.pull_request.html_url }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,26 +19,11 @@ on: | |
- 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: | ||
|
@@ -81,93 +66,9 @@ jobs: | |
git_committer_name: Coditory Bot | ||
git_committer_email: [email protected] | ||
|
||
- name: Update version in README (main only) | ||
- name: Create Release Tag | ||
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 | ||
sed -i "s|${ESC_PREV_VERSION}|${NEXT_VERSION}|" mkdocs.yml | ||
if [ -n "$(git status --porcelain)" ]; then | ||
git add -A | ||
git commit -a -m "Update version in docs $PREV_VERSION -> $NEXT_VERSION" -m "[ci skip]" | ||
git push origin main | ||
else | ||
echo "Nothing changed. Skipping commit." | ||
fi | ||
- name: Setup JDK | ||
if: inputs.publish != 'SKIP' | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: 21 | ||
cache: gradle | ||
distribution: temurin | ||
|
||
- name: Publish release | ||
if: | | ||
github.event_name == 'release' | ||
|| inputs.publish == 'RELEASE' | ||
|| (inputs.publish == 'AUTO' && github.ref == 'refs/heads/main') | ||
env: | ||
NEXT_VERSION: ${{ steps.versions.outputs.next_version }} | ||
SIGNING_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | ||
SIGNING_PASSWORD: ${{ secrets.GPG_PASSPHRASE }} | ||
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} | ||
OSSRH_PASSWORD: ${{ secrets.OSSRH_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/main' | ||
&& 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='main' \ | ||
-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 (main 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 }} | ||
|
||
- name: Publish snapshot | ||
if: | | ||
github.event_name == 'workflow_dispatch' | ||
&& ( | ||
inputs.publish == 'SNAPSHOT' | ||
|| inputs.publish == 'AUTO' && github.ref != 'refs/heads/main' | ||
) | ||
env: | ||
NEXT_VERSION: ${{ steps.versions.outputs.next_version }} | ||
SIGNING_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | ||
SIGNING_PASSWORD: ${{ secrets.GPG_PASSPHRASE }} | ||
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} | ||
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} | ||
run: | | ||
declare -r MIDDLE="$([ "$GITHUB_REF" == "refs/heads/main" ] && echo "" || echo "-${GITHUB_REF#refs/heads/}")" | ||
./gradlew publishToSonatype -Pversion="${NEXT_VERSION}${MIDDLE}-SNAPSHOT" -Ppublish | ||
echo "Published snapshot: ${NEXT_VERSION}${MIDDLE}-SNAPSHOT" | ||
git push origin master "v$NEXT_VERSION" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.