2 Commits

Author SHA1 Message Date
7bbf9eb8d7 Update Gradle to 8.9.3, Sdk to 35, Java to 17 and Fix 2025-07-09 15:30:59 +02:00
f39ff35e93 Add CI workflow 2025-07-09 15:30:59 +02:00
2 changed files with 46 additions and 38 deletions

View File

@ -6,10 +6,6 @@ on:
tag:
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 lAPK ?'
required: true
@ -33,11 +29,23 @@ jobs:
- name: 🔧 Préparation de Git (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
id: tag-precedent
run: |
CURRENT_TAG="${{ github.event.inputs.tag }}"
TAGS=$(git tag --sort=-creatordate)
TARGET_TAG="${{ github.event.inputs.tag }}"
TAGS=$(git tag --sort=creatordate)
if [ -z "$TAGS" ]; then
echo "Aucun tag existant détecté."
@ -46,19 +54,16 @@ jobs:
fi
PREV_TAG=""
FOUND=false
for tag in $TAGS; do
if [ "$FOUND" = true ]; then
if [ "$tag" != "$TARGET_TAG" ]; then
PREV_TAG=$tag
else
break
fi
if [ "$tag" = "$CURRENT_TAG" ]; then
FOUND=true
fi
done
echo "tag_precedent=$PREV_TAG" >> $GITHUB_OUTPUT
echo "tag_precedent=$PREV_TAG" | tee -a $GITHUB_OUTPUT
- name: 📝 Liste des modifications
id: changelog
@ -81,18 +86,6 @@ jobs:
echo "$LOG" >> $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
id: creation-release
env:
@ -102,7 +95,6 @@ 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"
@ -113,7 +105,6 @@ jobs:
-H "Authorization: token $TOKEN" \
-d "{
\"tag_name\": \"$TAG_NAME\",
\"target\": \"$BRANCHE\",
\"name\": \"Version $TAG_NAME\",
\"body\": $ESCAPED_DESCRIPTION
}")
@ -131,8 +122,10 @@ jobs:
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" >> $GITHUB_OUTPUT
echo "compile_sdk_version=$COMPILE_SDK_VERSION" >> $GITHUB_OUTPUT
{
echo "app_name=$APP_NAME"
echo "sdk=$COMPILE_SDK_VERSION"
} | tee -a $GITHUB_OUTPUT
- name: ☕ Configurer Java
if: ${{ github.event.inputs.build_apk == 'oui' }}
@ -145,27 +138,42 @@ jobs:
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
api-level: ${{ steps.extraire-info-gradle.outputs.sdk }}
build-tools-version: ${{ steps.extraire-info-gradle.outputs.sdk }}.0.3
- name: 🛠️ Compilation de lapplication (APK)
if: ${{ github.event.inputs.build_apk == 'oui' }}
run: ./gradlew assembleRelease
- name: 🏷️ Renommer lAPK avec le nom de lapplication et le tag
id: renommer-apk
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
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") # 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 lAPK dans la version
if: ${{ github.event.inputs.build_apk == 'oui' }}
env:
GITEA_URL: ${{ vars.REGISTRY_URL }}
REGISTRY_URL: ${{ vars.REGISTRY_URL }}
REPO: ${{ vars.REGISTRY_REPOSITORY }}
TOKEN: ${{ secrets.REGISTRY_PASSWORD }}
RELEASE_ID: ${{ steps.creation-release.outputs.id_release }}
run: |
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
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

View File

@ -7,14 +7,14 @@ android {
minSdkVersion 27
targetSdkVersion 35
versionCode 1
versionName "2.0"
versionName "3.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}