diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 28ca811..b98c17f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -86,16 +86,25 @@ jobs: fi echo "color=$COLOR" >> "$GITHUB_OUTPUT" + - name: Read version from gradle.properties + id: version + run: | + VERSION=$(grep 'jsoncmp.version=' gradle.properties | cut -d= -f2) + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + - name: Update README badges run: | COVERAGE=${{ needs.test-and-coverage.outputs.coverage }} COLOR=${{ steps.badge.outputs.color }} REPO=${{ github.repository }} + VERSION=${{ steps.version.outputs.version }} - BUILD_BADGE="[![Build](https://github.com/${REPO}/actions/workflows/main.yml/badge.svg)](https://github.com/${REPO}/actions/workflows/main.yml)" - COVERAGE_BADGE="[![Coverage](https://img.shields.io/badge/coverage-${COVERAGE}%25-${COLOR})](https://github.com/${REPO}/actions/workflows/main.yml)" + BUILD_BADGE="[![Build](https://github.com/${REPO}/actions/workflows/deploy.yml/badge.svg)](https://github.com/${REPO}/actions/workflows/deploy.yml)" + COVERAGE_BADGE="[![Coverage](https://img.shields.io/badge/coverage-${COVERAGE}%25-${COLOR})](https://github.com/${REPO}/actions/workflows/deploy.yml)" + VERSION_ESCAPED=$(echo "$VERSION" | sed 's/-/--/g') + MAVEN_BADGE="[![Maven](https://img.shields.io/badge/maven-${VERSION_ESCAPED}-blue)](https://github.com/${REPO}/packages)" - BADGE_LINE="${BUILD_BADGE} ${COVERAGE_BADGE}" + BADGE_LINE="${BUILD_BADGE} ${COVERAGE_BADGE} ${MAVEN_BADGE}" if grep -q '^\[!\[Build\]' README.md; then sed -i "1,/^\[!\[Build\]/s|^\[!\[Build\].*|${BADGE_LINE}|" README.md @@ -105,6 +114,12 @@ jobs: sed -i "1a\\\\${BADGE_LINE}\n" README.md fi + - name: Update version in README and docs + run: | + VERSION=${{ steps.version.outputs.version }} + sed -i "s|implementation(\"dev.skymansandy:json-cmp:[^\"]*\")|implementation(\"dev.skymansandy:json-cmp:${VERSION}\")|" README.md + find docs -name '*.md' -exec sed -i "s|implementation(\"dev.skymansandy:json-cmp:[^\"]*\")|implementation(\"dev.skymansandy:json-cmp:${VERSION}\")|" {} + + - name: Commit badge updates run: | git config user.name "github-actions[bot]" @@ -164,3 +179,32 @@ jobs: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4 + + github-release: + name: GitHub Release + needs: [publish, update-badges] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Read version from gradle.properties + id: version + run: | + VERSION=$(grep 'jsoncmp.version=' gradle.properties | cut -d= -f2) + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + + - name: Create GitHub Release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + VERSION=${{ steps.version.outputs.version }} + TAG="v${VERSION}" + + if gh release view "$TAG" > /dev/null 2>&1; then + echo "Release $TAG already exists, skipping." + else + gh release create "$TAG" \ + --title "$TAG" \ + --generate-notes \ + --target main + fi diff --git a/README.md b/README.md index 2858674..ed6aa45 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # JsonCMP -[![Build](https://github.com/skymansandy/jsonCMP/actions/workflows/main.yml/badge.svg)](https://github.com/skymansandy/jsonCMP/actions/workflows/main.yml) [![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)](https://github.com/skymansandy/jsonCMP/actions/workflows/main.yml) +[![Build](https://github.com/skymansandy/jsonCMP/actions/workflows/deploy.yml/badge.svg)](https://github.com/skymansandy/jsonCMP/actions/workflows/deploy.yml) [![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)](https://github.com/skymansandy/jsonCMP/actions/workflows/deploy.yml) [![Maven](https://img.shields.io/badge/maven-1.0.0--alpha2-blue)](https://github.com/skymansandy/jsonCMP/packages) Kotlin Multiplatform Compose JSON viewer and editor component for Android, iOS, and JVM Desktop. @@ -14,10 +14,29 @@ Kotlin Multiplatform Compose JSON viewer and editor component for Android, iOS, ## Installation +Add the GitHub Packages repository to your `settings.gradle.kts`: + +```kotlin +// settings.gradle.kts +dependencyResolutionManagement { + repositories { + maven { + url = uri("https://maven.pkg.github.com/skymansandy/jsonCMP") + credentials { + username = providers.gradleProperty("gpr.user").orNull ?: System.getenv("GITHUB_USERNAME") + password = providers.gradleProperty("gpr.key").orNull ?: System.getenv("GITHUB_TOKEN") + } + } + } +} +``` + +Then add the dependency: + ```kotlin // build.gradle.kts dependencies { - implementation("dev.skymansandy:json-cmp:") + implementation("dev.skymansandy:json-cmp:1.0.0-alpha2") } ``` diff --git a/docs/getting-started/installation.md b/docs/getting-started/installation.md index 6bbf42a..1fd8ce2 100644 --- a/docs/getting-started/installation.md +++ b/docs/getting-started/installation.md @@ -1,5 +1,28 @@ # Installation +## Repository Setup + +JsonCMP is published to GitHub Packages. Add the repository to your `settings.gradle.kts`: + +```kotlin +// settings.gradle.kts +dependencyResolutionManagement { + repositories { + maven { + url = uri("https://maven.pkg.github.com/skymansandy/jsonCMP") + credentials { + username = providers.gradleProperty("gpr.user").orNull ?: System.getenv("GITHUB_USERNAME") + password = providers.gradleProperty("gpr.key").orNull ?: System.getenv("GITHUB_TOKEN") + } + } + } +} +``` + +> **Note:** GitHub Packages requires authentication. Add `gpr.user` and `gpr.key` to your +> `~/.gradle/gradle.properties` or set `GITHUB_USERNAME` and `GITHUB_TOKEN` environment variables. +> The token needs the `read:packages` scope. + ## Gradle (Kotlin DSL) Add the dependency to your KMP module: @@ -11,7 +34,7 @@ Add the dependency to your KMP module: kotlin { sourceSets { commonMain.dependencies { - implementation("dev.skymansandy:json-cmp:") + implementation("dev.skymansandy:json-cmp:1.0.0-alpha2") } } } @@ -22,7 +45,7 @@ Add the dependency to your KMP module: ```kotlin // build.gradle.kts dependencies { - implementation("dev.skymansandy:json-cmp:") + implementation("dev.skymansandy:json-cmp:1.0.0-alpha2") } ``` diff --git a/gradle.properties b/gradle.properties index d6c7110..f94d15c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,4 +17,4 @@ android.r8.strictFullModeForKeepRules=false #Publishing jsoncmp.group=dev.skymansandy -jsoncmp.version=1.0.0-alpha2 +jsoncmp.version=1.0.0-alpha1