From 053a903fb564a62222a427f2d182d1c7fff36c6a Mon Sep 17 00:00:00 2001 From: Lukas Date: Thu, 30 May 2024 23:04:03 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7:=20Discord=20Notification?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- codemagic.yaml | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/codemagic.yaml b/codemagic.yaml index 2182004..61450a4 100644 --- a/codemagic.yaml +++ b/codemagic.yaml @@ -58,24 +58,15 @@ workflows: # 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: Discord notification - script: | - set -ex - APP_LINK=$(echo $CM_ARTIFACT_LINKS | jq -r '.[] | select(.name=="app.aab") | .url') - - # 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) - - # Publish the notification - curl -H "Content-Type: multipart/form-data" \ - -F 'payload_json={"username" : "codemagic-bot", "content": "**Commit:** `'"$COMMIT"'`\n\n**Commit message:** '"$COMMIT_MESSAGE"'\n\n**Branch:** '"$CM_BRANCH"'\n\n**Author:** '"$AUTHOR"'\n\n**Artifacts: **\n\n'"$APP_LINK"'\n\n"}' \ - $WEBHOOK_URL + - 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 @@ -86,4 +77,24 @@ workflows: - lukas.valois@gmail.com notify: success: true - failure: true \ No newline at end of file + failure: true + scripts: + - name: Discord notification + script: | + set -ex + APP_LINK=$(echo $CM_ARTIFACT_LINKS | jq -r '.[] | select(.name=="app.aab") | .url') + + # 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) + + # Publish the notification + curl -H "Content-Type: multipart/form-data" \ + -F 'payload_json={"username" : "codemagic-bot", "content": "**Commit:** `'"$COMMIT"'`\n\n**Commit message:** '"$COMMIT_MESSAGE"'\n\n**Branch:** '"$CM_BRANCH"'\n\n**Author:** '"$AUTHOR"'\n\n**Artifacts: **\n\n'"$APP_LINK"'\n\n"}' \ + -F "file1=@release_notes.txt" \ + $WEBHOOK_URL \ No newline at end of file