Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Android開発においての自動化あれこれ

Rui
November 20, 2024
24

 Android開発においての自動化あれこれ

Rui

November 20, 2024
Tweet

Transcript

  1. ,UMJOUͷࣗಈԽͰߦͳͬͨ͜ͱ name: ktLint-checker on: [ pull_request ] jobs: kotlin: name:

    runner / suggester / spotless runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up JDK 17 uses: actions/setup-java@v4 with: java-version: '17' distribution: 'temurin' - run: ./gradlew ktlintFormat - run: ./gradlew spotlessKotlinApply - uses: reviewdog/action-suggester@v1 with: github_token: ${{ secrets.GITHUB_TOKEN }} tool_name: spotless w HJUIVCXPSL fl PXTLUMJOU DIFDLFSZNM౳Ͱ࡞੒͢Δ w TQPUMFTT,PUMJO"QQMZͰ,UMJOUʹԊ͏ Α͏ʹमਖ਼ͯ͠ɺSFWJFXEPXͰ TVHHFTUJPO͢Δ
  2. ,UMJOUͷࣗಈԽͰߦͳͬͨ͜ͱ tasks.register("ktlintFormat", JavaExec::class.java) { description = "Fix Kotlin code style

    deviations." mainClass.set("com.pinterest.ktlint.Main") classpath = ktlint group = "formatting" args = listOf("-F", "src/**/*.kt") jvmArgs = listOf("--add-opens", "java.base/ java.lang=ALL-UNNAMED") } w TQPUMFTT,PUMJO"QQMZͷΈͩͱม׵ ͯ͘͠Εͳ͍ͱ͜Ζ͕͋ͬͨͷͰɺ CVJMEHSBEMFLUTʹࣗ࡞Ͱ΋,UMJOUͰ ϑΥʔϚοτνΣοΫΛߦ͏ɻ
  3. όʔδϣϯίʔυΛߋ৽ - &update_version_code name: "commit & push update versionCode" command:

    | git config user.email “[email protected]” git config user.name "note Android auto committer" git pull origin $(git branch --show-current) ./gradlew updateVersionCode git add note/app_version.properties git commit -m "[ci skip][auto commit] update to versionCode" git push origin HEAD w DJSDMFDJDPO fi HZNM w HJUDPO fi HͰϢʔβʔ৘ใΛઃఆ w $JSDMF$*ͷϏϧυ͕࠶ͼߦΘΕͳ͍ Α͏ʹ<DJTLJQ>Λ͚ͭΔ
  4. όʔδϣϯίʔυΛߋ৽ // app_version.properties versionName=8.21.0 versionCode=366 // build.gradle.kts tasks.register("updateVersionCode") { doLast

    { val appVersionPropertyFile = "app_version.properties" val propertyKeyVersionCode = "versionCode" val propertyFile = file(appVersionPropertyFile) val props = loadProperties(propertyFile) val nextVersionCode = props.getProperty(propertyKeyVersionCode).toInt() + 1 props.setProperty(propertyKeyVersionCode, nextVersionCode.toString()) props.store(propertyFile.writer(), null) } } fun loadProperties(file: File): Properties { val props = Properties() file.inputStream().use { props.load(it) } return props } w BQQ@WFSTJPOQSPQFSUJFTʹόʔδϣ ϯίʔυΛఆٛ w #VJMEHSBEMFLUT಺Ͱ্هͷόʔδϣ ϯίʔυΛΠϯΫϦϝϯτ͢Δ