StoreScreenshot

name: StoreScreenshot

on:
  push:
    branches:
      - main
  pull_request:

permissions: {}

jobs:
  store-screenshot-test:
    runs-on: macos-latest
    timeout-minutes: 20

    permissions:
      contents: read # for clone
      actions: write # for upload-artifact

    steps:
      - name: Checkout
        uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0

      - name: Set up JDK 17
        uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
        with:
          distribution: temurin
          java-version: 17

      # Better than caching and/or extensions of actions/setup-java
      - name: Setup Gradle
        uses: gradle/gradle-build-action@a8f75513eafdebd8141bd1cd4e30fcd194af8dfa # v2.12.0
        with:
          gradle-version: wrapper

      - name: record screenshot
        id: record-test
        run: |
          cd include-build;
          ./gradlew roborazzi-core:test
          cd ..
          ./gradlew recordRoborazziDebug recordRoborazziDesktop recordRoborazziJvm recordRoborazziIosX64 --stacktrace

      - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
        if: ${{ always() }}
        with:
          name: screenshot
          path: |
            **/build/outputs/roborazzi
          retention-days: 30

      - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
        if: ${{ always() }}
        with:
          name: screenshot-reports
          path: |
            **/build/reports
            **/build/outputs/roborazzi
          retention-days: 30

      - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
        if: ${{ always() }}
        with:
          name: screenshot-test-results
          path: |
            **/build/test-results
          retention-days: 30


build-plugin

name: build-plugin

on:
  push:
    branches:
      - main
  pull_request:

env:
  GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx6g -Dorg.gradle.daemon=false -Dkotlin.incremental=false"

jobs:
  build:
    runs-on: macos-latest

    steps:
      - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
      - uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
        with:
          distribution: 'zulu'
          java-version: 19

      - name: Gradle cache
        uses: gradle/gradle-build-action@a8f75513eafdebd8141bd1cd4e30fcd194af8dfa # v2

      - name: build-plugin
        id: test
        run: |
          ./gradlew roborazzi-idea-plugin:build --stacktrace

      - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
        if: ${{ always() }}
        with:
          name: roborazzi-plugin-jar
          path: |
            **/build/libs/roborazzi-idea-plugin-*.jar
          retention-days: 120


diff test

name: diff test

on:
  push:
    branches:
      - main
  pull_request:

env:
  GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx6g -Dorg.gradle.daemon=false -Dkotlin.incremental=false"

jobs:
  test:
    runs-on: macos-latest

    steps:
      - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
      - uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
        with:
          distribution: 'zulu'
          java-version: 19

      - name: Gradle cache
        uses: gradle/gradle-build-action@a8f75513eafdebd8141bd1cd4e30fcd194af8dfa # v2

      - uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e # v2
        with:
          name: screenshot
          path: sample-android/build/outputs/roborazzi
          workflow: StoreScreenshot.yml
          branch: main

      - name: compare test
        run: |
          echo '<resources>
            <string name="first_fragment_label">Hello! This is compare test screen! Compare me!</string>
            <string name="hello_first_fragment">Compare Hello first fragment</string>
          </resources>' > sample-android/src/main/res/values/strings_for_test.xml
          ./gradlew sample-android:compareRoborazziDebug --stacktrace
          # Check if there are difference with sample-android/build/outputs/roborazzi/test_compare.png
          find sample-android/build/outputs/roborazzi
          file_path="sample-android/build/outputs/roborazzi/com.github.takahirom.roborazzi.sample.ManualTest.captureScreenLevelImageWithEspresso_compare.png"
          if [ ! -f "$file_path" ]; then
            echo "Error: File $file_path not found."
           exit 1
          else
            echo "File $file_path found."
            exit 0
          fi

      - name: verify test
        id: verify-test
        continue-on-error: true
        run: |
          echo '<resources>
            <string name="first_fragment_label">Hello! This is verify test screen! Verify me!</string>
            <string name="hello_first_fragment">Verify Hello first fragment</string>
          </resources>' > sample-android/src/main/res/values/strings_for_test.xml
          ./gradlew sample-android:verifyRoborazziDebug --stacktrace

      - name: Run shell script on Gradle failure
        if: steps.verify-test.outcome == 'success'
        run: |
          echo "Roborazzi should verify changes"
          exit 1

      - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
        if: ${{ always() }}
        with:
          name: screenshot-diff
          path: sample-android/build/outputs/roborazzi
          retention-days: 30

      - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
        if: ${{ always() }}
        with:
          name: screenshot-diff-reports
          path: sample-android/build/reports
          retention-days: 30

      - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
        if: ${{ always() }}
        with:
          name: screenshot-diff-test-results
          path: sample-android/build/test-results
          retention-days: 30


Build documentation

name: Build documentation

on:
# If specified, the workflow will be triggered automatically once you push to the `main` branch.
# Replace `main` with your branch’s name
    push:
        branches: ["main"]
# Specify to run a workflow manually from the Actions tab on GitHub
    workflow_dispatch:

# Gives the workflow permissions to clone the repo and create a page deployment
permissions:
    id-token: write
    pages: write

env:
    # Name of module and id separated by a slash
    INSTANCE: docs/roborazzi-docs
    ARTIFACT: webHelpROBORAZZI-DOCS2-all.zip
    # Writerside docker image version
    DOCKER_VERSION: 232.10275
# Add the variable below to upload Algolia indexes
#    ALGOLIA_ARTIFACT: algolia-indexes-roborazzi-docs.zip

jobs:
    build:
        runs-on: ubuntu-latest

        steps:
        - name: Checkout repository
          uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3

        - name: Build Writerside docs using Docker
          uses: JetBrains/writerside-github-action@5a6920dbce3ef3169acbeb7e45c6cbdaf7e76bfa # v4
          with:
            instance: ${{ env.INSTANCE }}
            artifact: ${{ env.ARTIFACT }}
            docker-version: ${{ env.DOCKER_VERSION }}

        - name: Upload documentation
          uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
          with:
            name: docs
            path: |
                artifacts/${{ env.ARTIFACT }}
                artifacts/report.json
            retention-days: 7

# Add the step below to upload Algolia indexes
#        - name: Upload algolia-indexes
#          uses: actions/upload-artifact@v3
#          with:
#            name: algolia-indexes
#            path: artifacts/${{ env.ALGOLIA_ARTIFACT }}
#            retention-days: 7

# Add the job below and artifacts/report.json on Upload documentation step above if you want to fail the build when documentation contains errors
    test:
    # Requires build job results
        needs: build
        runs-on: ubuntu-latest

        steps:
            - name: Download artifacts
              uses: actions/download-artifact@18f0f591fbc635562c815484d73b6e8e3980482e # v1
              with:
                name: docs
                path: artifacts

            - name: Test documentation
              uses: JetBrains/writerside-checker-action@8e11963855941a93dff60b8e39a2ffd4a2c0b767 # v1
              with:
                instance: ${{ env.INSTANCE }}

    deploy:
        environment:
            name: github-pages
            url: ${{ steps.deployment.outputs.page_url }}
        # Requires the build job results
        needs: test
        runs-on: ubuntu-latest
        steps:
            - name: Download artifact
              uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3
              with:
                name: docs

            - name: Unzip artifact
              uses: montudor/action-zip@a8e75c9faefcd80fac3baf53ef40b9b119d5b702 # v1
              with:
                args: unzip -qq ${{ env.ARTIFACT }} -d dir

            - name: Setup Pages
              uses: actions/configure-pages@c5a3e1159e0cbdf0845eb8811bd39e39fc3099c2 # v2

            - name: Upload artifact
              uses: actions/upload-pages-artifact@84bb4cd4b733d5c320c9c9cfbc354937524f4d64 # v1
              with:
                path: dir

            - name: Deploy to GitHub Pages
              id: deployment
              uses: actions/deploy-pages@f27bcc15848fdcdcc02f01754eb838e44bcf389b # v1


integration-test

name: integration-test

on:
  push:
    branches:
      - main
  pull_request:

env:
  GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx6g -Dorg.gradle.daemon=false -Dkotlin.incremental=false"

jobs:
  test:
    runs-on: macos-latest

    steps:
      - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
      - uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
        with:
          distribution: 'zulu'
          java-version: 19

      - name: Gradle cache
        uses: gradle/gradle-build-action@a8f75513eafdebd8141bd1cd4e30fcd194af8dfa # v2

      - name: integration test
        id: integration-test
        run: |
          cd include-build
          ./gradlew roborazzi-gradle-plugin:check --stacktrace

      - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
        if: ${{ always() }}
        with:
          name: test-reports
          path: include-build/roborazzi-gradle-plugin/build/reports
          retention-days: 30

      - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
        if: ${{ always() }}
        with:
          name: test-test-results
          path: include-build/roborazzi-gradle-plugin/build/test-results
          retention-days: 30


release

name: release

on:
  push:
    tags:
      - '**'

env:
  GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx6g -Dorg.gradle.daemon=false -Dkotlin.incremental=false"

jobs:
  publish:
    environment:
      name: release
    runs-on: macos-latest

    steps:
      - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
      - uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
        with:
          distribution: 'zulu'
          java-version: 19

      - name: Build and publish artifacts
        uses: nick-fields/retry@14672906e672a08bd6eeb15720e9ed3ce869cdd4 # v2.9.0
        env:
          ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
          ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
          ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ARTIFACT_SIGNING_PRIVATE_KEY }}
          ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.ARTIFACT_SIGNING_PRIVATE_KEY_ID }}
          ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.ARTIFACT_SIGNING_PRIVATE_KEY_PASSWORD }}
        with:
          max_attempts: 3
          retry_on: error
          timeout_minutes: 20
          command: |
            ./gradlew publish --rerun-tasks --stacktrace --no-configuration-cache
            cd include-build
            ./gradlew publish --rerun-tasks --stacktrace --no-configuration-cache


plain-tests

name: plain-tests

on:
  push:
    branches:
      - main
  pull_request:

env:
  GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx6g -Dorg.gradle.daemon=false -Dkotlin.incremental=false"

jobs:
  test:
    runs-on: macos-latest

    steps:
      - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
      - uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
        with:
          distribution: 'zulu'
          java-version: 19

      - name: Gradle cache
        uses: gradle/gradle-build-action@a8f75513eafdebd8141bd1cd4e30fcd194af8dfa # v2

      - name: tests
        id: test
        run: |
          ./gradlew test --stacktrace -x testReleaseUnitTest

      - name: include build tests
        id: include-build-test
        run: |
          cd include-build
          ./gradlew test jvmTest --stacktrace -x testReleaseUnitTest

      - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
        if: ${{ always() }}
        with:
          name: tests-reports
          path: |
            **/build/reports
            **/build/outputs/roborazzi
          retention-days: 30


Release

on:
  push:
    tags:
      - '*'

name: Release

