Add CI workflow
This commit is contained in:
108
.gitea/workflows/publish.yml
Normal file
108
.gitea/workflows/publish.yml
Normal file
@ -0,0 +1,108 @@
|
||||
name: 🚀 Créer une nouvelle version
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: 'Nom du tag (ex: v1.2.3)'
|
||||
required: true
|
||||
branche:
|
||||
description: 'Branche cible (ex: master)'
|
||||
default: 'master'
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: 📦 Cloner le dépôt
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: 🔧 Préparation de Git (récupération des tags)
|
||||
run: git fetch --tags
|
||||
|
||||
- name: 🔖 Détection du dernier tag existant
|
||||
id: dernier-tag
|
||||
run: |
|
||||
TAG=$(git describe --tags --abbrev=0 || echo "")
|
||||
echo "dernier_tag=$TAG" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: 📝 Liste des modifications depuis le dernier tag
|
||||
id: changelog
|
||||
run: |
|
||||
FROM_TAG=${{ steps.dernier-tag.outputs.dernier_tag }}
|
||||
if [ -z "$FROM_TAG" ]; then
|
||||
LOG=$(git log --oneline)
|
||||
else
|
||||
LOG=$(git log "$FROM_TAG"..HEAD --oneline)
|
||||
fi
|
||||
echo "modifications<<EOF" >> $GITHUB_OUTPUT
|
||||
echo "$LOG" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: 🔍️ Extraire les informations de l’application
|
||||
id: extraire-info-gradle
|
||||
run: |
|
||||
# Extraction du nom de l’application
|
||||
APP_NAME=$(grep 'rootProject.name' settings.gradle | sed -E 's/.*= "(.*)"/\1/')
|
||||
|
||||
# Extraction de compileSdkVersion (nombre uniquement)
|
||||
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
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '11'
|
||||
|
||||
- name: 🤖 Installer Android SDK
|
||||
uses: android/setup-android@v2
|
||||
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)
|
||||
run: ./gradlew assembleRelease
|
||||
|
||||
- name: 🏷️ Renommer l’APK avec le nom de l’application et le tag
|
||||
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: 📦 Création de la version sur Gitea
|
||||
id: creation-release
|
||||
env:
|
||||
REGISTRY_URL: ${{ vars.REGISTRY_URL }}
|
||||
REPO: ${{ vars.REGISTRY_REPOSITORY }}
|
||||
TOKEN: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
COMMITS: ${{ steps.changelog.outputs.modifications }}
|
||||
run: |
|
||||
TAG_NAME="${{ github.event.inputs.tag }}"
|
||||
BRANCHE="${{ github.event.inputs.branche }}"
|
||||
|
||||
REPONSE=$(curl -s -X POST "https://$REGISTRY_URL/api/v1/repos/$REPO/releases" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: token $TOKEN" \
|
||||
-d '{
|
||||
"tag_name": "'"$TAG_NAME"'",
|
||||
"target": "'"$BRANCHE"'",
|
||||
"title": "Version '"$TAG_NAME"'",
|
||||
"note": "'"$COMMITS"'"
|
||||
}')
|
||||
|
||||
ID_RELEASE=$(echo "$REPONSE" | jq -r .id)
|
||||
echo "id_release=$ID_RELEASE" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: 📤 Téléversement de l’APK dans la version
|
||||
env:
|
||||
GITEA_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
|
Reference in New Issue
Block a user