Skip to content

Commit dfd4edf

Browse files
committed
fix: ensure reproducible builds (deterministic versionCode and base path)
1 parent bba5baf commit dfd4edf

4 files changed

Lines changed: 16 additions & 14 deletions

File tree

.github/workflows/android-release.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ jobs:
2323

2424
- name: Build Web Assets (Vite)
2525
run: npm run build
26-
env:
27-
CAPACITOR_BUILD: 'true'
2826

2927
- name: Generate Android Assets (Icon/Splash)
3028
run: npx -y @capacitor/assets generate --android
@@ -44,18 +42,11 @@ jobs:
4442
- name: Sync Capacitor
4543
run: npx cap sync android
4644

47-
- name: Set Version Code
48-
run: echo "ANDROID_VERSION_CODE=$((GITHUB_RUN_NUMBER + 100))" >> $GITHUB_ENV
49-
env:
50-
GITHUB_RUN_NUMBER: ${{ github.run_number }}
51-
5245
- name: Build with Gradle
5346
run: |
5447
cd android
5548
chmod +x gradlew
5649
./gradlew assembleRelease
57-
env:
58-
ANDROID_VERSION_CODE: ${{ env.ANDROID_VERSION_CODE }}
5950
6051
- name: Sign APK
6152
id: sign_app

.github/workflows/deploy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ jobs:
2525

2626
- name: Build
2727
run: npm run build
28+
env:
29+
VITE_BASE: /PaperKnife/
2830

2931
- name: Deploy
3032
uses: JamesIves/github-pages-deploy-action@v4

android/app/build.gradle

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
apply plugin: 'com.android.application'
22

3+
import groovy.json.JsonSlurper
4+
5+
def getPackageJson() {
6+
def inputFile = new File(project.rootDir, '../package.json')
7+
return new JsonSlurper().parseText(inputFile.text)
8+
}
9+
10+
def packageJson = getPackageJson()
11+
312
android {
4-
namespace = "com.paperknife.app"
5-
compileSdk = rootProject.ext.compileSdkVersion
13+
namespace "com.paperknife.app"
14+
compileSdk rootProject.ext.compileSdkVersion
615
defaultConfig {
716
applicationId "com.paperknife.app"
817
minSdkVersion rootProject.ext.minSdkVersion
918
targetSdkVersion rootProject.ext.targetSdkVersion
10-
versionCode 101
11-
versionName "1.0.1"
19+
versionCode (packageJson.version.split('-')[0].split('\\.').collect { it.toInteger() }.with { (it[0] * 10000) + (it[1] * 100) + it[2] })
20+
versionName packageJson.version
1221
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1322
aaptOptions {
1423
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.

vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default defineConfig({
66
plugins: [
77
react()
88
],
9-
base: process.env.CAPACITOR_BUILD === 'true' ? './' : '/PaperKnife/',
9+
base: process.env.VITE_BASE || './',
1010
server: {
1111
host: true
1212
},

0 commit comments

Comments
 (0)