jobs:
  test:
    name: Build and upload release
    runs-on: ubuntu-latest
    steps:
      - name: Check out code
        uses: actions/checkout@v4

      - name: Set up Java environment
        uses: actions/setup-java@v4
        with:
          java-version: 17
          distribution: 'zulu'
          cache: 'gradle'
      - name: Decrypt keystore
        run: openssl aes-256-cbc -K  ${{ secrets.encrypted_53968681344a_key }} -iv  ${{ secrets.encrypted_53968681344a_iv }} -in _ci/keystore.jks.enc -out _ci/keystore.jks -d
      - name: Extract version code
        run: echo "VERSION_CODE=$(grep -o "^\s*versionCode\s*=\s*[0-9]\+" app/build.gradle.kts | awk '{ print $3 }' | tr -d \''"\\')" >> $GITHUB_ENV

      - name: Build app release
        env:
          GOINGELECTRIC_API_KEY: ${{ secrets.GOINGELECTRIC_API_KEY }}
          OPENCHARGEMAP_API_KEY: ${{ secrets.OPENCHARGEMAP_API_KEY }}
          CHARGEPRICE_API_KEY: ${{ secrets.CHARGEPRICE_API_KEY }}
          MAPBOX_API_KEY: ${{ secrets.MAPBOX_API_KEY }}
          JAWG_API_KEY: ${{ secrets.JAWG_API_KEY }}
          ARCGIS_API_KEY: ${{ secrets.ARCGIS_API_KEY }}
          GOOGLE_MAPS_API_KEY: ${{ secrets.GOOGLE_MAPS_API_KEY }}
          FRONYX_API_KEY: ${{ secrets.FRONYX_API_KEY }}
          ACRA_CRASHREPORT_CREDENTIALS: ${{ secrets.ACRA_CRASHREPORT_CREDENTIALS }}
          KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
          KEYSTORE_ALIAS: ${{ secrets.KEYSTORE_ALIAS }}
          KEYSTORE_ALIAS_PASSWORD: ${{ secrets.KEYSTORE_ALIAS_PASSWORD }}
        run: ./gradlew assembleRelease --no-daemon

      - name: release
        uses: actions/create-release@v1
        id: create_release
        with:
          draft: false
          prerelease: false
          release_name: ${{ steps.version.outputs.version }}
          tag_name: ${{ github.ref }}
          body_path: fastlane/metadata/android/en-US/changelogs/${{ env.VERSION_CODE }}.txt
        env:
          GITHUB_TOKEN: ${{ github.token }}

      - name: upload Google artifact
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ github.token }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: app/build/outputs/apk/googleNormal/release/app-google-normal-release.apk
          asset_name: app-google-normal-release.apk
          asset_content_type: application/vnd.android.package-archive
      - name: upload Foss artifact
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ github.token }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: app/build/outputs/apk/fossNormal/release/app-foss-normal-release.apk
          asset_name: app-foss-normal-release.apk
          asset_content_type: application/vnd.android.package-archive
      - name: upload Google Automotive artifact
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ github.token }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: app/build/outputs/apk/googleAutomotive/release/app-google-automotive-release.apk
          asset_name: app-google-automotive-release.apk
          asset_content_type: application/vnd.android.package-archive
      - name: upload Foss Automotive artifact
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ github.token }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: app/build/outputs/apk/fossAutomotive/release/app-foss-automotive-release.apk
          asset_name: app-foss-automotive-release.apk
          asset_content_type: application/vnd.android.package-archive


Tests

on:
  pull_request:
  push:
    branches:
      - '*'

name: Tests

jobs:

  test:
    name: Build and Test (${{ matrix.buildvariant }})
    runs-on: ubuntu-latest
    strategy:
      matrix:
        buildvariant: [ FossNormal, FossAutomotive, GoogleNormal, GoogleAutomotive ]
    steps:
      - name: Check out code
        uses: actions/checkout@v4

      - name: Set up Java environment
        uses: actions/setup-java@v4
        with:
          java-version: 17
          distribution: 'zulu'
          cache: 'gradle'

      - name: Copy apikeys.xml
        run: cp .github/workflows/apikeys-ci.xml app/src/main/res/values/apikeys.xml

      - name: Build app
        run: ./gradlew assemble${{ matrix.buildvariant }}Debug --no-daemon
      - name: Run unit tests
        run: ./gradlew test${{ matrix.buildvariant }}DebugUnitTest --no-daemon
      - name: Run Android Lint
        run: ./gradlew lint${{ matrix.buildvariant }}Debug --no-daemon
      - name: Check licenses
        run: ./gradlew exportLibraryDefinitions --no-daemon


Build project

name: Build project

