diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8b0105d..5a57575 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,6 +2,10 @@ name: Build Release App on: workflow_call: + inputs: + version: + required: true + type: string jobs: build: @@ -16,6 +20,12 @@ jobs: - uses: gradle/actions/setup-gradle@v4 + - name: Inject version + run: | + sed -i 's/versionName = ".*"/versionName = "${{ inputs.version }}"/' Manager/app/build.gradle.kts + sed -i "s/versionCode = .*/versionCode = ${{ github.run_number }}/" Manager/app/build.gradle.kts + grep -E "versionCode|versionName" Manager/app/build.gradle.kts + - name: Build working-directory: Manager env: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 53749f1..d7fa1d2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,13 +8,27 @@ on: - "**/*.md" jobs: + Version: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.set.outputs.version }} + steps: + - uses: actions/checkout@v4 + - id: set + run: | + BASE=$(cat .version | tr -d '[:space:]') + echo "version=$BASE.${{ github.run_number }}" >> $GITHUB_OUTPUT + Build: + needs: Version uses: ./.github/workflows/build.yml + with: + version: ${{ needs.Version.outputs.version }} secrets: inherit Release: name: Publish Release - needs: Build + needs: [Version, Build] runs-on: ubuntu-latest permissions: contents: write @@ -54,5 +68,5 @@ jobs: repo_token: ${{ secrets.GITHUB_TOKEN }} automatic_release_tag: latest prerelease: false - title: Latest Release + title: v${{ needs.Version.outputs.version }} files: ./dist/** diff --git a/.version b/.version new file mode 100644 index 0000000..be58634 --- /dev/null +++ b/.version @@ -0,0 +1 @@ +0.3 diff --git a/Manager/app/src/main/kotlin/com/meowarex/rlmobile/network/models/GithubRelease.kt b/Manager/app/src/main/kotlin/com/meowarex/rlmobile/network/models/GithubRelease.kt index 166c67f..80b1e7d 100644 --- a/Manager/app/src/main/kotlin/com/meowarex/rlmobile/network/models/GithubRelease.kt +++ b/Manager/app/src/main/kotlin/com/meowarex/rlmobile/network/models/GithubRelease.kt @@ -10,6 +10,7 @@ data class GithubRelease( val assets: List, @SerialName("tag_name") val tagName: String, + val name: String? = null, @SerialName("html_url") val htmlUrl: String, ) { diff --git a/Manager/app/src/main/kotlin/com/meowarex/rlmobile/ui/widgets/updater/UpdaterViewModel.kt b/Manager/app/src/main/kotlin/com/meowarex/rlmobile/ui/widgets/updater/UpdaterViewModel.kt index fe0fce4..35c7e2c 100644 --- a/Manager/app/src/main/kotlin/com/meowarex/rlmobile/ui/widgets/updater/UpdaterViewModel.kt +++ b/Manager/app/src/main/kotlin/com/meowarex/rlmobile/ui/widgets/updater/UpdaterViewModel.kt @@ -147,13 +147,13 @@ class UpdaterViewModel( // Fetch releases from GitHub (60s local cache) val releases = github.getManagerReleases().getOrThrow() - // Find the latest release + APK release asset + // Find the latest release — version is parsed from the release title (e.g. "v1.0.5") val (version, release, apkUrl) = releases .mapNotNull { release -> - val version = SemVer.parseOrNull(release.tagName) + val version = SemVer.parseOrNull(release.name?.removePrefix("v") ?: "") ?: return@mapNotNull null - val asset = release.assets.find { it.name == "rl-manager-${release.tagName}.apk" } + val asset = release.assets.find { it.name == "rl-manager.apk" } ?: return@mapNotNull null Triple(version, release, asset.browserDownloadUrl)