-
Notifications
You must be signed in to change notification settings - Fork 1
/
codemagic.yaml
113 lines (102 loc) · 4.04 KB
/
codemagic.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
workflows:
flutter-app:
name: Android Build
working_directory: frontend/app_student
environment:
flutter: "3.19.2"
xcode: latest
vars:
PROD_API_URL: "https://api.lukasvalois.com"
DEV_API_URL: "https://api-dev.lukasvalois.com"
PROJECT_ROOT: "$CM_BUILD_DIR/frontend/app_student"
android_signing:
- GooglePlayLukas
groups:
- firebase_things
triggering:
events:
- push
branch_patterns:
- pattern: dev
include: true
source: true
scripts:
- name: Set up local.properties
script: |
echo "flutter.sdk=$HOME/programs/flutter" > "$PROJECT_ROOT/android/local.properties"
- name: Get Flutter packages
script: |
flutter packages pub get
- name: Flutter analyze
script: |
flutter analyze
- name: Add Firebase configuration
script: |
#!/usr/bin/env sh
set -e # exit on first failed command
echo $ANDROID_FIREBASE_SECRET | base64 --decode > $PROJECT_ROOT/android/app/google-services.json
- name: Build AAB with Flutter
script: |
flutter build appbundle --release
- name: Publish GitHub release for tag builds
script: |
#!/usr/bin/env zsh
# Publish only for tag builds
if [ -z ${CM_TAG} ]; then
echo "Not a tag build will not publish GitHub release"
exit 0
fi
# See more options about `gh release create` usage from GitHub CLI
# official docs at https://cli.github.com/manual/gh_release_create
gh release create "${CM_TAG}" \
--title "my3iL - ${CM_TAG}" \
--generate-notes \
build/**/outputs/**/*.aab
# Note that you don't need to include title and changelog if you do not want to.
# Any number of artifacts can be included with the release.
- name: Create a changelog
script: |
if [[ -z ${CM_PREVIOUS_COMMIT} ]]
then
echo "No finished builds found to generate changelog" | tee release_notes.txt
else
echo "$(git-changelog generate --previous-commit $CM_PREVIOUS_COMMIT)" | tee release_notes.txt
fi
artifacts:
- build/**/outputs/**/*.aab
- build/**/outputs/**/mapping.txt
- flutter_drive.log
publishing:
email:
recipients:
notify:
success: true
failure: true
scripts:
- name: Discord notification
script: |
set -ex
# Convertir le tableau JSON en une liste de liens
APP_LINKS=$(echo $CM_ARTIFACT_LINKS | jq -r '.[] | .url')
# Convertir la liste de liens en une chaîne avec des sauts de ligne
APP_LINKS=$(echo $APP_LINKS | tr ' ' '\n')
# Get first 7 digits of commit number
COMMIT=$(echo "${CM_COMMIT}" | sed 's/^\(........\).*/\1/;q')
# Get commit message
COMMIT_MESSAGE=$(git log --format=%B -n 1 $CM_COMMIT)
# Get commit author
AUTHOR=$(git show -s --format='%ae' $CM_COMMIT)
# Générer la chaîne JSON avec jq
PAYLOAD_JSON=$(jq -n \
--arg commit "$COMMIT" \
--arg message "$COMMIT_MESSAGE" \
--arg branch "$CM_BRANCH" \
--arg author "$AUTHOR" \
--arg links "$APP_LINKS" \
'{username: "codemagic-bot", content: "@everyone\n**Commit:** `\($commit)`\n\n**Commit message:** \($message)\n\n**Branch:** \($branch)\n\n**Author:** \($author)\n\n**Artifacts: **\n\n\($links)\n\n"}')
# Utiliser PAYLOAD_JSON dans la notification
curl -H "Content-Type: multipart/form-data" \
-F "payload_json=$PAYLOAD_JSON" \
-F "file1=@release_notes.txt" \
$WEBHOOK_URL