on:
  pull_request:
    branches:
      - master
  push:
    branches:
      - master

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - uses: actions/setup-java@v4
        with:
          distribution: 'temurin'
          java-version: 21

      - name: Write Gradle build properties to `~/.gradle/gradle.properties`
        run: |
          mkdir -p ~/.gradle
          printf "org.gradle.jvmargs=-Xmx3G -XX:+UseParallelGC\n" >> ~/.gradle/gradle.properties
        shell: bash

      - uses: gradle/actions/setup-gradle@v3

      - run: ./gradlew projectCodestyle

      - run: ./gradlew assemble

      - run: ./gradlew check

      - run: ./gradlew projectCoverage

      - name: Upload test results
        if: ${{ always() }}
        uses: actions/upload-artifact@v4
        with:
          name: test-results
          path: "${{ github.workspace }}/**/build/reports/tests"

      - name: Upload jacoco report
        uses: actions/upload-artifact@v4
        with:
          name: jacoco-report
          path: "${{ github.workspace }}/**/build/reports/jacoco"

      - run: ./gradlew publishToMavenLocal

      - run: ./gradlew publishPlugins -m

      - run: git diff --exit-code

      - name: Publish to Github Package Registry
        run: ./gradlew publish --continue
        if: github.repository == 'usefulness/easylauncher-gradle-plugin' && github.event_name == 'push'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  build-all-sample-apps:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        javaVersion: [ 17, 21 ]
        gradle: [ release-candidate ]
        agp: [ alpha, beta, stable ]
        include:
          - javaVersion: 17
            gradle: "8.2.1"
            agp: 8.2.2
          - javaVersion: 17
            gradle: current
            agp: 8.2.2
          - javaVersion: 19
            gradle: current
            agp: 8.2.2
          - javaVersion: 21
            gradle: current
            agp: stable

    name: Run Gradle-${{ matrix.gradle }}, AGP-${{ matrix.agp }}, Java-${{ matrix.javaVersion }}
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - uses: actions/setup-java@v4
        with:
          distribution: 'temurin'
          java-version: ${{ matrix.javaVersion }}

      - name: Write Gradle build properties to `~/.gradle/gradle.properties`
        run: |
          mkdir -p ~/.gradle
          printf "org.gradle.jvmargs=-Xmx3G -XX:+UseParallelGC\n" >> ~/.gradle/gradle.properties
        shell: bash

      - uses: gradle/actions/setup-gradle@v3

      - name: Pre-compile plugin
        run: ./gradlew publishToMavenLocal -Pgroup=com.project.starter.local

      - id: agp-version-finder
        uses: usefulness/agp-version-finder-action@v1
        with:
          version-to-resolve: ${{ matrix.agp }}

      - uses: gradle/actions/setup-gradle@v3
        with:
          gradle-version: ${{ matrix.gradle }}

      - run: gradle assemble lint -PuseMavenLocal -PagpVersion=${{ steps.agp-version-finder.outputs.resolved-version }}
        working-directory: sample

  build-sample-apps-with-configuration-cache:
    runs-on: ${{ matrix.os }}
    name: Configuration Cache Java-${{ matrix.javaVersion }} OS-${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        javaVersion: [ 17, 21 ]
        os: [ ubuntu-latest, windows-latest, macos-latest ]

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - uses: actions/setup-java@v4
        with:
          distribution: 'temurin'
          java-version: ${{ matrix.javaVersion }}

      - name: Write Gradle build properties to `~/.gradle/gradle.properties`
        run: |
          mkdir -p ~/.gradle
          printf "org.gradle.jvmargs=-Xmx3G -XX:+UseParallelGC\n" >> ~/.gradle/gradle.properties
        shell: bash

      - uses: gradle/actions/setup-gradle@v3
        with:
          gradle-version: current

      - run: gradle assembleDebug --configuration-cache
        working-directory: sample

  icons-test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        apiVersion: [ 28 ]

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - uses: actions/setup-java@v4
        with:
          distribution: 'temurin'
          java-version: 21

      - name: Write Gradle build properties to `~/.gradle/gradle.properties`
        run: |
          mkdir -p ~/.gradle
          printf "org.gradle.jvmargs=-Xmx3G -XX:+UseParallelGC\n" >> ~/.gradle/gradle.properties
        shell: bash

      - uses: gradle/actions/setup-gradle@v3

      - name: Enable KVM group perms
        run: |
          echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
          sudo udevadm control --reload-rules
          sudo udevadm trigger --name-match=kvm

      - name: run tests
        uses: reactivecircus/android-emulator-runner@v2
        with:
          api-level: ${{ matrix.apiVersion }}
          profile: pixel_xl
          target: google_apis
          arch: x86
          disable-spellchecker: true
          working-directory: ./sample
          script: ./icon_check.sh

      - name: Upload failed screenshots
        if: ${{ failure() }}
        uses: actions/upload-artifact@v4
        with:
          name: failedScreenshots
          path: "**/reports/failedScreenshots"

      - name: Upload failed screenshots
        if: ${{ failure() }}
        uses: actions/upload-artifact@v4
        with:
          name: tests
          path: "**/reports/androidTests"

      - name: Upload screenshot tests result
        uses: actions/upload-artifact@v4
        if: ${{ always() }}
        with:
          name: screenshots
          path: "**/reports/screenshots**AndroidTest*/"


Generate dependency diff

name: Generate dependency diff

on:
  pull_request:

jobs:
  generate-diff:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - uses: actions/setup-java@v4
        with:
          distribution: 'temurin'
          java-version: 21

      - name: Write Gradle build properties to `~/.gradle/gradle.properties`
        run: |
          mkdir -p ~/.gradle
          printf "org.gradle.jvmargs=-Xmx3G -XX:+UseParallelGC\n" >> ~/.gradle/gradle.properties
        shell: bash

      - uses: gradle/actions/setup-gradle@v3

      - id: dependency-diff
        name: Generate dependency diff
        uses: usefulness/dependency-tree-diff-action@v2
        with:
          configuration: 'runtimeClasspath'
          project: 'easylauncher'

      - uses: peter-evans/find-comment@v3
        id: find_comment
        with:
          issue-number: ${{ github.event.pull_request.number }}
          body-includes: Dependency diff

      - uses: peter-evans/create-or-update-comment@v4
        if: ${{ steps.dependency-diff.outputs.text-diff != null || steps.find_comment.outputs.comment-id != null }}
        with:
          body: |
            Dependency diff:
              ```diff
              ${{ steps.dependency-diff.outputs.text-diff }}
              ```
          edit-mode: replace
          comment-id: ${{ steps.find_comment.outputs.comment-id }}
          issue-number: ${{ github.event.pull_request.number }}
          token: ${{ secrets.GITHUB_TOKEN }}


Publish Project to Gradle Plugin Portal

name: Publish Project to Gradle Plugin Portal

on:
  push:
    tags:
      - 'v*'

jobs:
  build:
    runs-on: ubuntu-latest
    if: github.repository == 'usefulness/easylauncher-gradle-plugin'
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - uses: actions/setup-java@v4
        with:
          distribution: 'temurin'
          java-version: 21

      - name: Write Gradle build properties to `~/.gradle/gradle.properties`
        run: |
          mkdir -p ~/.gradle
          printf "org.gradle.jvmargs=-Xmx3G -XX:+UseParallelGC\n" >> ~/.gradle/gradle.properties
        shell: bash

      - uses: gradle/actions/setup-gradle@v3

      - run: ./gradlew assemble

      - name: Publish to Gradle Plugin Portal
        run: ./gradlew publishPlugins -Pgradle.publish.key=${{ secrets.gradle_publish_key }} -Pgradle.publish.secret=${{ secrets.gradle_publish_secret }}

      - name: Publish to Github Package Registry
        run: ./gradlew publish --continue || true
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


Java CI with Gradle

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Java CI with Gradle

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

permissions:
  contents: read

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3.5.2
    - name: Set up JDK 17
      uses: actions/setup-java@v4.0.0
      with:
        java-version: '17'
        distribution: 'temurin'
    - name: Grant execute permission for gradlew
      run: chmod +x gradlew
    - name: Build with Gradle
      uses: gradle/gradle-build-action@v2.11.0
      with:
        arguments: build --stacktrace
    - name: Upload Artifact
      uses: actions/upload-artifact@v4.0.0
      with:
        name: compiled
        path: build/libs/*.jar


Collect samples CRON

name: Collect samples CRON

on:
  schedule:
   - cron: '30 18 * * 1,4' # 18:30 UTC Mon, Thu

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        include:
          - repo: 'https://github.com/JetBrains/kotlin-web-site'
            filter: '#tag="code" & kotlin-runnable="true" & !validate="false"'
            path: 'src/test/resources/test-compile-data/jvm/kotlin-web-site'
          - repo: 'https://github.com/Kotlin/kotlin-by-example'
            filter: '#tag="code" & class="language-run-kotlin" & !validate="false"'
            path: 'src/test/resources/test-compile-data/jvm/kotlin-by-example'
          - repo: 'https://github.com/kotlin-hands-on/hands-on'
            filter: '#tag="code" & class="language-run-kotlin" & !validate="false"'
            path: 'src/test/resources/test-compile-data/jvm/kotlin-hands-on'
    steps:
      - name: Set up JDK
        uses: actions/setup-java@v3
        with:
          java-version: '17'
          distribution: 'adopt'
      - name: Run a verifier
        uses: AlexanderPrendota/kotlin-samples-verifier@master
        with:
          io-event: '' #reset default behavior
          repository: '${{ matrix.repo }}'
          verify-branch: 'master'
          push-repository: 'https://github.com/${{github.repository}}'
          tag-filter: '${{ matrix.filter }}'
          push-path: '${{ matrix.path }}'
          username: '${{ secrets.COMPILE_SERVICE_PUSHER }}' #token with an access to create PR in push-repository


Docker Image CI

name: Docker Image CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:

  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
    - name: Build the Docker image
      run: ./docker-image-build.sh


Java CI

name: Java CI

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
    - name: Set up JDK 17
      uses: actions/setup-java@v3
      with:
        java-version: '17'
        distribution: 'adopt'
    - name: Grant execute permission for gradlew
      run: chmod +x gradlew
    - name: Build with Gradle
      run: ./gradlew build


Test Gradle plugin

name: Test Gradle plugin
on:
  pull_request:
    paths:
      - 'gradle-plugins/**'
      - '.github/workflows/gradle-plugin.yml'
  push:
    branches:
      - master
    paths:
      - 'gradle-plugins/**'
      - '.github/workflows/gradle-plugin.yml'

jobs:
  test-gradle-plugin:
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-20.04, macos-14, windows-2022]
        gradle: [7.4, 8.7]
        agp: [8.1.0, 8.4.0]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-java@v3
        with:
          distribution: 'corretto'
          java-version: '17'
      - name: Test Gradle plugin
        shell: bash
        run: |
          cd gradle-plugins
          ./gradlew assemble
          ./gradlew --continue :preview-rpc:test :compose:test ':compose:test-Gradle(${{ matrix.gradle }})-Agp(${{ matrix.agp }})'
      - name: Upload Reports
        uses: actions/upload-artifact@v2
        with:
          name: Test-Reports
          path: gradle-plugins/compose/build/reports
        if: always()
      - name: Print summary
        shell: bash
        if: always()
        run: |
          cd gradle-plugins/compose/build/test-summary
          for SUMMARY_FILE in `find . -name "*.md"`; do
            FILE_NAME=`basename $SUMMARY_FILE`
            echo "## $FILE_NAME" >> $GITHUB_STEP_SUMMARY
            cat $SUMMARY_FILE >> $GITHUB_STEP_SUMMARY
          done


# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions

# Yes, booleans used here are 'strings' despite the type of input being declared as boolean because… well, see here:
# https://docs.github.com/en/actions/learn-github-actions/expressions

# https://github.com/marketplace/actions/gradle-build-action
name: Check build and tests of plugins and samples
on:
  workflow_dispatch:
    inputs:
      check-for-memory-leaks:
        description: "Check for memory leaks"
        required: true
        type: boolean
        default: true
      run-refreshVersions-task:
        description: "Run the refreshVersions task"
        required: true
        type: boolean
        default: false
      sample-kotlin:
        description: "Enable sample-kotlin"
        required: true
        type: boolean
        default: true
      sample-groovy:
        description: "Enable sample-groovy"
        required: true
        type: boolean
        default: true
      sample-multi-modules:
        description: "Enable sample-multi-modules"
        required: true
        type: boolean
        default: true
      sample-kotlin-js:
        description: "Enable sample-kotlin-js"
        required: true
        type: boolean
        default: true
      sample-android:
        description: "Enable sample-android"
        required: true
        type: boolean
        default: false
      run-on:
        type: choice
        description: "Where to run this workflow"
        default: 'ubuntu-latest'
        required: true
        options:
          - windows-2022
          - windows-2019
          - windows-latest
          - macos-12
          - macos-11
          - macos-10.5
          - macos-latest
          - ubuntu-22.04
          - ubuntu-20.04
          - ubuntu-18.04
          - ubuntu-latest
  pull_request:
    paths:
      - 'plugins/**'
      - 'sample-kotlin/**'
      - 'sample-groovy/**'
      - '!**.md'
      - '!.editorconfig'
      - '!**/.gitignore'
      - '!**.adoc'
      - '!docs/**'
  push:
    branches:
      - main
    paths:
      - 'plugins/**'
      - 'sample-kotlin/**'
      - 'sample-groovy/**'
      - '!**.md'
      - '!.editorconfig'
      - '!**/.gitignore'
      - '!**.adoc'
      - '!docs/**'
jobs:
  check-all:
    env:
      GPG_key_id: ${{ secrets.GPG_KEY_ID }}
      GPG_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
      GPG_private_password: ${{ secrets.GPG_PRIVATE_PASSWORD }}
    runs-on: ${{ github.event.inputs.run-on || 'ubuntu-latest' }}
    steps:
      - name: "Enable long paths for git Windows"
        if: ${{ runner.os == 'Windows' }}
        run: git config --global core.longpaths true
      - uses: actions/checkout@v2
      - name: "Configure JDK"
        uses: actions/setup-java@v3
        with:
          distribution: 'temurin'
          java-version: '17'
      - name: "Check plugins and publish them to MavenLocal"
        uses: gradle/gradle-build-action@v2
        with:
          gradle-executable: plugins/gradlew
          build-root-directory: plugins
          arguments: check publishToMavenLocal --stacktrace --daemon
      - name: "Configure JDK for old Gradle"
        uses: actions/setup-java@v3
        with:
          distribution: 'temurin'
          java-version: '11'
      - name: "Run refreshVersions on sample-kotlin"
        if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.sample-kotlin == 'true' && github.event.inputs.run-refreshVersions-task == 'true' }}
        uses: gradle/gradle-build-action@v2
        with:
          gradle-executable: sample-kotlin/gradlew
          build-root-directory: sample-kotlin
          arguments: refreshVersions --stacktrace --daemon
      - name: "Check sample-kotlin"
        if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.sample-kotlin == 'true' }}
        uses: gradle/gradle-build-action@v2
        with:
          gradle-executable: sample-kotlin/gradlew
          build-root-directory: sample-kotlin
          arguments: check --stacktrace --configuration-cache --daemon
      - name: "Configure JDK back for new Gradle"
        uses: actions/setup-java@v3
        with:
          distribution: 'temurin'
          java-version: '17'
      - name: "Check for memory leaks"
        if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.check-for-memory-leaks == 'true' }}
        working-directory: sample-groovy
        run: ./counted-stress-test.sh 10 ./gradlew --daemon -Dorg.gradle.jvmargs="-Xmx150M"
      - name: "Run refreshVersions on sample-groovy"
        if: ${{ github.event.inputs.sample-groovy == 'true' && github.event.inputs.run-refreshVersions-task == 'true' }}
        uses: gradle/gradle-build-action@v2
        with:
          gradle-executable: sample-groovy/gradlew
          build-root-directory: sample-groovy
          arguments: refreshVersions --stacktrace --daemon
      - name: "Check sample-groovy"
        if: ${{ github.event.inputs.sample-groovy == 'true' }}
        uses: gradle/gradle-build-action@v2
        with:
          gradle-executable: sample-groovy/gradlew
          build-root-directory: sample-groovy
          arguments: check --stacktrace --daemon
      - name: "Check buildSrc of sample-groovy (simulates IDE Gradle sync)"
        if: ${{ github.event.inputs.sample-groovy == 'true' }}
        uses: gradle/gradle-build-action@v2
        with:
          gradle-executable: sample-groovy/gradlew
          build-root-directory: sample-groovy/buildSrc
          arguments: help --stacktrace --daemon
      - name: "Run refreshVersions on sample-multi-modules"
        if: ${{ github.event.inputs.sample-multi-modules == 'true' && github.event.inputs.run-refreshVersions-task == 'true' }}
        uses: gradle/gradle-build-action@v2
        with:
          gradle-executable: sample-multi-modules/gradlew
          build-root-directory: sample-multi-modules
          arguments: refreshVersions --stacktrace --daemon
      - name: "Check sample-multi-modules"
        if: ${{ github.event.inputs.sample-multi-modules == 'true' }}
        uses: gradle/gradle-build-action@v2
        with:
          gradle-executable: sample-multi-modules/gradlew
          build-root-directory: sample-multi-modules
          arguments: check --stacktrace --daemon
      - name: "Run refreshVersions on sample-kotlin-js"
        if: ${{ github.event.inputs.sample-kotlin-js == 'true' && github.event.inputs.run-refreshVersions-task == 'true' }}
        uses: gradle/gradle-build-action@v2
        with:
          gradle-executable: sample-kotlin-js/gradlew
          build-root-directory: sample-kotlin-js
          arguments: refreshVersions --stacktrace --daemon
      - name: "Check sample-kotlin-js"
        if: ${{ github.event.inputs.sample-kotlin-js == 'true' }}
        uses: gradle/gradle-build-action@v2
        with:
          gradle-executable: sample-kotlin-js/gradlew
          build-root-directory: sample-kotlin-js
          arguments: check --stacktrace --daemon
      - name: "Run refreshVersions on sample-android"
        if: ${{ github.event.inputs.sample-android == 'true' && github.event.inputs.run-refreshVersions-task == 'true' }}
        uses: gradle/gradle-build-action@v2
        with:
          gradle-executable: sample-android/gradlew
          build-root-directory: sample-android
          arguments: refreshVersions --stacktrace --daemon
      - name: "Check sample-android"
        if: ${{ github.event.inputs.sample-android == 'true' }}
        uses: gradle/gradle-build-action@v2
        with:
          gradle-executable: sample-android/gradlew
          build-root-directory: sample-android
          arguments: check --stacktrace --daemon
      - name: "Stop Gradle daemon"
        working-directory: plugins
        run: ./gradlew --stop


