mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-01-23 02:36:05 +00:00
build: add script to auto bump android version
This commit is contained in:
parent
c9f1ac3503
commit
869fd120bf
3 changed files with 86 additions and 1 deletions
8
fastlane/metadata/android/en-US/changelogs/100101.txt
Normal file
8
fastlane/metadata/android/en-US/changelogs/100101.txt
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
### Bug Fixes
|
||||
|
||||
- **sync:** rev check code #3661 #3660
|
||||
### Features
|
||||
|
||||
- **android:** improve error handling in request interceptor 3657
|
||||
- **android:** prepare auto builds
|
||||
- changes the separators when the user is typing
|
||||
|
|
@ -79,7 +79,7 @@
|
|||
"install:android:prod": "adb install -r android/app/build/outputs/apk/fdroid/release/app-fdroid-release.apk && echo 'Production APK installed successfully.'",
|
||||
"release": "npm run release.changelog && npm run dist",
|
||||
"release.changelog": "conventional-changelog -i CHANGELOG.md -s -p angular",
|
||||
"version": "npm run prebuild && npm run release.changelog && git add -A",
|
||||
"version": "npm run prebuild && npm run release.changelog && node ./tools/bump-android-version.js && git add -A",
|
||||
"buildSchema": "cd tools/schematics && npm run build && cd ../../ && npm i file:./tools/schematics --legacy-peer-deps",
|
||||
"int": "node ./tools/extract-i18n-single.js",
|
||||
"int:watch": "node ./tools/extract-i18n-watch.js",
|
||||
|
|
|
|||
77
tools/bump-android-version.js
Normal file
77
tools/bump-android-version.js
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// Read the version from package.json
|
||||
const packageJson = require('../package.json');
|
||||
const version = packageJson.version;
|
||||
|
||||
// Define the path to build.gradle
|
||||
const gradleFilePath = path.join(__dirname, '..', 'android', 'app', 'build.gradle');
|
||||
|
||||
// Read the build.gradle file
|
||||
let gradleFileContent = fs.readFileSync(gradleFilePath, 'utf8');
|
||||
|
||||
// Update the versionCode and versionName
|
||||
const versionCodeDroid = version
|
||||
.split('.')
|
||||
.map((num) => num.padStart(2, '0'))
|
||||
.join('');
|
||||
|
||||
gradleFileContent = gradleFileContent.replace(
|
||||
/versionCode \d+/g,
|
||||
`versionCode ${versionCodeDroid}`,
|
||||
);
|
||||
gradleFileContent = gradleFileContent.replace(
|
||||
/versionName "[^"]+"/g,
|
||||
`versionName "${version}"`,
|
||||
);
|
||||
|
||||
// Write the updated content back to build.gradle
|
||||
fs.writeFileSync(gradleFilePath, gradleFileContent, 'utf8');
|
||||
|
||||
console.log(`Updated build.gradle to version ${version}`);
|
||||
|
||||
// CREATE fastlane changelog file
|
||||
// Define the paths
|
||||
const changelogPath = path.join(__dirname, '..', 'CHANGELOG.md');
|
||||
const outputDir = path.join(
|
||||
__dirname,
|
||||
'..',
|
||||
'fastlane',
|
||||
'metadata',
|
||||
'android',
|
||||
'en-US',
|
||||
'changelogs',
|
||||
);
|
||||
const outputFilePath = path.join(outputDir, `${versionCodeDroid}.txt`);
|
||||
|
||||
// Read the changelog.md file
|
||||
const changelogContent = fs.readFileSync(changelogPath, 'utf8');
|
||||
|
||||
// Extract the latest changes
|
||||
const lines = changelogContent.split('\n').slice(2); // Remove the first two lines;
|
||||
let latestChanges = '';
|
||||
let headerCount = 0;
|
||||
|
||||
for (const line of lines) {
|
||||
if (line.startsWith('# [') || line.startsWith('## [')) {
|
||||
headerCount++;
|
||||
if (headerCount === 1) break;
|
||||
}
|
||||
latestChanges += line + '\n';
|
||||
}
|
||||
// Remove all links from the extracted text
|
||||
latestChanges = latestChanges
|
||||
.replace(/\[([^\]]+)\]\([^\)]+\)/g, '$1')
|
||||
.replace(/\s*\([a-f0-9]{7}\)\s*$/gm, '');
|
||||
|
||||
// Ensure the output directory exists
|
||||
if (!fs.existsSync(outputDir)) {
|
||||
fs.mkdirSync(outputDir, { recursive: true });
|
||||
}
|
||||
|
||||
// Write the latest changes to the versioned changelog file
|
||||
fs.writeFileSync(outputFilePath, latestChanges, 'utf8');
|
||||
|
||||
console.log(`Wrote latest changes to ${outputFilePath}`);
|
||||
// console.log(latestChanges);
|
||||
Loading…
Add table
Add a link
Reference in a new issue