Skip to content

Commit

Permalink
feat(cicd): add scripts to bump code version
Browse files Browse the repository at this point in the history
  • Loading branch information
azarz committed Dec 15, 2023
1 parent 2e0dab3 commit f28c543
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
push:
tags:
- '**'
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
deploy:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ios-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
push:
tags:
- '**'
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
deploy:
Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "fr.ign.geoportail"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 3
versionName "1.0"
versionCode 29001
versionName "2.90.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
Expand Down
32 changes: 32 additions & 0 deletions bump_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
def updateiOSVesions(version):
with open("ios/App/App.xcodeproj/project.pbxproj", "r", newline="") as file:
lines = file.readlines()
with open("ios/App/App.xcodeproj/project.pbxproj", "w", newline="") as file:
for line in lines:
if 'CURRENT_PROJECT_VERSION = ' in line:
line = ' CURRENT_PROJECT_VERSION = {};\n'.format(version)
if 'MARKETING_VERSION = ' in line:
line = ' MARKETING_VERSION = {};\n'.format(version)
file.write(line)

def updateAndroidVesions(version):
splittedPackage = list(map(int,version.split(".")))
buildnumber = splittedPackage[0] * 10000 + splittedPackage[1] * 100 + splittedPackage[2]
with open("android/app/build.gradle", "r", newline="") as file:
lines = file.readlines()
with open("android/app/build.gradle", "w", newline="") as file:
for line in lines:
if 'versionCode' in line:
line = ' versionCode {}\n'.format(buildnumber)
if 'versionName' in line:
line = ' versionName "{}"\n'.format(version)
file.write(line)

if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("version")
parser.parse_args()
version = parser.parse_args().version
updateiOSVesions(version)
updateAndroidVesions(version)
4 changes: 2 additions & 2 deletions ios/App/App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 2.90;
MARKETING_VERSION = 2.90.1;
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
PRODUCT_BUNDLE_IDENTIFIER = fr.ign.geoportail;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -370,7 +370,7 @@
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 2.90;
MARKETING_VERSION = 2.90.1;
PRODUCT_BUNDLE_IDENTIFIER = fr.ign.geoportail;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "geoportail-app",
"displayName": "Géoportail",
"version": "3.0.0",
"version": "2.90.1",
"description": "Application Géoportail",
"main": "index.js",
"scripts": {
Expand All @@ -10,7 +10,10 @@
"serve:dev": "webpack-dev-server --config webpack.dev.js",
"run:android": "npm run build:dev && npx cap sync && npx cap run android",
"build:android": "npm run build && npx cap sync && cd android && ./gradlew assembleRelease",
"build:android:dev": "npm run build:dev && npx cap sync && cd android && ./gradlew"
"build:android:dev": "npm run build:dev && npx cap sync && cd android && ./gradlew",
"bump:version": "echo 'npm run bump:app:versions -- $1' > temp.sh && echo 'npm version $1 --git-tag-version false' >> temp.sh && echo 'git add -u && git commit -m \"$1\" && git tag v$1' >> temp.sh && sh temp.sh",
"postbump:version": "rm temp.sh",
"bump:app:versions": "python bump_version.py"
},
"keywords": [
"ecosystem:capacitor"
Expand Down

0 comments on commit f28c543

Please sign in to comment.