Publish plugins

# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions
name: Publish plugins
on:
  workflow_dispatch:
  pull_request:
    types: [opened]
    paths:
      - 'plugins/version.txt'
    branches:
      - release
jobs:
  gradle-plugins-publishing:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-java@v2
        with:
          distribution: 'temurin'
          java-version: 17
      - uses: gradle/gradle-build-action@v2
        with:
          gradle-executable: plugins/gradlew
          build-root-directory: plugins
          arguments: publishPlugins --scan -Pgradle.publish.key=${{ secrets.gradle_publish_key }} -Pgradle.publish.secret=${{ secrets.gradle_publish_secret }}
        env:
          sonatype_username: ${{ secrets.SONATYPE_USERNAME }}
          sonatype_password: ${{ secrets.SONATYPE_PASSWORD }}
          GPG_key_id: ${{ secrets.GPG_KEY_ID }}
          GPG_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
          GPG_private_password: ${{ secrets.GPG_PRIVATE_PASSWORD }}


Publish MkDocs website to GitHub pages

name: Publish MkDocs website to GitHub pages
permissions:
  contents: write
on:
  push:
    branches:
      - release
  workflow_dispatch:
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: ./docs/DocsCopier.main.kts
      - uses: actions/setup-python@v2
        with:
          python-version: 3.x
      - run: pip install -r docs/requirements.txt
      - run: mkdocs gh-deploy --force


Build MkDocs website as artifacts

name: Build MkDocs website as artifacts
on:
  push:
    branches-ignore:
      - release
    paths:
      - 'docs/**'
      - 'mkdocs.yml'
      - 'CHANGELOG.md'
      # Any additional files/dirs that take part in updating the website must be added here.
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: ./docs/DocsCopier.main.kts
      - uses: actions/setup-python@v2
        with:
          python-version: 3.x
      - run: pip install -r docs/requirements.txt
      - run: mkdocs build --site-dir public
      - uses: actions/upload-artifact@v2
        with:
          name: docs-static-website
          path: public


Publish to Sonatype Snapshots

name: Publish to Sonatype Snapshots
on:
  workflow_dispatch:
jobs:
  build-and-upload:
    name: Build and upload
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2.3.4
      - name: Build and upload artifacts
        run: cd plugins && ./gradlew publishAllPublicationsToSonatypeSnapshotsRepository
        env:
          sonatype_username: ${{ secrets.SONATYPE_USERNAME }}
          sonatype_password: ${{ secrets.SONATYPE_PASSWORD }}
          GPG_key_id: ${{ secrets.GPG_KEY_ID }}
          GPG_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
          GPG_private_password: ${{ secrets.GPG_PRIVATE_PASSWORD }}


Test/Build Android

name: Test/Build Android

on:
  pull_request:
    branches: [main]
  push:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest
    timeout-minutes: 30

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up JDK 17
        uses: actions/setup-java@v4
        with:
          distribution: 'temurin'
          java-version: 17

      - name: Cache gradle
        uses: actions/cache@v3
        with:
          path: ~/.gradle/caches
          key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
          restore-keys: |
            ${{ runner.os }}-gradle-

      - name: Linter (gradle)
        run: ./gradlew spotlessCheck

      - name: Test (gradle)
        run: ./gradlew test --no-daemon

      - name: Android Test Report
        uses: asadmansr/android-test-report-action@v1.2.0
        if: ${{ always() }} # IMPORTANT: run Android Test Report regardless

      - name: Build APK (gradle)
        run: ./gradlew assembleDebug --no-daemon

      - name: Upload APK
        uses: actions/upload-artifact@v2
        with:
          name: Debug APK
          path: app/build/outputs/apk/debug/app-debug.apk

      - name: Upload Test Results
        uses: actions/upload-artifact@v2
        with:
          name: Build Reports
          path: app/build/reports


Create Release Assets

name: Create Release Assets

on:
  push:
    tags:
    - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up JDK 17
        uses: actions/setup-java@v4
        with:
          distribution: 'temurin'
          java-version: 17

      - name: Cache gradle
        uses: actions/cache@v3
        with:
          path: ~/.gradle/caches
          key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
          restore-keys: |
            ${{ runner.os }}-gradle-

      - name: Build AAB
        run: ./gradlew clean bundleRelease --stacktrace

      - name: Sign AAB (Google Play)
        uses: r0adkll/sign-android-release@v1
        with:
          releaseDirectory: app/build/outputs/bundle/playRelease
          signingKeyBase64: ${{ secrets.SIGNING_KEY }}
          alias: ${{ secrets.KEY_ALIAS }}
          keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
          keyPassword: ${{ secrets.KEY_PASSWORD }}
        env:
          # override default build-tools version (29.0.3) -- optional
          BUILD_TOOLS_VERSION: "34.0.0"

      - name: Sign AAB (F-Droid)
        uses: r0adkll/sign-android-release@v1
        with:
          releaseDirectory: app/build/outputs/bundle/fdroidRelease
          signingKeyBase64: ${{ secrets.SIGNING_KEY }}
          alias: ${{ secrets.KEY_ALIAS }}
          keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
          keyPassword: ${{ secrets.KEY_PASSWORD }}
        env:
          # override default build-tools version (29.0.3) -- optional
          BUILD_TOOLS_VERSION: "34.0.0"

      - name: Build APK
        run: ./gradlew assembleRelease --stacktrace

      - name: Sign APK (Google Play)
        uses: r0adkll/sign-android-release@v1
        with:
          releaseDirectory: app/build/outputs/apk/play/release
          signingKeyBase64: ${{ secrets.SIGNING_KEY }}
          alias: ${{ secrets.KEY_ALIAS }}
          keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
          keyPassword: ${{ secrets.KEY_PASSWORD }}
        env:
          # override default build-tools version (29.0.3) -- optional
          BUILD_TOOLS_VERSION: "34.0.0"

      - name: Sign APK (F-Droid)
        uses: r0adkll/sign-android-release@v1
        with:
          releaseDirectory: app/build/outputs/apk/fdroid/release
          signingKeyBase64: ${{ secrets.SIGNING_KEY }}
          alias: ${{ secrets.KEY_ALIAS }}
          keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
          keyPassword: ${{ secrets.KEY_PASSWORD }}
        env:
          # override default build-tools version (29.0.3) -- optional
          BUILD_TOOLS_VERSION: "34.0.0"

      - name: Create Release
        id: create_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          release_name: Release ${{ github.ref }}
          draft: false
          prerelease: true

      # Google Play APK
      - name: Upload Play APK Universal Asset
        id: upload-release-asset-play-universal-apk
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: app/build/outputs/apk/play/release/app-play-universal-release-unsigned-signed.apk
          asset_name: amethyst-googleplay-universal-${{ github.ref_name }}.apk
          asset_content_type: application/zip

      - name: Upload Play APK x86 Asset
        id: upload-release-asset-play-x86-apk
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: app/build/outputs/apk/play/release/app-play-x86-release-unsigned-signed.apk
          asset_name: amethyst-googleplay-x86-${{ github.ref_name }}.apk
          asset_content_type: application/zip

      - name: Upload Play APK x86_64 Asset
        id: upload-release-asset-play-x86-64-apk
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: app/build/outputs/apk/play/release/app-play-x86_64-release-unsigned-signed.apk
          asset_name: amethyst-googleplay-x86_64-${{ github.ref_name }}.apk
          asset_content_type: application/zip

      - name: Upload Play APK arm64-v8a Asset
        id: upload-release-asset-play-arm64-v8a-apk
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: app/build/outputs/apk/play/release/app-play-arm64-v8a-release-unsigned-signed.apk
          asset_name: amethyst-googleplay-arm64-v8a-${{ github.ref_name }}.apk
          asset_content_type: application/zip

      - name: Upload Play APK armeabi-v7a Asset
        id: upload-release-asset-play-armeabi-v7a-apk
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: app/build/outputs/apk/play/release/app-play-armeabi-v7a-release-unsigned-signed.apk
          asset_name: amethyst-googleplay-armeabi-v7a-${{ github.ref_name }}.apk
          asset_content_type: application/zip

      # F-Droid APK
      - name: Upload F-Droid APK Universal Asset
        id: upload-release-asset-fdroid-universal-apk
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: app/build/outputs/apk/fdroid/release/app-fdroid-universal-release-unsigned-signed.apk
          asset_name: amethyst-fdroid-universal-${{ github.ref_name }}.apk
          asset_content_type: application/zip

      - name: Upload F-Droid APK x86 Asset
        id: upload-release-asset-fdroid-x86-apk
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: app/build/outputs/apk/fdroid/release/app-fdroid-x86-release-unsigned-signed.apk
          asset_name: amethyst-fdroid-x86-${{ github.ref_name }}.apk
          asset_content_type: application/zip

      - name: Upload F-Droid APK x86_64 Asset
        id: upload-release-asset-fdroid-x86-64-apk
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: app/build/outputs/apk/fdroid/release/app-fdroid-x86_64-release-unsigned-signed.apk
          asset_name: amethyst-fdroid-x86_64-${{ github.ref_name }}.apk
          asset_content_type: application/zip

      - name: Upload F-Droid APK arm64-v8a Asset
        id: upload-release-asset-fdroid-arm64-v8a-apk
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: app/build/outputs/apk/fdroid/release/app-fdroid-arm64-v8a-release-unsigned-signed.apk
          asset_name: amethyst-fdroid-arm64-v8a-${{ github.ref_name }}.apk
          asset_content_type: application/zip

      - name: Upload F-Droid APK armeabi-v7a Asset
        id: upload-release-asset-fdroid-armeabi-v7a-apk
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: app/build/outputs/apk/fdroid/release/app-fdroid-armeabi-v7a-release-unsigned-signed.apk
          asset_name: amethyst-fdroid-armeabi-v7a-${{ github.ref_name }}.apk
          asset_content_type: application/zip

      # Google Play AAB
      - name: Upload Google Play AAB Asset
        id: upload-release-asset-play-aab
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: app/build/outputs/bundle/playRelease/app-play-release.aab
          asset_name: amethyst-googleplay-${{ github.ref_name }}.aab
          asset_content_type: application/zip

      # FDroid AAB
      - name: Upload F-Droid AAB Asset
        id: upload-release-asset-fdroid-aab
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: app/build/outputs/bundle/fdroidRelease/app-fdroid-release.aab
          asset_name: amethyst-fdroid-${{ github.ref_name }}.aab
          asset_content_type: application/zip


Crowdin Action

name: Crowdin Action

