Compare commits
2 Commits
master
...
74e1c919d4
| Author | SHA1 | Date | |
|---|---|---|---|
| 74e1c919d4 | |||
| eafd87d273 |
@ -1,143 +1,43 @@
|
||||
name: 🚀 Créer une nouvelle version
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: 'Numéro de version (ex: 2.1)'
|
||||
description: 'Nom du tag (ex: v1.2.3)'
|
||||
required: true
|
||||
branche:
|
||||
description: 'Branche cible (ex: master)'
|
||||
default: 'master'
|
||||
required: true
|
||||
build_apk:
|
||||
description: 'Compiler et publier l’APK ?'
|
||||
required: true
|
||||
default: 'oui'
|
||||
type: choice
|
||||
options:
|
||||
- oui
|
||||
- non
|
||||
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: 🚀 Publier une nouvelle version
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: 🔐 Vérification du nom de tag
|
||||
run: |
|
||||
TAG="${{ github.event.inputs.tag }}"
|
||||
if ! [[ "$TAG" =~ ^[0-9]+\.[0-9]+$ ]]; then
|
||||
echo "❌ Format de tag invalide : $TAG"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: 📦 Cloner le dépôt
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
fetch-depth: 0 # important pour récupérer tout l'historique
|
||||
|
||||
- name: 🔧 Préparation de Git
|
||||
run: |
|
||||
git fetch --tags
|
||||
git config user.name "github-actions"
|
||||
git config user.email "."
|
||||
|
||||
- name: 🔎 Vérifier si le tag existe déjà
|
||||
id: tag-existant
|
||||
run: |
|
||||
TAG="${{ github.event.inputs.tag }}"
|
||||
if git rev-parse "$TAG" >/dev/null 2>&1; then
|
||||
echo "❌ Le tag '$TAG' existe déjà."
|
||||
exit 1
|
||||
else
|
||||
echo "✅ Le tag '$TAG' n'existe pas encore, on continue."
|
||||
fi
|
||||
|
||||
- name: 🔍️ Extraire les informations de l’application
|
||||
id: extraire-info-gradle
|
||||
run: |
|
||||
APP_NAME=$(grep 'rootProject.name' settings.gradle | sed -E 's/.*= "(.*)"/\1/')
|
||||
COMPILE_SDK_VERSION=$(grep 'compileSdk' app/build.gradle | grep -oE '[0-9]+')
|
||||
|
||||
{
|
||||
echo "app_name=$APP_NAME"
|
||||
echo "sdk=$COMPILE_SDK_VERSION"
|
||||
} | tee -a $GITHUB_OUTPUT
|
||||
|
||||
- name: ☕ Configurer Java
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
|
||||
- name: 🤖 Installer Android SDK
|
||||
uses: android-actions/setup-android@v3
|
||||
with:
|
||||
api-level: ${{ steps.extraire-info-gradle.outputs.sdk }}
|
||||
build-tools-version: ${{ steps.extraire-info-gradle.outputs.sdk }}.0.3
|
||||
|
||||
- name: 🔐 Récupérer et décoder le keystore
|
||||
id: decode-keystore
|
||||
env:
|
||||
KEYSTORE_B64: ${{ secrets.KEYSTORE_B64 }}
|
||||
run: |
|
||||
echo "$KEYSTORE_B64" | base64 -d > app/keystore.jks
|
||||
ls -1 app/keystore.jks
|
||||
echo "keystore_path=$(realpath app/keystore.jks)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: 📝 Mise à jour de versionName et versionCode
|
||||
run: |
|
||||
TAG="${{ github.event.inputs.tag }}"
|
||||
BUILD_GRADLE_FILE="app/build.gradle"
|
||||
|
||||
# Récupérer tous les tags valides au format X.Y
|
||||
VALID_TAGS=$(git tag -l '[0-9]*.[0-9]*' | wc -l)
|
||||
VERSION_CODE=$((VALID_TAGS + 1))
|
||||
|
||||
echo "🔢 versionCode (depuis nombre de tag) : $VERSION_CODE"
|
||||
echo "🏷️ versionName (depuis nom du tag) : $TAG"
|
||||
|
||||
# Mise à jour dans build.gradle
|
||||
sed -i "s/versionCode [0-9]\+/versionCode $VERSION_CODE/" "$BUILD_GRADLE_FILE"
|
||||
sed -i "s/versionName \".*\"/versionName \"$TAG\"/" "$BUILD_GRADLE_FILE"
|
||||
|
||||
- name: 🛠️ Compilation signée de l’application (APK)
|
||||
env:
|
||||
KEYSTORE_FILE: ${{ steps.decode-keystore.outputs.keystore_path }}
|
||||
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
|
||||
KEY_ALIAS: ${{ secrets.KEYSTORE_ALIAS }}
|
||||
KEY_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
|
||||
run: |
|
||||
./gradlew assembleRelease \
|
||||
-Pandroid.injected.signing.store.file=$KEYSTORE_FILE \
|
||||
-Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD \
|
||||
-Pandroid.injected.signing.key.alias=$KEY_ALIAS \
|
||||
-Pandroid.injected.signing.key.password=$KEY_PASSWORD
|
||||
|
||||
- name: 💾 Commit des modifications de version
|
||||
run: |
|
||||
TAG="${{ github.event.inputs.tag }}"
|
||||
git add app/build.gradle
|
||||
git commit -m "🔖 Bump versionCode et versionName pour $TAG"
|
||||
git push origin HEAD
|
||||
|
||||
- name: 🏷️ Créer le tag
|
||||
run: |
|
||||
TAG="${{ github.event.inputs.tag }}"
|
||||
git tag "$TAG"
|
||||
git push origin "$TAG"
|
||||
|
||||
- name: 🏷️ Renommer l’APK avec le nom de l’application et le tag
|
||||
id: renommer-apk
|
||||
run: |
|
||||
APP_NAME=${{ steps.extraire-info-gradle.outputs.app_name }}
|
||||
TAG=${{ github.event.inputs.tag }}
|
||||
APK_DIR="app/build/outputs/apk/release"
|
||||
|
||||
APKs=""
|
||||
for apk in "$APK_DIR"/*.apk; do
|
||||
BASENAME=$(basename "$apk")
|
||||
SUFFIX=${BASENAME#app}
|
||||
NEW_NAME="${APP_NAME}${SUFFIX%\.apk}_${TAG}.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: 🔧 Préparation de Git (tags)
|
||||
run: git fetch --tags
|
||||
|
||||
- name: 🔖 Détection du tag précédent
|
||||
id: tag-precedent
|
||||
run: |
|
||||
TARGET_TAG="${{ github.event.inputs.tag }}"
|
||||
TAGS=$(git tag --sort=creatordate)
|
||||
CURRENT_TAG="${{ github.event.inputs.tag }}"
|
||||
TAGS=$(git tag --sort=-creatordate)
|
||||
|
||||
if [ -z "$TAGS" ]; then
|
||||
echo "Aucun tag existant détecté."
|
||||
@ -146,16 +46,19 @@ jobs:
|
||||
fi
|
||||
|
||||
PREV_TAG=""
|
||||
FOUND=false
|
||||
|
||||
for tag in $TAGS; do
|
||||
if [ "$tag" != "$TARGET_TAG" ]; then
|
||||
if [ "$FOUND" = true ]; then
|
||||
PREV_TAG=$tag
|
||||
else
|
||||
break
|
||||
fi
|
||||
if [ "$tag" = "$CURRENT_TAG" ]; then
|
||||
FOUND=true
|
||||
fi
|
||||
done
|
||||
|
||||
echo "tag_precedent=$PREV_TAG" | tee -a $GITHUB_OUTPUT
|
||||
echo "tag_precedent=$PREV_TAG" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: 📝 Liste des modifications
|
||||
id: changelog
|
||||
@ -172,13 +75,25 @@ jobs:
|
||||
LOG=$(git log "$PREV_TAG"..HEAD --oneline)
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "$LOG"
|
||||
|
||||
echo "modifications<<EOF" >> $GITHUB_OUTPUT
|
||||
echo "$LOG" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: 📦 Création de la publication sur Gitea
|
||||
- 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
|
||||
id: creation-release
|
||||
env:
|
||||
REGISTRY_URL: ${{ vars.REGISTRY_URL }}
|
||||
@ -187,6 +102,9 @@ jobs:
|
||||
COMMITS: ${{ steps.changelog.outputs.modifications }}
|
||||
run: |
|
||||
TAG_NAME="${{ github.event.inputs.tag }}"
|
||||
BRANCHE="${{ github.event.inputs.branche }}"
|
||||
|
||||
# Échappement du contenu pour JSON
|
||||
DESCRIPTION="Changelog:"$'\n'"$COMMITS"
|
||||
ESCAPED_DESCRIPTION=$(printf '%s\n' "$DESCRIPTION" | jq -Rsa .)
|
||||
|
||||
@ -195,6 +113,7 @@ jobs:
|
||||
-H "Authorization: token $TOKEN" \
|
||||
-d "{
|
||||
\"tag_name\": \"$TAG_NAME\",
|
||||
\"target\": \"$BRANCHE\",
|
||||
\"name\": \"Version $TAG_NAME\",
|
||||
\"body\": $ESCAPED_DESCRIPTION
|
||||
}")
|
||||
@ -202,21 +121,51 @@ jobs:
|
||||
echo "$REPONSE"
|
||||
|
||||
ID_RELEASE=$(echo "$REPONSE" | jq -r .id)
|
||||
if [ -z "$ID_RELEASE" ] || [ "$ID_RELEASE" = "null" ]; then
|
||||
echo "❌ Échec : impossible de récupérer l’ID de la publication depuis Gitea."
|
||||
exit 1
|
||||
fi
|
||||
echo "id_release=$ID_RELEASE" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: 📤 Ajout de l’APK sur la publication
|
||||
|
||||
- name: 🔍️ Extraire les informations de l’application
|
||||
id: extraire-info-gradle
|
||||
if: ${{ github.event.inputs.build_apk == 'oui' }}
|
||||
run: |
|
||||
APP_NAME=$(grep 'rootProject.name' settings.gradle | sed -E 's/.*= "(.*)"/\1/')
|
||||
COMPILE_SDK_VERSION=$(grep 'compileSdkVersion' app/build.gradle | grep -oE '[0-9]+')
|
||||
|
||||
echo "app_name=$APP_NAME" >> $GITHUB_OUTPUT
|
||||
echo "compile_sdk_version=$COMPILE_SDK_VERSION" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: ☕ Configurer Java
|
||||
if: ${{ github.event.inputs.build_apk == 'oui' }}
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
|
||||
- name: 🤖 Installer Android SDK
|
||||
if: ${{ github.event.inputs.build_apk == 'oui' }}
|
||||
uses: android-actions/setup-android@v3
|
||||
with:
|
||||
api-level: ${{ steps.extraire-info-gradle.outputs.compile_sdk_version }}
|
||||
build-tools-version: ${{ steps.extraire-info-gradle.outputs.compile_sdk_version }}.0.3
|
||||
|
||||
- name: 🛠️ Compilation de l’application (APK)
|
||||
if: ${{ github.event.inputs.build_apk == 'oui' }}
|
||||
run: ./gradlew assembleRelease
|
||||
|
||||
- name: 🏷️ Renommer l’APK avec le nom de l’application et le tag
|
||||
if: ${{ github.event.inputs.build_apk == 'oui' }}
|
||||
run: |
|
||||
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
|
||||
|
||||
|
||||
- name: 📤 Téléversement de l’APK dans la version
|
||||
if: ${{ github.event.inputs.build_apk == 'oui' }}
|
||||
env:
|
||||
REGISTRY_URL: ${{ vars.REGISTRY_URL }}
|
||||
GITEA_URL: ${{ vars.REGISTRY_URL }}
|
||||
REPO: ${{ vars.REGISTRY_REPOSITORY }}
|
||||
TOKEN: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
RELEASE_ID: ${{ steps.creation-release.outputs.id_release }}
|
||||
run: |
|
||||
for apk in ${{ steps.renommer-apk.outputs.apk_files }}; do
|
||||
curl -s -X POST "https://$REGISTRY_URL/api/v1/repos/$REPO/releases/$RELEASE_ID/assets" \
|
||||
-H "Authorization: token $TOKEN" \
|
||||
-F attachment=@"$apk"
|
||||
done
|
||||
curl -s -X POST "$GITEA_URL/api/v1/repos/$REPO/releases/$RELEASE_ID/assets" \
|
||||
-H "Authorization: token $TOKEN" \
|
||||
-F attachment=@app/build/outputs/apk/release/${{ steps.extraire-info-gradle.outputs.app_name }}_${{ github.event.inputs.tag }}.apk
|
||||
|
||||
@ -6,25 +6,15 @@ android {
|
||||
applicationId "com.localtransfer"
|
||||
minSdkVersion 27
|
||||
targetSdkVersion 35
|
||||
versionCode 6
|
||||
versionName "3.1"
|
||||
versionCode 1
|
||||
versionName "2.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
release {
|
||||
storeFile file(System.getenv("KEYSTORE_FILE"))
|
||||
storePassword System.getenv("KEYSTORE_PASSWORD")
|
||||
keyAlias System.getenv("KEY_ALIAS")
|
||||
keyPassword System.getenv("KEY_PASSWORD")
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
signingConfig signingConfigs.release
|
||||
minifyEnabled true
|
||||
minifyEnabled false
|
||||
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.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
android:maxSdkVersion="28" />
|
||||
@ -20,8 +19,8 @@
|
||||
android:theme="@style/AppTheme">
|
||||
<service
|
||||
android:name=".TransferService"
|
||||
android:exported="false"
|
||||
android:foregroundServiceType="dataSync" />
|
||||
android:enabled="true"
|
||||
android:exported="true" />
|
||||
<!-- android:usesCleartextTraffic="true" -->
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
|
||||
@ -20,7 +20,7 @@ public class TransferService extends Service {
|
||||
|
||||
Intent notificationIntent = new Intent(this, MainActivity.class);
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(this,
|
||||
0, notificationIntent, PendingIntent.FLAG_IMMUTABLE);
|
||||
0, notificationIntent, 0);
|
||||
|
||||
Notification notification = new NotificationCompat.Builder(this, "CHANNEL_ID")
|
||||
.setContentIntent(pendingIntent)
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
app:title="@string/server_header">
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:defaultValue="false"
|
||||
android:key="protocol"
|
||||
android:title="@string/server_protocol" />
|
||||
<EditTextPreference
|
||||
|
||||
Reference in New Issue
Block a user