Add CI workflow
This commit is contained in:
90
.gitea/workflows/publish.yml
Normal file
90
.gitea/workflows/publish.yml
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
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 le nom de l’application depuis settings.gradle
|
||||||
|
id: extraire-nom-appli
|
||||||
|
run: |
|
||||||
|
APP_NAME=$(grep 'rootProject.name' settings.gradle | sed -E 's/.*= "(.*)"/\1/')
|
||||||
|
echo "app_name=$APP_NAME" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- 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-nom-appli.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-nom-appli.outputs.app_name }}_${{ github.event.inputs.tag }}.apk
|
Reference in New Issue
Block a user