on:
  push:
    # paths: ["app/src/main/res/**/strings.xml"] // removes filter to allow downloads at any moment.
    branches: [ main ]

jobs:
  synchronize-with-crowdin:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: crowdin action
        uses: crowdin/github-action@v1
        with:
          upload_sources: true
          upload_translations: true
          download_translations: true
          localization_branch_name: l10n_crowdin_translations
          create_pull_request: true
          pull_request_title: 'New Crowdin Translations'
          pull_request_body: 'New Crowdin translations by [Crowdin GH Action](https://github.com/crowdin/github-action)'
          pull_request_base_branch_name: 'main'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
          CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}


Build

# This file was generated using Kotlin DSL (.github/workflows/build.main.kts).
# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file.
# Generated with https://github.com/typesafegithub/github-workflows-kt

name: 'Build'
on:
  push:
    branches:
    - 'main'
  pull_request: {}
jobs:
  check_yaml_consistency:
    name: 'Check YAML consistency'
    runs-on: 'ubuntu-latest'
    steps:
    - id: 'step-0'
      name: 'Check out'
      uses: 'actions/checkout@v4'
    - id: 'step-1'
      name: 'Execute script'
      run: 'rm ''.github/workflows/build.yaml'' && ''.github/workflows/build.main.kts'''
    - id: 'step-2'
      name: 'Consistency check'
      run: 'git diff --exit-code ''.github/workflows/build.yaml'''
  build-for-UbuntuLatest:
    runs-on: 'ubuntu-latest'
    needs:
    - 'check_yaml_consistency'
    steps:
    - id: 'step-0'
      uses: 'actions/checkout@v4'
    - id: 'step-1'
      name: 'Set up JDK'
      uses: 'actions/setup-java@v4'
      with:
        java-version: '11'
        distribution: 'zulu'
    - id: 'step-2'
      uses: 'gradle/actions/setup-gradle@v3'
      with:
        cache-encryption-key: '${{ secrets.GRADLE_ENCRYPTION_KEY }}'
    - id: 'step-3'
      name: 'Build'
      env:
        GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
      run: './gradlew build'
  build-for-Windows2022:
    runs-on: 'windows-2022'
    needs:
    - 'check_yaml_consistency'
    steps:
    - id: 'step-0'
      uses: 'actions/checkout@v4'
    - id: 'step-1'
      name: 'Set up JDK'
      uses: 'actions/setup-java@v4'
      with:
        java-version: '11'
        distribution: 'zulu'
    - id: 'step-2'
      uses: 'gradle/actions/setup-gradle@v3'
      with:
        cache-encryption-key: '${{ secrets.GRADLE_ENCRYPTION_KEY }}'
    - id: 'step-3'
      name: 'Build'
      env:
        GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
      run: './gradlew build'
  publish-snapshot:
    name: 'Publish snapshot'
    runs-on: 'ubuntu-latest'
    needs:
    - 'check_yaml_consistency'
    env:
      ORG_GRADLE_PROJECT_sonatypeUsername: '${{ secrets.ORG_GRADLE_PROJECT_SONATYPEUSERNAME }}'
      ORG_GRADLE_PROJECT_sonatypePassword: '${{ secrets.ORG_GRADLE_PROJECT_SONATYPEPASSWORD }}'
    if: '${{ github.ref == ''refs/heads/main'' }}'
    steps:
    - id: 'step-0'
      uses: 'actions/checkout@v4'
    - id: 'step-1'
      name: 'Set up JDK'
      uses: 'actions/setup-java@v4'
      with:
        java-version: '11'
        distribution: 'zulu'
    - id: 'step-2'
      uses: 'gradle/actions/setup-gradle@v3'
    - id: 'step-3'
      name: 'Check if snapshot version is set'
      run: './gradlew setIsSnapshotFlagInGithubOutput'
    - id: 'step-4'
      name: 'Publish '':shared-internal'' to Sonatype'
      run: './gradlew :shared-internal:publishToSonatype --no-configuration-cache'
      if: '${{ steps.step-3.outputs.is-snapshot == ''true'' }}'
    - id: 'step-5'
      name: 'Publish '':github-workflows-kt'' to Sonatype'
      run: './gradlew :github-workflows-kt:publishToSonatype --no-configuration-cache'
      if: '${{ steps.step-3.outputs.is-snapshot == ''true'' }}'
    - id: 'step-6'
      name: 'Publish '':action-binding-generator'' to Sonatype'
      run: './gradlew :action-binding-generator:publishToSonatype --no-configuration-cache'
      if: '${{ steps.step-3.outputs.is-snapshot == ''true'' }}'
    - id: 'step-7'
      name: 'Publish '':action-updates-checker'' to Sonatype'
      run: './gradlew :action-updates-checker:publishToSonatype --no-configuration-cache'
      if: '${{ steps.step-3.outputs.is-snapshot == ''true'' }}'
  build_docs:
    name: 'Build docs'
    runs-on: 'ubuntu-latest'
    needs:
    - 'check_yaml_consistency'
    steps:
    - id: 'step-0'
      uses: 'actions/checkout@v4'
    - id: 'step-1'
      uses: 'actions/setup-python@v5'
      with:
        python-version: '3.8'
    - id: 'step-2'
      run: 'pip install -r docs/requirements.txt'
    - id: 'step-3'
      run: 'mkdocs build --site-dir public'
  workflows_consistency_check:
    name: 'Run consistency check on all GitHub workflows'
    runs-on: 'ubuntu-latest'
    needs:
    - 'check_yaml_consistency'
    steps:
    - id: 'step-0'
      uses: 'actions/checkout@v4'
    - id: 'step-1'
      name: 'Set up Java in proper version'
      uses: 'actions/setup-java@v4'
      with:
        java-version: '17'
        distribution: 'zulu'
        cache: 'gradle'
    - id: 'step-2'
      run: 'cd .github/workflows'
    - id: 'step-3'
      name: 'Regenerate all workflow YAMLs'
      run: |-
        find -name "*.main.kts" -print0 | while read -d $'\0' file
        do
            if [ "$file" = "./.github/workflows/end-to-end-tests.main.kts" ]; then
                continue
            fi

            if [ -x "$file" ]; then
                echo "Regenerating $file..."
                ($file)
            fi
        done
    - id: 'step-4'
      name: 'Check if some file is different after regeneration'
      run: 'git diff --exit-code .'


Validate Gradle wrapper

# This file was generated using Kotlin DSL (.github/workflows/gradle-wrapper-validation.main.kts).
# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file.
# Generated with https://github.com/typesafegithub/github-workflows-kt

name: 'Validate Gradle wrapper'
on:
  push:
    branches:
    - 'main'
    paths:
    - 'gradle/wrapper/gradle-wrapper.jar'
  pull_request:
    paths:
    - 'gradle/wrapper/gradle-wrapper.jar'
jobs:
  check_yaml_consistency:
    name: 'Check YAML consistency'
    runs-on: 'ubuntu-latest'
    steps:
    - id: 'step-0'
      name: 'Check out'
      uses: 'actions/checkout@v4'
    - id: 'step-1'
      name: 'Execute script'
      run: 'rm ''.github/workflows/gradle-wrapper-validation.yaml'' && ''.github/workflows/gradle-wrapper-validation.main.kts'''
    - id: 'step-2'
      name: 'Consistency check'
      run: 'git diff --exit-code ''.github/workflows/gradle-wrapper-validation.yaml'''
  validation:
    runs-on: 'ubuntu-latest'
    needs:
    - 'check_yaml_consistency'
    steps:
    - id: 'step-0'
      uses: 'actions/checkout@v4'
    - id: 'step-1'
      name: 'Validate wrapper'
      uses: 'gradle/wrapper-validation-action@v3'


Release

# This file was generated using Kotlin DSL (.github/workflows/release.main.kts).
# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file.
# Generated with https://github.com/typesafegithub/github-workflows-kt

name: 'Release'
on:
  push:
    tags:
    - 'v*.*.*'
env:
  SIGNING_KEY: '${{ secrets.SIGNING_KEY }}'
  SIGNING_PASSWORD: '${{ secrets.SIGNING_PASSWORD }}'
  ORG_GRADLE_PROJECT_sonatypeUsername: '${{ secrets.ORG_GRADLE_PROJECT_SONATYPEUSERNAME }}'
  ORG_GRADLE_PROJECT_sonatypePassword: '${{ secrets.ORG_GRADLE_PROJECT_SONATYPEPASSWORD }}'
jobs:
  check_yaml_consistency:
    name: 'Check YAML consistency'
    runs-on: 'ubuntu-latest'
    steps:
    - id: 'step-0'
      name: 'Check out'
      uses: 'actions/checkout@v4'
    - id: 'step-1'
      name: 'Execute script'
      run: 'rm ''.github/workflows/release.yaml'' && ''.github/workflows/release.main.kts'''
    - id: 'step-2'
      name: 'Consistency check'
      run: 'git diff --exit-code ''.github/workflows/release.yaml'''
  release:
    runs-on: 'ubuntu-latest'
    needs:
    - 'check_yaml_consistency'
    steps:
    - id: 'step-0'
      uses: 'actions/checkout@v4'
    - id: 'step-1'
      name: 'Set up JDK'
      uses: 'actions/setup-java@v4'
      with:
        java-version: '11'
        distribution: 'zulu'
    - id: 'step-2'
      uses: 'gradle/actions/setup-gradle@v3'
    - id: 'step-3'
      name: 'Build'
      run: './gradlew build'
    - id: 'step-4'
      uses: 'actions/setup-python@v5'
      with:
        python-version: '3.8'
    - id: 'step-5'
      name: 'Publish '':shared-internal'' to Sonatype'
      run: './gradlew :shared-internal:publishToSonatype closeAndReleaseSonatypeStagingRepository --no-configuration-cache'
    - id: 'step-6'
      name: 'Publish '':github-workflows-kt'' to Sonatype'
      run: './gradlew :github-workflows-kt:publishToSonatype closeAndReleaseSonatypeStagingRepository --no-configuration-cache'
    - id: 'step-7'
      name: 'Publish '':action-binding-generator'' to Sonatype'
      run: './gradlew :action-binding-generator:publishToSonatype closeAndReleaseSonatypeStagingRepository --no-configuration-cache'
    - id: 'step-8'
      name: 'Publish '':action-updates-checker'' to Sonatype'
      run: './gradlew :action-updates-checker:publishToSonatype closeAndReleaseSonatypeStagingRepository --no-configuration-cache'
    - id: 'step-9'
      name: 'Wait until '':shared-internal'' present in Maven Central'
      run: './gradlew :shared-internal:waitUntilLibraryPresentInMavenCentral'
    - id: 'step-10'
      name: 'Wait until '':github-workflows-kt'' present in Maven Central'
      run: './gradlew :github-workflows-kt:waitUntilLibraryPresentInMavenCentral'
    - id: 'step-11'
      name: 'Wait until '':action-binding-generator'' present in Maven Central'
      run: './gradlew :action-binding-generator:waitUntilLibraryPresentInMavenCentral'
    - id: 'step-12'
      name: 'Wait until '':action-updates-checker'' present in Maven Central'
      run: './gradlew :action-updates-checker:waitUntilLibraryPresentInMavenCentral'
    - id: 'step-13'
      run: 'pip install -r docs/requirements.txt'
    - id: 'step-14'
      name: 'Build Mkdocs docs'
      run: 'mkdocs build --site-dir to-gh-pages'
    - id: 'step-15'
      uses: 'gradle/actions/setup-gradle@v3'
    - id: 'step-16'
      name: 'Generate API docs'
      run: './gradlew :github-workflows-kt:dokkaHtml --no-configuration-cache'
    - id: 'step-17'
      name: 'Prepare target directory for API docs'
      run: 'mkdir -p to-gh-pages/api-docs'
    - id: 'step-18'
      name: 'Copy Dokka output to Mkdocs output'
      run: 'cp -r github-workflows-kt/build/dokka/html/* to-gh-pages/api-docs'
    - id: 'step-19'
      name: 'Copy teaser image'
      run: 'cp images/teaser-with-newest-version.svg to-gh-pages'
    - id: 'step-20'
      name: 'Deploy merged docs to GitHub Pages'
      uses: 'JamesIves/github-pages-deploy-action@v4'
      with:
        folder: 'to-gh-pages'


