diff --git a/.github/workflows/playstore.yml b/.github/workflows/playstore.yml index c5d487798..bc49baa95 100644 --- a/.github/workflows/playstore.yml +++ b/.github/workflows/playstore.yml @@ -83,33 +83,28 @@ jobs: env: VERSION: ${{ inputs.version }} SOURCE_BRANCH: ${{ inputs.source_branch || 'playstore' }} - PLAY_VERSION_CODE_BASE: ${{ vars.PLAY_VERSION_CODE_BASE }} run: | set -euo pipefail test "$SOURCE_BRANCH" = playstore test "$GITHUB_REF" = refs/heads/playstore sha=$(git rev-parse HEAD) + name=$(sed -n 's/^ *versionName "\(.*\)"$/\1/p' app/build.gradle) + [[ $name =~ ^[0-9A-Za-z._-]+$ ]] if [ "$GITHUB_EVENT_NAME" = workflow_dispatch ]; then [[ $VERSION =~ ^[0-9A-Za-z._-]+$ ]] || { echo "::error::invalid version"; exit 1; } - name=$(sed -n 's/^ *versionName "\(.*\)"$/\1/p' app/build.gradle) [[ $VERSION == "$name" || $VERSION == "$name"-* ]] || { echo "::error::version must match versionName in app/build.gradle; bump versionName and versionCode first" exit 1 } else - VERSION="playstore-${sha::7}" + VERSION="$name" fi echo "sha=$sha" >> "$GITHUB_OUTPUT" echo "version=$VERSION" >> "$GITHUB_OUTPUT" source_code=$(sed -n 's/^ *versionCode \([0-9][0-9]*\)$/\1/p' app/build.gradle) - base=${PLAY_VERSION_CODE_BASE:-$source_code} - [[ $base =~ ^[0-9]+$ && $source_code =~ ^[0-9]+$ ]] - [ "$base" -ge "$source_code" ] || base=$source_code - elapsed=$(( $(date -u +%s) - 1577836800 )) - [ "$elapsed" -gt 0 ] - version_code=$((base + elapsed)) - [ "$version_code" -le 2100000000 ] - echo "version_code=$version_code" >> "$GITHUB_OUTPUT" + [[ $source_code =~ ^[1-9][0-9]*$ ]] + [ "$source_code" -le 2100000000 ] + echo "version_code=$source_code" >> "$GITHUB_OUTPUT" bundle: needs: source diff --git a/app/build.gradle b/app/build.gradle index 6495e4289..7898b0daa 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -134,8 +134,8 @@ android { applicationId "com.droiddeck.launcher" minSdkVersion 26 targetSdkVersion 37 - versionCode 17 - versionName "0.6.9" + versionCode 18 + versionName "0.6.9.1" buildConfigField "String", "BUILD_LABEL", "\"${escapedBuildLabel}\"" buildConfigField "String", "SOURCE_COMMIT", "\"${sourceCommit}\"" buildConfigField "int", "PR_NUMBER", "${prNumber}" @@ -264,11 +264,8 @@ if (playDistribution) { android.buildTypes.debug.signingConfig = null android.buildTypes.release.signingConfig = null def requestedCode = providers.gradleProperty('playVersionCode').orNull - if (requestedCode != null) { - if (!requestedCode.isInteger() || requestedCode.toLong() < android.defaultConfig.versionCode || requestedCode.toLong() > 2100000000L) { - throw new GradleException('Play version code must be a valid increasing Android version code') - } - android.defaultConfig.versionCode = requestedCode.toInteger() + if (requestedCode != null && requestedCode != android.defaultConfig.versionCode.toString()) { + throw new GradleException('Play version code must match app/build.gradle') } def playAudio = layout.buildDirectory.dir('play-audio') def playNdk = androidComponents.sdkComponents.ndkDirectory.get().asFile diff --git a/tools/playstore/README.md b/tools/playstore/README.md index 04283ac65..557b77c4c 100644 --- a/tools/playstore/README.md +++ b/tools/playstore/README.md @@ -4,6 +4,8 @@ For a versioned GitHub release, run the existing `Release APKs` workflow with branch `playstore` and a Version matching `versionName` in `app/build.gradle`. That entry calls `Build PlayStore Bundle`. The Play release uses a separate tag and explicitly leaves Latest unchanged. The manual entry works without adding the branch-only workflow to `main`. +Both `versionName` and the integer `versionCode` come directly from `app/build.gradle`. Increment the repository's version code for each new Play release. Build counters, timestamps, and repository variables never add offsets to it. Push artifact filenames also use the repository's version name. + The signing environment supplies `RELEASE_KEYSTORE_B64`, `RELEASE_STORE_PASSWORD`, and `RELEASE_KEY_ALIAS`. Compilation never receives the release key. Signing checks the certificate against `keystore/release-signer.sha256`, keeps the alias out of signature filenames, and verifies every signed payload entry. `components.lock.json` pins the native runtime, desktop packages, DroidDeck Proton, driver variants, native component variants, Decky channels, and synchronization packs. Native components have no external download fallback in the app. The bundled catalog pins current native variants rather than their complete release histories. Existing installed versions remain available. diff --git a/tools/tests/test_playstore_workflow.py b/tools/tests/test_playstore_workflow.py index eb42415a8..8705b0991 100644 --- a/tools/tests/test_playstore_workflow.py +++ b/tools/tests/test_playstore_workflow.py @@ -1,5 +1,8 @@ from pathlib import Path import re +import os +import subprocess +import tempfile import unittest import yaml @@ -81,13 +84,18 @@ class PlaystoreWorkflowTest(unittest.TestCase): self.assertEqual("github.ref == 'refs/heads/main'", self.release['jobs'][name]['if']) self.assertIn("'release-playstore' || 'release'", self.release['concurrency']['group']) - def test_play_version_codes_are_independent_of_the_entry_workflow_counter(self): + def test_play_version_metadata_comes_from_the_repository_without_generated_offsets(self): self.assertEqual('playstore-bundle', self.play['concurrency']['group']) self.assertEqual('false', self.play['concurrency']['cancel-in-progress']) source = self.play['jobs']['source']['steps'][-1]['run'] - self.assertIn('date -u +%s', source) + self.assertNotIn('date -u +%s', source) self.assertNotIn('GITHUB_RUN_NUMBER', source) - self.assertIn('version_code=$((base + elapsed))', source) + self.assertNotIn('PLAY_VERSION_CODE_BASE', source) + self.assertIn('echo "version_code=$source_code"', source) + self.assertIn('VERSION="$name"', source) + gradle = (ROOT / 'app/build.gradle').read_text() + self.assertIn('requestedCode != android.defaultConfig.versionCode.toString()', gradle) + self.assertNotIn('android.defaultConfig.versionCode = requestedCode', gradle) def test_distribution_checks_run_without_the_production_manifest_or_signing_secrets(self): checks = self.play['jobs']['checks'] @@ -101,6 +109,22 @@ class PlaystoreWorkflowTest(unittest.TestCase): self.assertIn('tools.tests.test_playstore_signing', command) self.assertIn('tools.tests.test_playstore_payloads', command) + def test_source_job_emits_repository_versions_even_with_old_counter_variables(self): + source = self.play['jobs']['source']['steps'][-1]['run'] + gradle = (ROOT / 'app/build.gradle').read_text() + code = re.search(r'^\s*versionCode (\d+)$', gradle, re.MULTILINE).group(1) + name = re.search(r'^\s*versionName "([^"]+)"$', gradle, re.MULTILINE).group(1) + for event in ['push', 'workflow_dispatch']: + with self.subTest(event=event), tempfile.TemporaryDirectory() as directory: + output = Path(directory) / 'outputs' + environment = dict(os.environ, GITHUB_EVENT_NAME=event, GITHUB_REF='refs/heads/playstore', + SOURCE_BRANCH='playstore', VERSION=name, GITHUB_OUTPUT=str(output), + GITHUB_RUN_NUMBER='4000000000', PLAY_VERSION_CODE_BASE='999999999') + subprocess.run(['bash', '-c', source], cwd=ROOT, env=environment, check=True, capture_output=True) + values = dict(line.split('=', 1) for line in output.read_text().splitlines()) + self.assertEqual(code, values['version_code']) + self.assertEqual(name, values['version']) + if __name__ == '__main__': unittest.main()