Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/actions/calculate-tag/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: 'Next Release Tag'
description: 'Calculate the next release'

outputs:
version:
description: Version of this release
value: ${{ steps.version_extractor.outputs.VERSION}}

runs:
using: composite
steps:
# Use to calculate next version name
- name: Run drafter to calculate version (on main)
id: draft-release-notes
uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}

- id: version_extractor
run: ./.github/actions/calculate-tag/extract_tag.sh ${{github.ref}} ${{ steps.draft-release-notes.outputs.tag_name}}
shell: bash
14 changes: 14 additions & 0 deletions .github/actions/calculate-tag/extract_tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

github_ref=$1
draft_tag=$2

if [[ $github_ref == refs/tags/v* ]]; then
tag=${github_ref/refs\/tags\//}
tag="${tag:1}"
echo "VERSION=$tag" >> "$GITHUB_OUTPUT"
else
tag=$draft_tag
tag="${tag:1}"
echo "VERSION=$tag" >> "$GITHUB_OUTPUT"
fi
45 changes: 45 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name-template: 'v$RESOLVED_VERSION 🌈'
tag-template: 'v$RESOLVED_VERSION'

categories:
- title: '🚀 Features and Enhancements'
labels:
- 'type: Feature :bulb:'
- 'type: Enhancement :pen:'
- title: '🐛 Bug Fixes'
labels:
- 'type: Bug :bug:'
- title: '🧰 Maintenance'
label: 'type: Chore'
- title: '🧺 Miscellaneous' # Everything except ABAP
label: 'type: Misc'
- title: '🔗 Dependency Updates'
label: 'type: dependencies'

change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch

exclude-labels:
- 'skip-changelog'

template: |
## What's New

$CHANGES

## Contributors

Thanks to $CONTRIBUTORS for your contributions to this release!

**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION
115 changes: 68 additions & 47 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ on:
pull_request:
branches:
- main
types: [ opened, synchronize, reopened, ready_for_review ]
paths-ignore:
- 'art/**'
- '**.md'
- 'docs/**'

concurrency:
group: build-${{ github.ref }}
Expand All @@ -36,11 +35,7 @@ jobs:
java-version: 17
distribution: adopt

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Gradle Wrapper Validation
uses: gradle/wrapper-validation-action@v3
- uses: gradle/gradle-build-action@v3

- name: Binary Compatibility Validation
run: ./gradlew apiCheck --scan
Expand Down Expand Up @@ -69,8 +64,7 @@ jobs:
java-version: 17
distribution: adopt

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- uses: gradle/gradle-build-action@v3

- name: Cache Konan
uses: actions/cache@v4
Expand All @@ -83,19 +77,44 @@ jobs:
restore-keys: |
${{ runner.os }}-konan-

- name: Gradle Wrapper Validation
uses: gradle/wrapper-validation-action@v3

- name: Run ${{ matrix.config.target }} tests
continue-on-error: ${{ matrix.config.continueOnError }}
run: ./gradlew ${{ matrix.config.tasks }} --scan

test-instrumented:
strategy:
matrix:
api-level: [ 24, 29, 31 ]
runs-on: macos-latest
name: Test API ${{ matrix.api-level }}
# test-instrumented:
# strategy:
# matrix:
# api-level: [ 24, 29, 31 ]
# runs-on: macos-latest
# name: Test API ${{ matrix.api-level }}
# needs: verify
# steps:
# - name: Checkout
# uses: actions/checkout@v4
#
# - name: setup-java
# uses: actions/setup-java@v4
# with:
# java-version: 17
# distribution: adopt
#
# - uses: gradle/gradle-build-action@v3
#
# - name: Run tests for API ${{ matrix.api-level }}
# uses: reactivecircus/android-emulator-runner@v2
# with:
# api-level: ${{ matrix.api-level }}
# arch: x86_64
# disable-animations: true
# force-avd-creation: false
# ram-size: 4096M
# emulator-boot-timeout: 12000
# emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-snapshot-save
# script: ./gradlew connectedCheck --scan

test-browser:
runs-on: ubuntu-latest
name: Test JS in browser
needs: verify
steps:
- name: Checkout
Expand All @@ -107,46 +126,48 @@ jobs:
java-version: 17
distribution: adopt

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- uses: gradle/gradle-build-action@v3

- name: Gradle Wrapper Validation
uses: gradle/wrapper-validation-action@v3
- name: Setup headless Chrome
uses: browser-actions/setup-chrome@v1

- name: Run tests for API ${{ matrix.api-level }}
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
arch: x86_64
disable-animations: true
force-avd-creation: false
ram-size: 4096M
emulator-boot-timeout: 12000
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-snapshot-save
script: ./gradlew connectedCheck --scan
- name: Run tests in browser
run: ./gradlew jsTest --scan

test-browser:
runs-on: ubuntu-latest
name: Test JS in browser
release:
if: github.ref == 'refs/heads/main'

name: Publish library SNAPSHOT
runs-on: macos-latest
needs: verify
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Extract version
id: version
uses: ./.github/actions/calculate-tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Copy CI gradle.properties
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties

- name: setup-java
uses: actions/setup-java@v4
with:
java-version: 17
distribution: adopt

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Gradle Wrapper Validation
uses: gradle/wrapper-validation-action@v3

- name: Setup headless Chrome
uses: browser-actions/setup-chrome@v1

- name: Run tests in browser
run: ./gradlew jsTest --scan
- uses: gradle/gradle-build-action@v3

- name: Deploy to Sonatype
run: |
export ORG_GRADLE_PROJECT_VERSION_NAME=${{ steps.version.outputs.version }}-SNAPSHOT
./gradlew publish --no-configuration-cache
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVENCENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVENCENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
23 changes: 13 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Publish
on:
workflow_dispatch:
release:
types: [ prereleased, released ]

Expand Down Expand Up @@ -43,18 +42,18 @@ jobs:
run: |
NEW_VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3)
echo "New version: ${NEW_VERSION}"
export ORG_GRADLE_PROJECT_VERSION_NAME=${NEW_VERSION}
export ORG_GRADLE_PROJECT_VERSION_NAME=${NEW_VERSION:1}
echo "RELEASE_VERSION=$NEW_VERSION" >> "$GITHUB_ENV"
./gradlew publishAllPublicationsToMavenCentral --no-configuration-cache --stacktrace
./gradlew publish --no-configuration-cache
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVENCENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVENCENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}