Updates available

# This file was generated using Kotlin DSL (.github/workflows/actions-versions.main.kts).
# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file.
# Generated with https://github.com/typesafegithub/github-workflows-kt

name: 'Updates available'
on:
  schedule:
  - cron: '0 7 * * 4'
  workflow_dispatch: {}
jobs:
  check_yaml_consistency:
    name: 'Check YAML consistency'
    runs-on: 'ubuntu-latest'
    if: '${{ github.repository_owner == ''typesafegithub'' || github.event_name != ''schedule'' }}'
    steps:
    - id: 'step-0'
      name: 'Check out'
      uses: 'actions/checkout@v4'
    - id: 'step-1'
      name: 'Execute script'
      run: 'rm ''.github/workflows/actions-versions.yaml'' && ''.github/workflows/actions-versions.main.kts'''
    - id: 'step-2'
      name: 'Consistency check'
      run: 'git diff --exit-code ''.github/workflows/actions-versions.yaml'''
  updates-available:
    runs-on: 'ubuntu-latest'
    needs:
    - 'check_yaml_consistency'
    if: '${{ github.repository_owner == ''typesafegithub'' || github.event_name != ''schedule'' }}'
    steps:
    - id: 'step-0'
      uses: 'actions/checkout@v4'
    - id: 'step-1'
      name: 'Set up JDK'
      uses: 'actions/setup-java@v4'
      with:
        java-version: '11'
        distribution: 'zulu'
    - id: 'step-2'
      uses: 'gradle/actions/setup-gradle@v3'
    - id: 'step-3'
      name: 'Run suggestVersions'
      env:
        GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
      run: './gradlew suggestVersions'
    - id: 'step-4'
      name: 'Create issue'
      uses: 'peter-evans/create-issue-from-file@v5'
      with:
        title: 'New major versions of actions available'
        content-filepath: 'build/suggestVersions.md'


Integration tests - permissions

.github/workflows/Integration tests - permissions.yaml


Create action update PRs

# This file was generated using Kotlin DSL (.github/workflows/create-action-update-prs.main.kts).
# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file.
# Generated with https://github.com/typesafegithub/github-workflows-kt

name: 'Create action update PRs'
on:
  schedule:
  - cron: '0 7 * * 4'
  workflow_dispatch: {}
jobs:
  check_yaml_consistency:
    name: 'Check YAML consistency'
    runs-on: 'ubuntu-latest'
    if: '${{ github.repository_owner == ''typesafegithub'' || github.event_name != ''schedule'' }}'
    steps:
    - id: 'step-0'
      name: 'Check out'
      uses: 'actions/checkout@v4'
    - id: 'step-1'
      name: 'Execute script'
      run: 'rm ''.github/workflows/create-action-update-prs.yaml'' && ''.github/workflows/create-action-update-prs.main.kts'''
    - id: 'step-2'
      name: 'Consistency check'
      run: 'git diff --exit-code ''.github/workflows/create-action-update-prs.yaml'''
  check-updates-and-create-prs:
    runs-on: 'ubuntu-latest'
    needs:
    - 'check_yaml_consistency'
    if: '${{ github.repository_owner == ''typesafegithub'' || github.event_name != ''schedule'' }}'
    steps:
    - id: 'step-0'
      uses: 'actions/checkout@v4'
    - id: 'step-1'
      name: 'Set up JDK'
      uses: 'actions/setup-java@v4'
      with:
        java-version: '11'
        distribution: 'zulu'
    - id: 'step-2'
      uses: 'gradle/actions/setup-gradle@v3'
    - id: 'step-3'
      name: 'Run logic'
      env:
        GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
      run: './gradlew createActionUpdatePRs'


Check if action bindings up to date

# This file was generated using Kotlin DSL (.github/workflows/check-if-action-bindings-up-to-date.main.kts).
# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file.
# Generated with https://github.com/typesafegithub/github-workflows-kt

name: 'Check if action bindings up to date'
on:
  push:
    branches:
    - 'main'
  pull_request: {}
  workflow_dispatch: {}
jobs:
  check_yaml_consistency:
    name: 'Check YAML consistency'
    runs-on: 'ubuntu-latest'
    steps:
    - id: 'step-0'
      name: 'Check out'
      uses: 'actions/checkout@v4'
    - id: 'step-1'
      name: 'Execute script'
      run: 'rm ''.github/workflows/check-if-action-bindings-up-to-date.yaml'' && ''.github/workflows/check-if-action-bindings-up-to-date.main.kts'''
    - id: 'step-2'
      name: 'Consistency check'
      run: 'git diff --exit-code ''.github/workflows/check-if-action-bindings-up-to-date.yaml'''
  check-on-UbuntuLatest:
    runs-on: 'ubuntu-latest'
    needs:
    - 'check_yaml_consistency'
    steps:
    - id: 'step-0'
      uses: 'actions/checkout@v4'
    - id: 'step-1'
      name: 'Set up JDK'
      uses: 'actions/setup-java@v4'
      with:
        java-version: '11'
        distribution: 'zulu'
    - id: 'step-2'
      uses: 'gradle/actions/setup-gradle@v3'
    - id: 'step-3'
      name: 'Generate action bindings'
      run: './gradlew :automation:code-generator:run'
    - id: 'step-4'
      name: 'Fail if there are any changes in the generated action bindings or their list in the docs'
      run: 'git diff --exit-code github-workflows-kt/src/gen/ docs/supported-actions.md'
  check-on-Windows2022:
    runs-on: 'windows-2022'
    needs:
    - 'check_yaml_consistency'
    steps:
    - id: 'step-0'
      uses: 'actions/checkout@v4'
    - id: 'step-1'
      name: 'Set up JDK'
      uses: 'actions/setup-java@v4'
      with:
        java-version: '11'
        distribution: 'zulu'
    - id: 'step-2'
      uses: 'gradle/actions/setup-gradle@v3'
    - id: 'step-3'
      name: 'Generate action bindings'
      run: './gradlew :automation:code-generator:run'
    - id: 'step-4'
      name: 'Fail if there are any changes in the generated action bindings or their list in the docs'
      run: 'git diff --exit-code github-workflows-kt/src/gen/ docs/supported-actions.md'


Integration test with Kotlin logic

.github/workflows/Integration test with Kotlin logic.yaml


End-to-end tests

# This file was generated using Kotlin DSL (.github/workflows/end-to-end-tests.main.kts).
# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file.
# Generated with https://github.com/typesafegithub/github-workflows-kt

name: 'End-to-end tests'
on:
  push:
    branches:
    - 'main'
  pull_request: {}
jobs:
  check_yaml_consistency:
    name: 'Check YAML consistency'
    runs-on: 'ubuntu-latest'
    env:
      GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
    steps:
    - id: 'step-0'
      name: 'Check out'
      uses: 'actions/checkout@v4'
    - id: 'step-1'
      name: 'Set up JDK'
      uses: 'actions/setup-java@v4'
      with:
        java-version: '11'
        distribution: 'zulu'
    - id: 'step-2'
      uses: 'gradle/actions/setup-gradle@v3'
      with:
        generate-job-summary: 'false'
    - id: 'step-3'
      name: 'Publish to Maven local'
      run: './gradlew publishToMavenLocal'
    - id: 'step-4'
      name: 'Execute script'
      run: 'rm ''.github/workflows/end-to-end-tests.yaml'' && ''.github/workflows/end-to-end-tests.main.kts'''
    - id: 'step-5'
      name: 'Consistency check'
      run: 'git diff --exit-code ''.github/workflows/end-to-end-tests.yaml'''
  test_job_1:
    runs-on: 'ubuntu-latest'
    permissions:
      actions: 'read'
      checks: 'write'
      contents: 'none'
    needs:
    - 'check_yaml_consistency'
    env:
      $GREETING: 'World'
    outputs:
      scriptKey: '${{ steps.step-20.outputs.key }}'
      scriptKey2: '${{ steps.step-20.outputs.key2 }}'
      scriptResult: '${{ steps.step-20.outputs.result }}'
    steps:
    - id: 'step-0'
      name: 'Hello world!'
      run: 'echo ''hello!'''
    - id: 'step-1'
      name: 'Hello world! Multiline command with pipes'
      run: |-
        less test.txt \
        | grep -P "foobar" \
        | sort \
        > result.txt
    - id: 'step-2'
      name: 'Check out'
      uses: 'actions/checkout@v4'
    - id: 'step-3'
      name: 'Run local action'
      uses: './.github/workflows/test-local-action'
      with:
        name: 'Rocky'
    - id: 'step-4'
      name: 'Run alpine'
      uses: 'docker://alpine:latest'
    - id: 'step-5'
      name: 'Check out again'
      uses: 'actions/checkout@v4'
      with:
        repository: 'actions/checkout'
        ref: 'v3'
        path: './.github/actions/checkout'
        clean: 'false'
    - id: 'step-6'
      name: 'Run local action'
      uses: './.github/workflows/test-local-action'
      with:
        name: 'Balboa'
    - id: 'step-7'
      name: 'Run alpine'
      uses: 'docker://alpine:latest'
    - id: 'step-8'
      uses: 'actions/setup-python@v5'
    - id: 'step-9'
      name: 'Some step consuming other step''s output'
      uses: 'actions/checkout@v4'
      with:
        ssh-key: '${{ steps.step-8.outputs.python-version }}'
        path: '${{ steps.step-8.outputs.my-unsafe-output }}'
    - id: 'step-10'
      name: 'Custom environment variable'
      env:
        $FIRST_NAME: 'Patrick'
      run: 'echo $GREETING $FIRST_NAME'
    - id: 'step-11'
      name: 'Encrypted secret'
      env:
        $SECRET: '${{ secrets.SUPER_SECRET }}'
        $TOKEN: '${{ secrets.GITHUB_TOKEN }}'
      run: 'echo secret=$SECRET token=$TOKEN'
    - id: 'step-12'
      name: 'RunnerContext create temp directory'
      run: 'mkdir ${{ runner.temp }}/build_logs'
    - id: 'step-13'
      name: 'GitHubContext echo sha'
      run: 'echo ${{ github.sha }} ev ${{ github.event.release.url }}'
    - id: 'step-14'
      name: 'Default environment variable'
      run: 'action=$GITHUB_ACTION repo=$GITHUB_REPOSITORY'
      if: '${{ always() }}'
    - id: 'step-15'
      name: 'Set up JDK'
      uses: 'actions/setup-java@v4'
      with:
        java-version: '11'
        distribution: 'zulu'
    - id: 'step-16'
      uses: 'gradle/actions/setup-gradle@v3'
      with:
        generate-job-summary: 'false'
    - id: 'step-17'
      name: 'Publish to Maven local'
      run: './gradlew publishToMavenLocal'
    - id: 'step-18'
      name: 'Evaluating condition for ''Step with a Kotlin-based logic'''
      env:
        GHWKT_GITHUB_CONTEXT_JSON: '${{ toJSON(github) }}'
      run: 'GHWKT_RUN_STEP=''test_job_1:step-18'' ''.github/workflows/end-to-end-tests.main.kts'''
    - id: 'step-19'
      name: 'Step with a Kotlin-based logic'
      env:
        GHWKT_GITHUB_CONTEXT_JSON: '${{ toJSON(github) }}'
      run: 'GHWKT_RUN_STEP=''test_job_1:step-19'' ''.github/workflows/end-to-end-tests.main.kts'''
      if: '${{ steps.step-18.outputs.evaluation-result }}'
    - id: 'step-20'
      uses: 'actions/github-script@v7'
      with:
        script: |-
          core.setOutput("key", "value")
          core.setOutput("key2", "value2")
          return "return"
  test_job_2:
    runs-on: 'ubuntu-latest'
    needs:
    - 'test_job_1'
    - 'check_yaml_consistency'
    if: '${{ always() }}'
    steps:
    - id: 'step-0'
      name: 'Hello world, again!'
      run: 'echo ''hello again!'''
    - id: 'step-1'
      name: 'use output of script'
      run: |-
        echo ${{ needs.test_job_1.outputs.scriptKey }}
        echo ${{ needs.test_job_1.outputs.scriptKey2 }}
        echo ${{ needs.test_job_1.outputs.scriptResult }}


