Compare commits
2 Commits
3.0
...
484e84ebe1
| Author | SHA1 | Date | |
|---|---|---|---|
| 484e84ebe1 | |||
| d519208439 |
@ -6,6 +6,10 @@ on:
|
|||||||
tag:
|
tag:
|
||||||
description: 'Nom du tag (ex: v1.2.3)'
|
description: 'Nom du tag (ex: v1.2.3)'
|
||||||
required: true
|
required: true
|
||||||
|
branche:
|
||||||
|
description: 'Branche cible (ex: master)'
|
||||||
|
default: 'master'
|
||||||
|
required: true
|
||||||
build_apk:
|
build_apk:
|
||||||
description: 'Compiler et publier l’APK ?'
|
description: 'Compiler et publier l’APK ?'
|
||||||
required: true
|
required: true
|
||||||
@ -29,23 +33,11 @@ jobs:
|
|||||||
- name: 🔧 Préparation de Git (tags)
|
- name: 🔧 Préparation de Git (tags)
|
||||||
run: git fetch --tags
|
run: git fetch --tags
|
||||||
|
|
||||||
- name: 🏷️ Créer le tag si nécessaire
|
|
||||||
run: |
|
|
||||||
TAG="${{ github.event.inputs.tag }}"
|
|
||||||
if git rev-parse "$TAG" >/dev/null 2>&1; then
|
|
||||||
echo "Le tag $TAG existe déjà, pas besoin de le créer."
|
|
||||||
else
|
|
||||||
git config user.name "github-actions"
|
|
||||||
git config user.email "github-actions@github.com"
|
|
||||||
git tag "$TAG"
|
|
||||||
git push origin "$TAG"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: 🔖 Détection du tag précédent
|
- name: 🔖 Détection du tag précédent
|
||||||
id: tag-precedent
|
id: tag-precedent
|
||||||
run: |
|
run: |
|
||||||
TARGET_TAG="${{ github.event.inputs.tag }}"
|
CURRENT_TAG="${{ github.event.inputs.tag }}"
|
||||||
TAGS=$(git tag --sort=creatordate)
|
TAGS=$(git tag --sort=-creatordate)
|
||||||
|
|
||||||
if [ -z "$TAGS" ]; then
|
if [ -z "$TAGS" ]; then
|
||||||
echo "Aucun tag existant détecté."
|
echo "Aucun tag existant détecté."
|
||||||
@ -54,16 +46,19 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
PREV_TAG=""
|
PREV_TAG=""
|
||||||
|
FOUND=false
|
||||||
|
|
||||||
for tag in $TAGS; do
|
for tag in $TAGS; do
|
||||||
if [ "$tag" != "$TARGET_TAG" ]; then
|
if [ "$FOUND" = true ]; then
|
||||||
PREV_TAG=$tag
|
PREV_TAG=$tag
|
||||||
else
|
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
if [ "$tag" = "$CURRENT_TAG" ]; then
|
||||||
|
FOUND=true
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "tag_precedent=$PREV_TAG" | tee -a $GITHUB_OUTPUT
|
echo "tag_precedent=$PREV_TAG" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: 📝 Liste des modifications
|
- name: 📝 Liste des modifications
|
||||||
id: changelog
|
id: changelog
|
||||||
@ -86,6 +81,18 @@ jobs:
|
|||||||
echo "$LOG" >> $GITHUB_OUTPUT
|
echo "$LOG" >> $GITHUB_OUTPUT
|
||||||
echo "EOF" >> $GITHUB_OUTPUT
|
echo "EOF" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: 🏷️ Créer le tag si nécessaire
|
||||||
|
run: |
|
||||||
|
TAG="${{ github.event.inputs.tag }}"
|
||||||
|
if git rev-parse "$TAG" >/dev/null 2>&1; then
|
||||||
|
echo "Le tag $TAG existe déjà, pas besoin de le créer."
|
||||||
|
else
|
||||||
|
git config user.name "github-actions"
|
||||||
|
git config user.email "github-actions@github.com"
|
||||||
|
git tag "$TAG"
|
||||||
|
git push origin "$TAG"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: 📦 Création de la version sur Gitea
|
- name: 📦 Création de la version sur Gitea
|
||||||
id: creation-release
|
id: creation-release
|
||||||
env:
|
env:
|
||||||
@ -95,6 +102,7 @@ jobs:
|
|||||||
COMMITS: ${{ steps.changelog.outputs.modifications }}
|
COMMITS: ${{ steps.changelog.outputs.modifications }}
|
||||||
run: |
|
run: |
|
||||||
TAG_NAME="${{ github.event.inputs.tag }}"
|
TAG_NAME="${{ github.event.inputs.tag }}"
|
||||||
|
BRANCHE="${{ github.event.inputs.branche }}"
|
||||||
|
|
||||||
# Échappement du contenu pour JSON
|
# Échappement du contenu pour JSON
|
||||||
DESCRIPTION="Changelog:"$'\n'"$COMMITS"
|
DESCRIPTION="Changelog:"$'\n'"$COMMITS"
|
||||||
@ -105,6 +113,7 @@ jobs:
|
|||||||
-H "Authorization: token $TOKEN" \
|
-H "Authorization: token $TOKEN" \
|
||||||
-d "{
|
-d "{
|
||||||
\"tag_name\": \"$TAG_NAME\",
|
\"tag_name\": \"$TAG_NAME\",
|
||||||
|
\"target\": \"$BRANCHE\",
|
||||||
\"name\": \"Version $TAG_NAME\",
|
\"name\": \"Version $TAG_NAME\",
|
||||||
\"body\": $ESCAPED_DESCRIPTION
|
\"body\": $ESCAPED_DESCRIPTION
|
||||||
}")
|
}")
|
||||||
@ -122,10 +131,8 @@ jobs:
|
|||||||
APP_NAME=$(grep 'rootProject.name' settings.gradle | sed -E 's/.*= "(.*)"/\1/')
|
APP_NAME=$(grep 'rootProject.name' settings.gradle | sed -E 's/.*= "(.*)"/\1/')
|
||||||
COMPILE_SDK_VERSION=$(grep 'compileSdk' app/build.gradle | grep -oE '[0-9]+')
|
COMPILE_SDK_VERSION=$(grep 'compileSdk' app/build.gradle | grep -oE '[0-9]+')
|
||||||
|
|
||||||
{
|
echo "app_name=$APP_NAME" >> $GITHUB_OUTPUT
|
||||||
echo "app_name=$APP_NAME"
|
echo "compile_sdk_version=$COMPILE_SDK_VERSION" >> $GITHUB_OUTPUT
|
||||||
echo "sdk=$COMPILE_SDK_VERSION"
|
|
||||||
} | tee -a $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: ☕ Configurer Java
|
- name: ☕ Configurer Java
|
||||||
if: ${{ github.event.inputs.build_apk == 'oui' }}
|
if: ${{ github.event.inputs.build_apk == 'oui' }}
|
||||||
@ -138,42 +145,27 @@ jobs:
|
|||||||
if: ${{ github.event.inputs.build_apk == 'oui' }}
|
if: ${{ github.event.inputs.build_apk == 'oui' }}
|
||||||
uses: android-actions/setup-android@v3
|
uses: android-actions/setup-android@v3
|
||||||
with:
|
with:
|
||||||
api-level: ${{ steps.extraire-info-gradle.outputs.sdk }}
|
api-level: ${{ steps.extraire-info-gradle.outputs.compile_sdk_version }}
|
||||||
build-tools-version: ${{ steps.extraire-info-gradle.outputs.sdk }}.0.3
|
build-tools-version: ${{ steps.extraire-info-gradle.outputs.compile_sdk_version }}.0.3
|
||||||
|
|
||||||
- name: 🛠️ Compilation de l’application (APK)
|
- name: 🛠️ Compilation de l’application (APK)
|
||||||
if: ${{ github.event.inputs.build_apk == 'oui' }}
|
if: ${{ github.event.inputs.build_apk == 'oui' }}
|
||||||
run: ./gradlew assembleRelease
|
run: ./gradlew assembleRelease
|
||||||
|
|
||||||
- name: 🏷️ Renommer l’APK avec le nom de l’application et le tag
|
- name: 🏷️ Renommer l’APK avec le nom de l’application et le tag
|
||||||
id: renommer-apk
|
|
||||||
if: ${{ github.event.inputs.build_apk == 'oui' }}
|
if: ${{ github.event.inputs.build_apk == 'oui' }}
|
||||||
run: |
|
run: |
|
||||||
APP_NAME=${{ steps.extraire-info-gradle.outputs.app_name }}
|
mv app/build/outputs/apk/release/app-release.apk app/build/outputs/apk/release/${{ steps.extraire-info-gradle.outputs.app_name }}_${{ github.event.inputs.tag }}.apk
|
||||||
TAG=${{ github.event.inputs.tag }}
|
|
||||||
APK_DIR="app/build/outputs/apk/release"
|
|
||||||
|
|
||||||
APKs=""
|
|
||||||
for apk in "$APK_DIR"/*.apk; do
|
|
||||||
BASENAME=$(basename "$apk") # ex: app-release-unsigned.apk
|
|
||||||
SUFFIX=${BASENAME#app} # ex: -release-unsigned.apk
|
|
||||||
NEW_NAME="${APP_NAME}${SUFFIX%\.apk}_${TAG}.apk" # ex: MonApp-release-unsigned_v1.2.3.apk
|
|
||||||
mv "$apk" "$APK_DIR/$NEW_NAME"
|
|
||||||
APKs+=" $APK_DIR/$NEW_NAME"
|
|
||||||
done
|
|
||||||
echo "📦 Liste des apks : $APKs"
|
|
||||||
echo "apk_files=$APKs" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: 📤 Téléversement de l’APK dans la version
|
- name: 📤 Téléversement de l’APK dans la version
|
||||||
if: ${{ github.event.inputs.build_apk == 'oui' }}
|
if: ${{ github.event.inputs.build_apk == 'oui' }}
|
||||||
env:
|
env:
|
||||||
REGISTRY_URL: ${{ vars.REGISTRY_URL }}
|
GITEA_URL: ${{ vars.REGISTRY_URL }}
|
||||||
REPO: ${{ vars.REGISTRY_REPOSITORY }}
|
REPO: ${{ vars.REGISTRY_REPOSITORY }}
|
||||||
TOKEN: ${{ secrets.REGISTRY_PASSWORD }}
|
TOKEN: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
RELEASE_ID: ${{ steps.creation-release.outputs.id_release }}
|
RELEASE_ID: ${{ steps.creation-release.outputs.id_release }}
|
||||||
run: |
|
run: |
|
||||||
for apk in ${{ steps.renommer-apk.outputs.apk_files }}; do
|
curl -s -X POST "$GITEA_URL/api/v1/repos/$REPO/releases/$RELEASE_ID/assets" \
|
||||||
curl -s -X POST "https://$REGISTRY_URL/api/v1/repos/$REPO/releases/$RELEASE_ID/assets" \
|
-H "Authorization: token $TOKEN" \
|
||||||
-H "Authorization: token $TOKEN" \
|
-F attachment=@app/build/outputs/apk/release/${{ steps.extraire-info-gradle.outputs.app_name }}_${{ github.event.inputs.tag }}.apk
|
||||||
-F attachment=@"$apk"
|
|
||||||
done
|
|
||||||
|
|||||||
@ -7,14 +7,14 @@ android {
|
|||||||
minSdkVersion 27
|
minSdkVersion 27
|
||||||
targetSdkVersion 35
|
targetSdkVersion 35
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "3.0"
|
versionName "2.0"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
minifyEnabled true
|
minifyEnabled false
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
|
|
||||||
<uses-permission
|
<uses-permission
|
||||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||||
android:maxSdkVersion="28" />
|
android:maxSdkVersion="28" />
|
||||||
@ -20,8 +19,8 @@
|
|||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme">
|
||||||
<service
|
<service
|
||||||
android:name=".TransferService"
|
android:name=".TransferService"
|
||||||
android:exported="false"
|
android:enabled="true"
|
||||||
android:foregroundServiceType="dataSync" />
|
android:exported="true" />
|
||||||
<!-- android:usesCleartextTraffic="true" -->
|
<!-- android:usesCleartextTraffic="true" -->
|
||||||
<provider
|
<provider
|
||||||
android:name="androidx.core.content.FileProvider"
|
android:name="androidx.core.content.FileProvider"
|
||||||
|
|||||||
@ -20,7 +20,7 @@ public class TransferService extends Service {
|
|||||||
|
|
||||||
Intent notificationIntent = new Intent(this, MainActivity.class);
|
Intent notificationIntent = new Intent(this, MainActivity.class);
|
||||||
PendingIntent pendingIntent = PendingIntent.getActivity(this,
|
PendingIntent pendingIntent = PendingIntent.getActivity(this,
|
||||||
0, notificationIntent, PendingIntent.FLAG_IMMUTABLE);
|
0, notificationIntent, 0);
|
||||||
|
|
||||||
Notification notification = new NotificationCompat.Builder(this, "CHANNEL_ID")
|
Notification notification = new NotificationCompat.Builder(this, "CHANNEL_ID")
|
||||||
.setContentIntent(pendingIntent)
|
.setContentIntent(pendingIntent)
|
||||||
|
|||||||
Reference in New Issue
Block a user