Skip to content

Commit 339aff1

Browse files
Merge pull request #82 from hhftechnology/dev
Android/IOS App Release
2 parents 57774d7 + 960d044 commit 339aff1

231 files changed

Lines changed: 27225 additions & 7 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/docker-publish.yml

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,20 @@ on:
55
branches:
66
- main
77
- dev
8-
- pangolin
8+
paths:
9+
- 'Dockerfile'
10+
- '.github/workflows/docker-publish.yml'
11+
- 'web/**'
12+
- 'internal/**'
13+
- 'cmd/**'
14+
- 'config/**'
15+
- 'scripts/**'
16+
- 'go.mod'
17+
- 'go.sum'
18+
- '*.go'
19+
- 'data/**'
20+
- 'docs/**'
21+
922
tags:
1023
- 'v*'
1124
pull_request:
@@ -17,9 +30,10 @@ env:
1730

1831
jobs:
1932
build-and-push:
33+
if: github.actor != 'github-actions[bot]'
2034
runs-on: ubuntu-latest
2135
permissions:
22-
contents: read
36+
contents: write
2337
packages: write
2438

2539
steps:
@@ -76,3 +90,47 @@ jobs:
7690
cache-from: type=gha
7791
cache-to: type=gha,mode=max
7892
platforms: linux/amd64,linux/arm64
93+
94+
- name: Build image for size calculation (linux/amd64)
95+
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/heads/')
96+
uses: docker/build-push-action@v6
97+
with:
98+
context: .
99+
file: ./Dockerfile
100+
push: false
101+
load: true
102+
tags: local/${{ env.IMAGE_NAME }}:size-${{ github.sha }}
103+
cache-from: type=gha
104+
platforms: linux/amd64
105+
106+
- name: Calculate image size
107+
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/heads/')
108+
id: image_size
109+
shell: bash
110+
run: |
111+
IMAGE_REF="local/${{ env.IMAGE_NAME }}:size-${{ github.sha }}"
112+
SIZE_BYTES="$(docker image inspect "${IMAGE_REF}" --format='{{.Size}}')"
113+
SIZE_HUMAN="$(numfmt --to=iec --suffix=B "${SIZE_BYTES}")"
114+
echo "Computed image size: ${SIZE_HUMAN}"
115+
echo "size_human=${SIZE_HUMAN}" >> "${GITHUB_OUTPUT}"
116+
117+
- name: Update README image size
118+
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/heads/')
119+
shell: bash
120+
run: |
121+
SIZE="${{ steps.image_size.outputs.size_human }}"
122+
sed -i -E "s|(<!-- IMAGE_SIZE_START -->)[^<]*(<!-- IMAGE_SIZE_END -->)|\1${SIZE}\2|" README.md
123+
124+
- name: Commit README image size update
125+
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/heads/')
126+
shell: bash
127+
run: |
128+
if git diff --quiet -- README.md; then
129+
echo "README image size is already up to date"
130+
exit 0
131+
fi
132+
git config user.name "github-actions[bot]"
133+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
134+
git add README.md
135+
git commit -m "chore(readme): update image size [skip ci]"
136+
git push

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ CrowdSec Manager is a web-based management interface for CrowdSec operations, Tr
1414

1515
## Stable release
1616

17-
- Current baseline: `2.3.0`
18-
- Multi-proxy support: not available in this release
17+
- Current baseline: `2.3.1`
18+
- Multi-proxy support: hhftechnology/crowdsec-manager:independent
19+
- Docker image size (linux/amd64): <!-- IMAGE_SIZE_START -->44MB<!-- IMAGE_SIZE_END -->
1920

2021
### Crowdsec-Manager mobile app.
2122

mobile/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

