diff --git a/.github/workflows/code_freeze.yml b/.github/workflows/code_freeze.yml index 9f99e65808..a6502013af 100644 --- a/.github/workflows/code_freeze.yml +++ b/.github/workflows/code_freeze.yml @@ -56,7 +56,8 @@ jobs: -H "Content-Type: application/json" \ -d "{ \"data\": { \"name\": \"$task_name\" }}" \ | jq -r .data.new_task.gid)" - echo "asana_task_url=https://app.asana.com/0/0/${asana_task_id}/f" >> $GITHUB_OUTPUT + echo "asana_task_id=${asana_task_id}" >> $GITHUB_OUTPUT + echo "asana_task_url=https://app.asana.com/0/0/${asana_task_id}/f" >> $GITHUB_OUTPUT curl -fLSs -X POST "https://app.asana.com/api/1.0/sections/${{ vars.MACOS_APP_DEVELOPMENT_RELEASE_SECTION_ID }}/addTask" \ -H "Authorization: Bearer ${{ env.ASANA_ACCESS_TOKEN }}" \ @@ -73,6 +74,12 @@ jobs: --output /dev/null \ -d "{ \"data\": { \"assignee\": \"$assignee_id\" }}" + - name: Populate release contents + env: + ASANA_ACCESS_TOKEN: ${{ secrets.ASANA_ACCESS_TOKEN }} + run: | + ./scripts/update_this_release_includes.sh ${{ steps.create_release_task.outputs.asana_task_id }} + run_tests: name: Run Tests diff --git a/scripts/extract_release_notes.sh b/scripts/extract_release_notes.sh index fba7600977..175cbf5ee0 100755 --- a/scripts/extract_release_notes.sh +++ b/scripts/extract_release_notes.sh @@ -6,7 +6,7 @@ # cat release_task_description.txt | ./extract_release_notes.sh # -notes_start="release notes:" +notes_start="release notes" notes_end="this release includes:" is_release_notes=0 has_release_notes=0 diff --git a/scripts/update_this_release_includes.sh b/scripts/update_this_release_includes.sh new file mode 100755 index 0000000000..b34064ea47 --- /dev/null +++ b/scripts/update_this_release_includes.sh @@ -0,0 +1,92 @@ +#!/bin/bash +# +# This script extracts release notes from Asana release task description. +# +# Usage: +# ./update_this_release_includes.sh +# + +set -e -o pipefail + +ASANA_ACCESS_TOKEN="1/14371688810375:01ca08516a957e423eed3fbc99ada1db" +task_url_regex='^https://app.asana.com/[0-9]/[0-9]*/([0-9]*)/f$' +cwd="$(dirname "${BASH_SOURCE[0]}")" +release_task_id="$1" + +if [[ -z "$release_task_id" ]]; then + echo "Usage: $0 " + exit 1 +fi + +get_task_id() { + local url="$1" + if [[ "$url" =~ ${task_url_regex} ]]; then + echo "${BASH_REMATCH[1]}" + fi +} + +fetch_current_release_notes() { + curl -fLSs "https://app.asana.com/api/1.0/tasks/${release_task_id}?opt_fields=notes" \ + -H "Authorization: Bearer ${ASANA_ACCESS_TOKEN}" \ + | jq -r .data.notes \ + | "${cwd}"/extract_release_notes.sh +} + +construct_task_description() { + local release_notes=("$@") + local escaped_release_note + printf '%s' '

Release notes

' + if [[ -n "${release_notes[*]}" ]]; then + printf '%s' '' + fi + + printf '%s' '

This release includes:

' + + # if task_urls is not empty + if [[ -n "${task_urls[*]}" ]]; then + printf '%s' '' + fi + + printf '%s' '' +} + +fetch_task_urls() { + git fetch -q --tags + last_release_tag="$(gh api /repos/duckduckgo/macos-browser/releases/latest --jq .tag_name)" + + task_urls= + # shellcheck disable=SC2046 + read -ra task_urls <<< $(git log "${last_release_tag}"..HEAD | grep 'Task.*URL' | awk '{ print $3; }' | grep asana | uniq) +} + +main() { + fetch_task_urls + local release_notes=() + local html_notes + local request_payload + # shellcheck disable=SC2046 + while read -r line; do + release_notes+=("$line") + done <<< "$(fetch_current_release_notes)" + html_notes="$(construct_task_description "${release_notes[@]}")" + request_payload="{\"data\":{\"html_notes\":\"${html_notes}\"}}" + + curl -fLSs -X PUT "https://app.asana.com/api/1.0/tasks/${release_task_id}?opt_fields=permalink_url" \ + -H 'Content-Type: application/json' \ + -H "Authorization: Bearer ${ASANA_ACCESS_TOKEN}" \ + -d "$request_payload" +} + +main \ No newline at end of file