- name: Update README for ${{ env.RELEASE_VERSION }}
run: ./.github/version.sh "${RELEASE_VERSION}"
run: ./.github/version.sh "${RELEASE_VERSION:1}"

- name: Commit changes to README to ${{ env.branch }}
uses: EndBug/add-and-commit@v9
Expand Down Expand Up @@ -116,11 +115,15 @@ jobs:
arguments: :demo:composeApp:jsBrowserProductionWebpack

- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
id: deploy
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: kmpalette-demo
directory: demo/composeApp/build/dist/js/productionExecutable
command: pages deploy demo/composeApp/build/dist/js/productionExecutable --project-name=example
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
branch: main

- name: Print deployment-url
env:
DEPLOYMENT_URL: ${{ steps.deploy.outputs.deployment-url }}
run: echo $DEPLOYMENT_URL
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ In `libs.versions.toml`:

```toml
[versions]
kmpalette = "3.1.0"
kmpalette = "0.1.1"

[libraries]
kmpalette-core = { module = "com.kmpalette:kmpalette-core", version.ref = "kmpalette" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,11 +512,11 @@ public class Palette internal constructor(
val bitmap = imageBitmap
if (bitmap != null) {
if (region == null) {
region = Rect(0f, 0f, bitmap.width.toFloat(), bitmap.height.toFloat())
region = Rect(left.toFloat(), top.toFloat(), right.toFloat(), bottom.toFloat())
}

// Now just get the intersection with the region
val other = Rect(left.toFloat(), top.toFloat(), right.toFloat(), bottom.toFloat())
val other = Rect(0f, 0f, bitmap.width.toFloat(), bitmap.height.toFloat())
if (!region!!.overlaps(other)) {
throw IllegalArgumentException("The given region must intersect with "
+ "the Bitmap's dimensions.")
Expand Down
3 changes: 2 additions & 1 deletion extensions-base64/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ kotlin {
implementation(project(":kmpalette-core"))
api(project(":kmpalette-bitmap-loader"))
api(project(":extensions-bytearray"))
implementation(project(":androidx-palette"))
implementation(compose.ui)
implementation(libs.kotlinx.coroutines)
}
Expand Down Expand Up @@ -87,4 +88,4 @@ android {
kotlin {
jvmToolchain(jdkVersion = 11)
}
}
}
3 changes: 2 additions & 1 deletion extensions-file/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ kotlin {
implementation(project(":kmpalette-core"))
api(project(":kmpalette-bitmap-loader"))
implementation(project(":extensions-bytearray"))
implementation(project(":androidx-palette"))
implementation(compose.ui)
implementation(libs.kotlinx.coroutines)
implementation(libs.okio)
Expand Down Expand Up @@ -69,4 +70,4 @@ android {
kotlin {
jvmToolchain(jdkVersion = 11)
}
}
}
3 changes: 2 additions & 1 deletion extensions-network/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ kotlin {
implementation(project(":kmpalette-core"))
api(project(":kmpalette-bitmap-loader"))
implementation(project(":extensions-bytearray"))
implementation(project(":androidx-palette"))
implementation(compose.ui)
implementation(libs.kotlinx.coroutines)
implementation(libs.ktor.client)
Expand Down Expand Up @@ -73,4 +74,4 @@ android {
kotlin {
jvmToolchain(jdkVersion = 11)
}
}
}
Loading