-
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.
update Ktor to 2.x and fix serialization issues
- Loading branch information
1 parent
9abe961
commit ceed827
Showing
14 changed files
with
240 additions
and
189 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,76 +1,97 @@ | ||
name: Build, Sign, Release | ||
|
||
permissions: write-all | ||
on: | ||
push: | ||
branches: | ||
- trunk | ||
|
||
permissions: write-all | ||
# tags: | ||
# - 'v*.*.*' | ||
|
||
jobs: | ||
build: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up our JDK environment | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: temurin | ||
java-version: 17 | ||
- name: | ||
uses: gradle/actions/setup-gradle@v3 | ||
|
||
- name: Execute Gradle build | ||
run: ./gradlew --build-cache assembleRelease | ||
|
||
- name: Sign artifact | ||
id: sign_artifact | ||
uses: r0adkll/sign-android-release@v1 | ||
with: | ||
releaseDirectory: app/build/outputs/apk/release | ||
alias: ${{ secrets.KEY_ALIAS }} | ||
signingKeyBase64: ${{ secrets.KEYSTORE }} | ||
keyStorePassword: ${{ secrets.KEYSTORE_PASSWORD }} | ||
keyPassword: ${{ secrets.KEY_PASSWORD }} | ||
env: | ||
BUILD_TOOLS_VERSION: "34.0.0" | ||
|
||
- name: Upload our APK | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: Release artifact | ||
path: app/build/outputs/apk/release/app-*.apk | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: trunk | ||
release_name: Release trunk | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Save name of our Artifact | ||
id: set-result-artifact | ||
run: | | ||
ARTIFACT_PATHNAME_APK=$(ls app/build/outputs/apk/release/*.apk | head -n 1) | ||
ARTIFACT_NAME_APK=$(basename $ARTIFACT_PATHNAME_APK) | ||
echo "ARTIFACT_NAME_APK is " ${ARTIFACT_NAME_APK} | ||
echo "ARTIFACT_PATHNAME_APK=${ARTIFACT_PATHNAME_APK}" >> $GITHUB_ENV | ||
echo "ARTIFACT_NAME_APK=${ARTIFACT_NAME_APK}" >> $GITHUB_ENV | ||
- uses: actions/checkout@v2 | ||
- name: Set env | ||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | ||
- name: Test | ||
run: | | ||
echo $RELEASE_VERSION | ||
echo ${{ env.RELEASE_VERSION }} | ||
- name: Upload our Artifact Assets | ||
id: upload-release-asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ${{ env.ARTIFACT_PATHNAME_APK }} | ||
asset_name: ${{ env.ARTIFACT_NAME_APK }} | ||
asset_content_type: application/zip | ||
# jobs: | ||
# build: | ||
# runs-on: ubuntu-latest | ||
# | ||
# steps: | ||
# - name: checkout | ||
# uses: actions/checkout@v4 | ||
# | ||
# - name: Set up JDK env | ||
# uses: actions/setup-java@v4 | ||
# with: | ||
# distribution: 'temurin' | ||
# java-version: 19 | ||
# cache: 'gradle' | ||
# | ||
# # - name: | ||
# # uses: gradle/actions/setup-gradle@v3 | ||
# | ||
# - name: Execute Gradle build | ||
# run: ./gradlew --no-daemon --build-cache assembleRelease | ||
# | ||
# # - name: Setup build tool version variable | ||
# # shell: bash | ||
# # run: | | ||
# # BUILD_TOOL_VERSION=$(ls /usr/local/lib/android/sdk/build-tools/ | tail -n 1) | ||
# # echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV | ||
# # echo Last build tool version is: $BUILD_TOOL_VERSION | ||
# # | ||
# # - name: Sign artifact | ||
# # id: sign_artifact | ||
# # uses: r0adkll/sign-android-release@v1 | ||
# # with: | ||
# # releaseDirectory: app/build/outputs/apk/release | ||
# # alias: ${{ secrets.KEY_ALIAS }} | ||
# # signingKeyBase64: ${{ secrets.KEYSTORE }} | ||
# # keyStorePassword: ${{ secrets.KEY_PASSWD }} | ||
# # keyPassword: ${{ secrets.KEY_PASSWD }} | ||
# # env: | ||
# # BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }} | ||
# | ||
# - name: Upload our APK | ||
# uses: actions/upload-artifact@v2 | ||
# with: | ||
# name: Release artifact | ||
# path: app/build/outputs/apk/release/app-*.apk | ||
# | ||
# - name: Create Release | ||
# id: create_release | ||
# uses: actions/create-release@v1 | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# with: | ||
# tag_name: trunk | ||
# release_name: Release trunk | ||
# draft: false | ||
# prerelease: false | ||
# | ||
# - name: Save name of our Artifact | ||
# id: set-result-artifact | ||
# run: | | ||
# ARTIFACT_PATHNAME_APK=$(ls app/build/outputs/apk/release/*.apk | head -n 1) | ||
# ARTIFACT_NAME_APK=$(basename $ARTIFACT_PATHNAME_APK) | ||
# echo "ARTIFACT_NAME_APK is " ${ARTIFACT_NAME_APK} | ||
# echo "ARTIFACT_PATHNAME_APK=${ARTIFACT_PATHNAME_APK}" >> $GITHUB_ENV | ||
# echo "ARTIFACT_NAME_APK=${ARTIFACT_NAME_APK}" >> $GITHUB_ENV | ||
# | ||
# - name: Upload our Artifact Assets | ||
# id: upload-release-asset | ||
# uses: actions/upload-release-asset@v1 | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# with: | ||
# upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
# asset_path: ${{ env.ARTIFACT_PATHNAME_APK }} | ||
# asset_name: ${{ env.ARTIFACT_NAME_APK }} | ||
# asset_content_type: application/zip |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"version": 3, | ||
"artifactType": { | ||
"type": "APK", | ||
"kind": "Directory" | ||
}, | ||
"applicationId": "org.yrovas.linklater", | ||
"variantName": "release", | ||
"elements": [ | ||
{ | ||
"type": "SINGLE", | ||
"filters": [], | ||
"attributes": [], | ||
"versionCode": 1, | ||
"versionName": "0.1.0", | ||
"outputFile": "app-release.apk" | ||
} | ||
], | ||
"elementType": "File" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,55 @@ | ||
package org.yrovas.linklater | ||
|
||
import android.util.Log | ||
import androidx.annotation.Keep | ||
import io.ktor.client.HttpClient | ||
import io.ktor.client.engine.android.Android | ||
import io.ktor.client.features.DefaultRequest | ||
import io.ktor.client.features.json.JsonFeature | ||
import io.ktor.client.features.json.serializer.KotlinxSerializer | ||
import io.ktor.client.features.logging.* | ||
import io.ktor.client.features.observer.ResponseObserver | ||
import io.ktor.client.plugins.DefaultRequest | ||
import io.ktor.client.plugins.contentnegotiation.* | ||
import io.ktor.client.plugins.logging.* | ||
import io.ktor.client.request.header | ||
import io.ktor.http.ContentType | ||
import io.ktor.http.HttpHeaders | ||
import io.ktor.serialization.kotlinx.json.json | ||
import kotlinx.serialization.json.Json | ||
|
||
private const val TIME_OUT = 60_000 | ||
// private const val TIME_OUT = 60_000 | ||
|
||
class Ktor { | ||
companion object { | ||
val client = HttpClient(Android) { | ||
|
||
install(JsonFeature) { | ||
serializer = KotlinxSerializer(Json { | ||
install(Logging) { | ||
logger = object : Logger { | ||
override fun log(message: String) { | ||
Log.i("Ktor =>", message) | ||
} | ||
} | ||
level = LogLevel.ALL | ||
} | ||
install(ContentNegotiation) { | ||
json(Json { | ||
prettyPrint = true | ||
isLenient = true | ||
ignoreUnknownKeys = true | ||
}) | ||
|
||
engine { | ||
connectTimeout = TIME_OUT | ||
socketTimeout = TIME_OUT | ||
} | ||
} | ||
|
||
// install(Logging) { | ||
// logger = object : Logger { | ||
// override fun log(message: String) { | ||
// Log.v("Ktor =>", message) | ||
// } | ||
// } | ||
// level = LogLevel.ALL | ||
// } | ||
|
||
install(ResponseObserver) { | ||
onResponse { response -> | ||
Log.d("HTTP status:", "${response.status.value}") | ||
} | ||
} | ||
|
||
install(DefaultRequest) { | ||
header(HttpHeaders.ContentType, ContentType.Application.Json) | ||
} | ||
} | ||
} | ||
} | ||
// | ||
//// if (BuildConfig.DEBUG) { | ||
// install(Logging) { | ||
// level = LogLevel.ALL | ||
// } | ||
//// } | ||
// | ||
//// if (BuildConfig.DEBUG) { | ||
// install(ResponseObserver) { | ||
// onResponse { response -> | ||
// Log.i("HTTP status:", "${response.status.value}") | ||
// } | ||
// } | ||
//// } |
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.