mobile/android/.gitignore

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Using Android gitignore template: https://github.com/github/gitignore/blob/HEAD/Android.gitignore
2+
3+
# Built application files
4+
*.apk
5+
*.aar
6+
*.ap_
7+
*.aab
8+
9+
# Files for the ART/Dalvik VM
10+
*.dex
11+
12+
# Java class files
13+
*.class
14+
15+
# Generated files
16+
bin/
17+
gen/
18+
out/
19+
# Uncomment the following line in case you need and you don't have the release build type files in your app
20+
# release/
21+
22+
# Gradle files
23+
.gradle/
24+
build/
25+
26+
# Local configuration file (sdk path, etc)
27+
local.properties
28+
29+
# Proguard folder generated by Eclipse
30+
proguard/
31+
32+
# Log Files
33+
*.log
34+
35+
# Android Studio Navigation editor temp files
36+
.navigation/
37+
38+
# Android Studio captures folder
39+
captures/
40+
41+
# IntelliJ
42+
*.iml
43+
.idea/workspace.xml
44+
.idea/tasks.xml
45+
.idea/gradle.xml
46+
.idea/assetWizardSettings.xml
47+
.idea/dictionaries
48+
.idea/libraries
49+
# Android Studio 3 in .gitignore file.
50+
.idea/caches
51+
.idea/modules.xml
52+
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
53+
.idea/navEditor.xml
54+
55+
# Keystore files
56+
# Uncomment the following lines if you do not want to check your keystore files in.
57+
#*.jks
58+
#*.keystore
59+
60+
# External native build folder generated in Android Studio 2.2 and later
61+
.externalNativeBuild
62+
.cxx/
63+
64+
# Google Services (e.g. APIs or Firebase)
65+
# google-services.json
66+
67+
# Freeline
68+
freeline.py
69+
freeline/
70+
freeline_project_description.json
71+
72+
# fastlane
73+
fastlane/report.xml
74+
fastlane/Preview.html
75+
fastlane/screenshots
76+
fastlane/test_output
77+
fastlane/readme.md
78+
79+
# Version control
80+
vcs.xml
81+
82+
# lint
83+
lint/intermediates/
84+
lint/generated/
85+
lint/outputs/
86+
lint/tmp/
87+
# lint/reports/
88+
89+
# Android Profiling
90+
*.hprof
91+
92+
# Cordova plugins for Capacitor
93+
capacitor-cordova-android-plugins
94+
95+
# Copied web assets
96+
app/src/main/assets/public
97+
98+
# Generated Config files
99+
app/src/main/assets/capacitor.config.json
100+
app/src/main/assets/capacitor.plugins.json
101+
app/src/main/res/xml/config.xml

mobile/android/app/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/build/*
2+
!/build/.npmkeep

mobile/android/app/build.gradle

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
apply plugin: 'com.android.application'
2+
3+
import groovy.json.JsonSlurper
4+
5+
def getPackage() {
6+
def packageFile = file("../../package.json")
7+
if (packageFile.exists()) {
8+
return new JsonSlurper().parseText(packageFile.text)
9+
}
10+
return null
11+
}
12+
13+
def packageJson = getPackage()
14+
def version = packageJson ? packageJson.version : "1.0.0"
15+
16+
def versionParts = version.tokenize('.')
17+
def major = versionParts[0].toInteger()
18+
def minor = versionParts[1].toInteger()
19+
def patch = versionParts[2].toInteger()
20+
21+
def generatedVersionCode = major * 10000 + minor * 100 + patch
22+
def generatedVersionName = version
23+
24+
android {
25+
namespace "com.crowdsec.manager.mobile"
26+
compileSdk rootProject.ext.compileSdkVersion
27+
defaultConfig {
28+
applicationId "com.crowdsec.manager.mobile"
29+
minSdkVersion rootProject.ext.minSdkVersion
30+
targetSdkVersion rootProject.ext.targetSdkVersion
31+
versionCode generatedVersionCode
32+
versionName generatedVersionName
33+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
34+
aaptOptions {
35+
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
36+
// Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
37+
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
38+
}
39+
}
40+
buildTypes {
41+
release {
42+
minifyEnabled true
43+
shrinkResources true
44+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
45+
if (project.hasProperty('RELEASE_STORE_FILE'))
46+
signingConfig signingConfigs.release
47+
}
48+
}
49+
}
50+
51+
repositories {
52+
flatDir{
53+
dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
54+
}
55+
}
56+
57+
dependencies {
58+
implementation fileTree(include: ['*.jar'], dir: 'libs')
59+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
60+
implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
61+
implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
62+
implementation project(':capacitor-android')
63+
testImplementation "junit:junit:$junitVersion"
64+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
65+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
66+
implementation project(':capacitor-cordova-android-plugins')
67+
}
68+
69+
apply from: 'capacitor.build.gradle'
70+
71+
try {
72+
def servicesJSON = file('google-services.json')
73+
if (servicesJSON.text) {
74+
apply plugin: 'com.google.gms.google-services'
75+
}
76+
} catch(Exception e) {
77+
logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
78+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
2+
3+
android {
4+
compileOptions {
5+
sourceCompatibility JavaVersion.VERSION_21
6+
targetCompatibility JavaVersion.VERSION_21
7+
}
8+
}
9+
10+
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
11+
dependencies {
12+
implementation project(':capacitor-app')
13+
implementation project(':capacitor-haptics')
14+
implementation project(':capacitor-keyboard')
15+
implementation project(':capacitor-splash-screen')
16+
implementation project(':capacitor-status-bar')
17+
18+
}
19+
20+
21+
if (hasProperty('postBuildExtras')) {
22+
postBuildExtras()
23+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.getcapacitor.myapp;
2+
3+
import static org.junit.Assert.*;
4+
5+
import android.content.Context;
6+
import androidx.test.ext.junit.runners.AndroidJUnit4;
7+
import androidx.test.platform.app.InstrumentationRegistry;
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
15+
*/
16+
@RunWith(AndroidJUnit4.class)
17+
public class ExampleInstrumentedTest {
18+
19+
@Test
20+
public void useAppContext() throws Exception {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
23+
24+
assertEquals("com.getcapacitor.app", appContext.getPackageName());
25+
}
26+
}

0 commit comments

Comments
 (0)