Bindings server

# This file was generated using Kotlin DSL (.github/workflows/bindings-server.main.kts).
# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file.
# Generated with https://github.com/typesafegithub/github-workflows-kt

name: 'Bindings server'
on:
  push:
    branches:
    - 'main'
  pull_request: {}
jobs:
  check_yaml_consistency:
    name: 'Check YAML consistency'
    runs-on: 'ubuntu-latest'
    steps:
    - id: 'step-0'
      name: 'Check out'
      uses: 'actions/checkout@v4'
    - id: 'step-1'
      name: 'Execute script'
      run: 'rm ''.github/workflows/bindings-server.yaml'' && ''.github/workflows/bindings-server.main.kts'''
    - id: 'step-2'
      name: 'Consistency check'
      run: 'git diff --exit-code ''.github/workflows/bindings-server.yaml'''
  end-to-end-test:
    name: 'End-to-end test'
    runs-on: 'ubuntu-latest'
    needs:
    - 'check_yaml_consistency'
    env:
      GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
    steps:
    - id: 'step-0'
      uses: 'actions/checkout@v4'
    - id: 'step-1'
      uses: 'gradle/actions/setup-gradle@v3'
    - id: 'step-2'
      name: 'Start the server'
      run: './gradlew :jit-binding-server:run &'
    - id: 'step-3'
      name: 'Wait for the server to respond'
      env:
        GHWKT_GITHUB_CONTEXT_JSON: '${{ toJSON(github) }}'
      run: 'GHWKT_RUN_STEP=''end-to-end-test:step-3'' ''.github/workflows/bindings-server.main.kts'''
    - id: 'step-4'
      name: 'Execute the script using the bindings from the serve - with /binding'
      run: |-
        mv .github/workflows/test-script-consuming-jit-bindings-old.main.do-not-compile.kts .github/workflows/test-script-consuming-jit-bindings-old.main.kts
        .github/workflows/test-script-consuming-jit-bindings-old.main.kts
    - id: 'step-5'
      name: 'Execute the script using the bindings from the server'
      run: |-
        mv .github/workflows/test-script-consuming-jit-bindings.main.do-not-compile.kts .github/workflows/test-script-consuming-jit-bindings.main.kts
        .github/workflows/test-script-consuming-jit-bindings.main.kts
    - id: 'step-6'
      name: 'Clean Maven Local to fetch required POMs again'
      run: 'rm -rf ~/.m2/repository/'
    - id: 'step-7'
      name: 'Execute the script using bindings but without dependency on library'
      run: |-
        mv .github/workflows/test-served-bindings-depend-on-library.main.do-not-compile.kts .github/workflows/test-served-bindings-depend-on-library.main.kts
        .github/workflows/test-served-bindings-depend-on-library.main.kts
    - id: 'step-8'
      name: 'Fetch maven-metadata.xml for top-level action - with /binding'
      run: 'curl --fail http://localhost:8080/binding/actions/checkout/maven-metadata.xml | grep ''<version>v4</version>'''
    - id: 'step-9'
      name: 'Fetch maven-metadata.xml for nested action - with /binding'
      run: 'curl --fail http://localhost:8080/binding/actions/cache__save/maven-metadata.xml | grep ''<version>v4</version>'''
    - id: 'step-10'
      name: 'Fetch maven-metadata.xml for top-level action'
      run: 'curl --fail http://localhost:8080/actions/checkout/maven-metadata.xml | grep ''<version>v4</version>'''
    - id: 'step-11'
      name: 'Fetch maven-metadata.xml for nested action'
      run: 'curl --fail http://localhost:8080/actions/cache__save/maven-metadata.xml | grep ''<version>v4</version>'''
  deploy:
    name: 'Deploy to DockerHub'
    runs-on: 'ubuntu-latest'
    needs:
    - 'end-to-end-test'
    - 'check_yaml_consistency'
    env:
      DOCKERHUB_USERNAME: '${{ secrets.DOCKERHUB_USERNAME }}'
      DOCKERHUB_PASSWORD: '${{ secrets.DOCKERHUB_PASSWORD }}'
    if: '${{ github.event_name == ''push'' }}'
    environment:
      name: 'DockerHub'
    steps:
    - id: 'step-0'
      uses: 'actions/checkout@v4'
    - id: 'step-1'
      uses: 'gradle/actions/setup-gradle@v3'
    - id: 'step-2'
      name: 'Build and publish image'
      run: './gradlew :jit-binding-server:publishImage'
    - id: 'step-3'
      name: 'Use newest image on the server'
      run: 'curl -X POST ${{ secrets.TRIGGER_IMAGE_PULL }} --insecure'


This is a example of a horribly outdated workflow


Greetings

name: Greetings

on: [pull_request, issues]

jobs:
  greeting:
    runs-on: ubuntu-latest
    permissions:
      issues: write
      pull-requests: write
    steps:
    - uses: actions/first-interaction@v1
      with:
        repo-token: ${{ secrets.GITHUB_TOKEN }}
        issue-message: 'Welcome with your first issue'
        pr-message: 'Welcome with your first PullRequest'


Publish KDocs

name: Publish KDocs
on:
  push:
    branches:
      - master
jobs:
  publishing:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-java@v1
        with:
          java-version: 17
      - name: Build
        run: ./gradlew dokkaHtmlMultiModule
      - name: Publish KDocs
        uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./build/dokka/htmlMultiModule
          publish_branch: kdocs


Pull Request Labeler

# This workflow will triage pull requests and apply a label based on the
# paths that are modified in the pull request.
#
# To use this workflow, you will need to set up a .github/labeler.yml
# file with configuration.  For more information, see:
# https://github.com/actions/labeler/blob/master/README.md

name: "Pull Request Labeler"
on:
  - pull_request

jobs:
  triage:
    runs-on: ubuntu-latest
    if: ${{ github.actor == github.repository_owner }}
    steps:
      - uses: actions/labeler@v2
        with:
          repo-token: "${{ secrets.GITHUB_TOKEN }}"


Publish package to GitHub Packages

name: Publish package to GitHub Packages
on: [push]
jobs:
  publishing:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-java@v1
        with:
          java-version: 17
      - name: Setup LibCurl
        run: sudo apt update && sudo apt install -y libcurl4-openssl-dev
      - name: Rewrite version
        run: |
          branch="`echo "${{ github.ref }}" | grep -o "[^/]*$"`"
          cat gradle.properties | sed -e "s/^library_version=\([0-9\.]*\)/library_version=\1-branch_$branch-build${{ github.run_number }}/" > gradle.properties.tmp
          rm gradle.properties
          mv gradle.properties.tmp gradle.properties
      - name: KotlinSymbolProcessing execution
        run: ./gradlew ksp
      - name: Build
        run: ./gradlew build
      - name: API compatibility check
        run: ./gradlew apiCheck
      - name: Publish to Gitea
        continue-on-error: true
        run: ./gradlew publishAllPublicationsToInmoNexusRepository
        env:
          INMONEXUS_USER: ${{ secrets.INMONEXUS_USER }}
          INMONEXUS_PASSWORD: ${{ secrets.INMONEXUS_PASSWORD }}
      - name: Publish to GithubPackages
        continue-on-error: true
        run: ./gradlew publishAllPublicationsToGithubPackagesRepository --no-parallel
        env:
          GITHUBPACKAGES_USER: ${{ github.actor }}
          GITHUBPACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }}


Java CI with Maven

# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Java CI with Maven

on:
  push:
    branches:
      - 'develop'

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Set up JDK 17
        uses: actions/setup-java@v3
        with:
          java-version: '17'
          distribution: 'temurin'
          cache: maven
          gpg-private-key: ${{ secrets.GPG_KEY }} # Value of the GPG private key to import
      - name: Build with Maven
        run: mvn -B deploy --file pom.xml

      # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
      - name: Update dependency graph
        uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6


Build

name: Build

on:
  push:
    branches: [ '**' ]
    paths-ignore:
      - '**.md'
      - 'docs/**'
      - '.github/workflows/docs.yml'
      - '.github/workflows/docs-pr.yml'
  workflow_call:
    secrets:
      DOCKER_USERNAME:
        required: false
      DOCKER_TOKEN:
        required: false
      DOCKER_REGISTRY:
        required: false
      DOCKER_IMAGE:
        required: false
      MAVEN_USERNAME:
        required: false
      MAVEN_PASSWORD:
        required: false
      ORG_GRADLE_PROJECT_mavenCentralPassword:
        required: false
      ORG_GRADLE_PROJECT_mavenCentralUsername:
        required: false
      ORG_GRADLE_PROJECT_signingInMemoryKey:
        required: false
      ORG_GRADLE_PROJECT_signingInMemoryKeyPassword:
        required: false

jobs:
  build:
    runs-on: ubuntu-latest
    env:
      DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
      DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
      DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
      DOCKER_IMAGE: ${{ secrets.DOCKER_IMAGE }}
      MAVEN_USERNAME: ${{ vars.MAVEN_USERNAME }}
      MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
      ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALPASSWORD }}
      ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALUSERNAME }}
      ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEY }}
      ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEYPASSWORD }}
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup Java
        uses: actions/setup-java@v3
        with:
          distribution: zulu
          java-version: 17
          cache: gradle

      - name: Setup Gradle
        uses: gradle/gradle-build-action@v2

      - name: Execute Gradle build
        run: ./gradlew build

      - name: Execute Gradle build
        run: ./gradlew build -PtargetPlatform=musl

      - name: Publish to Maven
        run: ./gradlew publish -PMAVEN_USERNAME=$MAVEN_USERNAME -PMAVEN_PASSWORD=$MAVEN_PASSWORD

      - name: Upload Artifacts
        uses: actions/upload-artifact@v4
        with:
          name: Lavalink.jar
          path: |
            LavalinkServer/build/libs/Lavalink.jar
            LavalinkServer/build/libs/Lavalink-musl.jar

      - name: Docker Meta
        id: meta
        uses: docker/metadata-action@v4
        with:
          images: |
            ghcr.io/${{ github.repository }}
            ${{ env.DOCKER_IMAGE }}
          tags: |
            type=ref,event=branch
            type=ref,event=pr
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}
            type=semver,pattern={{major}}
            type=sha,prefix=

      - name: Docker Meta Alpine
        id: meta-alpine
        uses: docker/metadata-action@v4
        with:
          images: |
            ghcr.io/${{ github.repository }}
            ${{ env.DOCKER_IMAGE }}
          flavor: |
            suffix=-alpine,onlatest=true
          tags: |
            type=ref,event=branch
            type=ref,event=pr
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}
            type=semver,pattern={{major}}
            type=sha,prefix=

      - name: Set up QEMU
        uses: docker/setup-qemu-action@v2

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2

      - name: Login to GitHub Container Registry
        uses: docker/login-action@v2
        with:
          registry: ghcr.io
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Log in to docker registry
        if: env.DOCKER_USERNAME && env.DOCKER_TOKEN && env.DOCKER_REGISTRY && env.DOCKER_IMAGE
        uses: docker/login-action@v2
        with:
          registry: ${{ env.DOCKER_REGISTRY }}
          username: ${{ env.DOCKER_USERNAME }}
          password: ${{ env.DOCKER_TOKEN }}

      - name: Build Ubuntu and Push
        uses: docker/build-push-action@v3
        with:
          file: LavalinkServer/docker/Dockerfile
          context: .
          platforms: linux/amd64,linux/arm/v7,linux/arm64/v8
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}

      - name: Build Alpine and Push
        uses: docker/build-push-action@v3
        with:
          file: LavalinkServer/docker/alpine.Dockerfile
          context: .
          platforms: linux/amd64,linux/arm64/v8
          push: true
          tags: ${{ steps.meta-alpine.outputs.tags }}
          labels: ${{ steps.meta-alpine.outputs.labels }}


Docs PR

name: Docs PR

on:
  pull_request_target:
    branches: [ '**' ]
    paths:
      - 'docs/**'

concurrency:
    group: pages
    cancel-in-progress: true

jobs:
  deploy:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      deployments: write
    steps:
      - uses: actions/checkout@v4
        with:
          ref: "${{ github.event.pull_request.merge_commit_sha }}"
      - uses: actions/setup-python@v5
        with:
          python-version: 3.x
      - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
      - uses: actions/cache@v4
        with:
          key: mkdocs-material-${{ env.cache_id }}
          path: .cache
          restore-keys: |
            mkdocs-material-
      - run: pip install -r requirements.txt
        working-directory: docs
#      - run: mkdocs build --verbose --strict
      - run: mkdocs build --verbose
        working-directory: docs
      - uses: actions/upload-pages-artifact@v3
        with:
          path: 'site'
      - uses: topi314/pages-action@989c0bd3a707c425c05f802dd9984387be67e82b
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
          projectName: ${{ vars.CLOUDFLARE_PROJECT_NAME }}
          directory: site
          branch: pr-${{ github.event.pull_request.number }}
          gitHubToken: ${{ secrets.GITHUB_TOKEN }}
          deploymentRef: ${{ github.event.pull_request.merge_commit_sha }}


Docs Push

name: Docs Push

on:
  push:
    branches: [ '**' ]
    paths:
      - 'docs/**'
      - '.github/workflows/docs.yml'

concurrency:
    group: pages-${{ github.ref }}
    cancel-in-progress: true

jobs:
  deploy:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      deployments: write
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: actions/setup-python@v5
        with:
          python-version: 3.x
      - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
      - uses: actions/cache@v4
        with:
          key: mkdocs-material-${{ env.cache_id }}
          path: .cache
          restore-keys: |
            mkdocs-material-
      - run: pip install -r requirements.txt
        working-directory: docs
#      - run: mkdocs build --verbose --strict
      - run: mkdocs build --verbose
        working-directory: docs
      - uses: actions/upload-pages-artifact@v3
        with:
          path: 'site'
      - uses: cloudflare/pages-action@v1
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
          projectName: ${{ vars.CLOUDFLARE_PROJECT_NAME }}
          directory: site
          gitHubToken: ${{ secrets.GITHUB_TOKEN }}
          wranglerVersion: '3'


Release

name: Release

on:
  release:
    types: [published]

jobs:
  build:
    uses: ./.github/workflows/build.yml
    secrets:
      DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
      DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
      DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
      DOCKER_IMAGE: ${{ secrets.DOCKER_IMAGE }}
      MAVEN_USERNAME: ${{ vars.MAVEN_USERNAME }}
      MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
      ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALPASSWORD }}
      ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALUSERNAME }}
      ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEY }}
      ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEYPASSWORD }}

  release:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Download Artifacts
        uses: actions/download-artifact@v4
        with:
          name: Lavalink.jar

      - name: Upload Artifacts to GitHub Release
        uses: ncipollo/release-action@v1
        with:
          artifacts: Lavalink.jar
          allowUpdates: true
          omitBodyDuringUpdate: true
          omitDraftDuringUpdate: true
          omitNameDuringUpdate: true
          omitPrereleaseDuringUpdate: true


Build CI

name: Build CI

on:
  push:
    branches: [ "develop" ]
  pull_request:
    branches: [ "develop" ]

jobs:
  build:

    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'
          cache: gradle

      - name: Grant execute permission for gradlew
        run: chmod +x gradlew
      - name: Build with Gradle
        run: ./gradlew buildDebug
      - name: Run Kover
        run: ./gradlew koverXmlReport
      - name: Upload coverage reports to Codecov
        uses: codecov/codecov-action@v4
#  ios:
#    runs-on: macos-latest
#    steps:
#      - name: Checkout
#        uses: actions/checkout@v4
#
#      - name: check Xcode version
#        run: /usr/bin/xcodebuild -version
#
#      - name: Get swift version
#        run: swift --version
#
#      - name: set up JDK 17
#        uses: actions/setup-java@v4
#        with:
#          java-version: '17'
#          distribution: 'temurin'
#          cache: gradle
#
#      - name: Grant execute permission for gradlew
#        run: chmod +x gradlew
#
#      - name: Install the Apple certificate and provisioning profile
#        env:
#          BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
#          P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
#          BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }}
#          KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
#        run: |
#          # create variables
#          CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
#          PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
#          KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
#
#          # import certificate and provisioning profile from secrets
#          echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o "$CERTIFICATE_PATH"
#          echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o "$PP_PATH"
#
#          # create temporary keychain
#          security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
#          security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH"
#          security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
#
#          # import certificate to keychain
#          security import "$CERTIFICATE_PATH" -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k "$KEYCHAIN_PATH"
#          security list-keychain -d user -s "$KEYCHAIN_PATH"
#
#          # apply provisioning profile
#          mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
#          cp "$PP_PATH" ~/Library/MobileDevice/Provisioning\ Profiles
#
#      - name: Set Default Scheme
#        run: |
#          cd ios
#          default="ios"
#          echo $default | cat >default
#          echo Using default scheme: $default
#
#      - name: Build
#        env:
#          scheme: ${{ 'default' }}
#          platform: ${{ 'iOS Simulator' }}
#        run: |
#          cd ios
#          # xcrun xctrace returns via stderr, not the expected stdout (see https://developer.apple.com/forums/thread/663959)
#          device=`xcrun xctrace list devices 2>&1 | grep -oE 'iPhone.*?[^\(]+' | head -1 | awk '{$1=$1;print}' | sed -e "s/ Simulator$//"`
#          if [ $scheme = default ]; then scheme=$(cat default); fi
#          if [ "`ls -A | grep -i \\.xcworkspace\$`" ]; then filetype_parameter="workspace" && file_to_build="`ls -A | grep -i \\.xcworkspace\$`"; else filetype_parameter="project" && file_to_build="`ls -A | grep -i \\.xcodeproj\$`"; fi
#          file_to_build=`echo $file_to_build | awk '{$1=$1;print}'`
#          xcodebuild build-for-testing -scheme "$scheme" -sdk iphoneos -allowProvisioningUpdates


Publish

name: Publish
on:
  release:
    types: [ published ]

jobs:
  publish-google-play:
    runs-on: ubuntu-latest
    env:
      BUILD_NUMBER: ${{ github.run_number }}
      RELEASE_BUILD: true

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: set up JDK 17
        uses: actions/setup-java@v4
        with:
          java-version: '17'
          distribution: 'temurin'
          cache: gradle

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: '3.2.2'
          bundler-cache: true

      - name: Cache Ruby - Bundler
        uses: actions/cache@v4
        with:
          path: vendor/bundle
          key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
          restore-keys: |
            ${{ runner.os }}-gems-

      - name: Grant Permission to Execute
        run: chmod +x gradlew

      - name: Install bundle
        run: |
          bundle config path vendor/bundle
          bundle install --jobs 4 --retry 3

      - name: Restore key
        working-directory: /home/runner/work/hammer-editor/hammer-editor/
        run: |
          echo "${{ secrets.RELEASE_KEYSTORE }}" > release.keystore.asc
          echo ${{ secrets.RELEASE_STORE_PASSWORD_BASE64 }} | base64 -d > passphrase
          gpg -d --passphrase-file passphrase --batch release.keystore.asc > release.keystore

      - name: Create Google Play Config file
        run: |
          echo "$PLAY_CONFIG_JSON" > play_config.json.b64
          base64 -d -i play_config.json.b64 > play_config.json
        env:
          PLAY_CONFIG_JSON: ${{ secrets.PLAY_CONFIG_JSON }}

      - name: Publish F-Droid
        run: |
          ./gradlew publishFdroid

      - name: Distribute app to Production track 🚀
        run: bundle exec fastlane release
        env:
          RELEASE_STORE_FILE: /home/runner/work/hammer-editor/hammer-editor/release.keystore
          RELEASE_STORE_PASSWORD: ${{ secrets.RELEASE_STORE_PASSWORD }}
          RELEASE_KEY_ALIAS: ${{ secrets.RELEASE_KEY_ALIAS }}
          RELEASE_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }}
  notify:
    needs: publish-google-play
    runs-on: ubuntu-latest
    steps:
      - name: Discord notification
        env:
          DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
        uses: Ilshidur/action-discord@master
        with:
          args: '**New release:** {{ EVENT_PAYLOAD.release.name }} **Download Here:** {{ EVENT_PAYLOAD.release.html_url }}'