-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dominik/nightly-internal-releases' into dominik/test-ba…
…se-branch
- Loading branch information
Showing
17 changed files
with
407 additions
and
55 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
.github/actions/asana-add-comment/templates/internal-release-complete-with-tasks.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
data: | ||
html_text: | | ||
<body> | ||
Build ${TAG} is now available for internal testing through Sparkle and TestFlight. | ||
Added in this release: | ||
${TASKS_SINCE_LAST_INTERNAL_RELEASE} | ||
<a href='${DMG_URL}'>📥 DMG download link</a> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Find Release Task in Asana | ||
description: | | ||
Searches macOS App Development Asana project for an active release task matching the latest version | ||
(as specified by GitHub releases). Returns an error when no release task is found, or when there's | ||
an active (incomplete) hotfix release task. Tasks are identified by the name. | ||
inputs: | ||
access-token: | ||
description: "Asana access token" | ||
required: true | ||
type: string | ||
github-token: | ||
description: "GitHub Token" | ||
required: false | ||
type: string | ||
outputs: | ||
task-id: | ||
description: "Release task ID" | ||
value: ${{ steps.find-release-task.outputs.task-id }} | ||
task-url: | ||
description: "Release task URL" | ||
value: ${{ steps.find-release-task.outputs.task-url }} | ||
runs: | ||
using: "composite" | ||
steps: | ||
- id: find-release-task | ||
shell: bash | ||
env: | ||
ASANA_ACCESS_TOKEN: ${{ inputs.access-token }} | ||
GITHUB_TOKEN: ${{ inputs.github-token || github.token }} | ||
run: | | ||
${{ github.action_path }}/find-release-task.sh |
93 changes: 93 additions & 0 deletions
93
.github/actions/asana-find-release-task/find_release_task.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#!/bin/bash | ||
# | ||
# This script is used to find the current release task. | ||
# | ||
|
||
set -e | ||
|
||
asana_app_url="https://app.asana.com/0/0" | ||
asana_api_url="https://app.asana.com/api/1.0" | ||
default_release_and_maintenance_section_id="1202202395298964" | ||
|
||
find_latest_marketing_version() { | ||
local latest_tag | ||
latest_tag="$(gh api /repos/duckduckgo/macos-browser/releases?per_page=1 --jq .[0].tag_name)" | ||
echo "${latest_tag%-*}" # remove everything after - (including -) i.e. x.y.z-N becomes x.y.z | ||
} | ||
|
||
# Find the release task in 'Release & Maintenance' section of the 'macOS App Development' Asana project. | ||
# - If there is no release task, return nothing. | ||
# - If there is an active (incomplete) hotfix task, return nothing. | ||
find_release_task() { | ||
local version="$1" | ||
local task_name="macOS App Release ${version}" | ||
local hotfix_task_name_prefix="macOS App Hotfix Release" | ||
local section_id="${RELEASE_AND_MAINTENANCE_SECTION_ID:-$default_release_and_maintenance_section_id}" | ||
|
||
# `completed_since=now` returns only incomplete tasks | ||
local url="${asana_api_url}/sections/${section_id}/tasks?opt_fields=name,created_at&limit=100&completed_since=now" | ||
local response | ||
local hotfix_task_id | ||
local created_at | ||
|
||
# go through all tasks in the section (there may be multiple requests in case there are more than 100 tasks in the section) | ||
# repeat until no more pages (next_page.uri is null) | ||
while true; do | ||
response="$(curl -fLSs "$url" -H "Authorization: Bearer ${ASANA_ACCESS_TOKEN}")" | ||
# echo "$response" | ||
|
||
# find task id only if not found yet | ||
if [[ -z "$release_task_id" || "$release_task_id" == "null" ]]; then | ||
release_task_id="$(jq -r ".data[] | select(.name == \"${task_name}\").gid" <<< "$response")" | ||
created_at="$(jq -r ".data[] | select(.name == \"${task_name}\").created_at" <<< "$response")" | ||
|
||
# Only consider release tasks created in the last 4 days. | ||
# - We don't want to bump internal release automatically for release tasks that are open for more than a week. | ||
# - The automatic check is only done Tuesday-Friday. If the release task is still open next Tuesday, it's unexpected, | ||
# and likely something went wrong. | ||
if [[ -n "$created_at" && "$created_at" != "null" ]]; then | ||
created_at_timestamp="$(TZ=UTC date -j -f "%Y-%m-%dT%H:%M:%S." "$created_at" +%s)" | ||
four_days_ago="$(date -j -v-4d +%s)" | ||
if [[ "$created_at_timestamp" -le "$four_days_ago" ]]; then | ||
echo "::error::Found release task: ${asana_app_url}/${release_task_id} but it's older than 4 days, skipping." | ||
exit 1 | ||
fi | ||
fi | ||
fi | ||
|
||
# find hotfix task id only if not found yet | ||
if [[ -z "$hotfix_task_id" || "$hotfix_task_id" == "null" ]]; then | ||
hotfix_task_id="$(jq -r ".data[] | select(.name | startswith(\"${hotfix_task_name_prefix}\")).gid" <<< "$response")" | ||
fi | ||
|
||
url="$(jq -r .next_page.uri <<< "$response")" | ||
|
||
# break on last page | ||
if [[ "$url" == "null" ]]; then | ||
break | ||
fi | ||
done | ||
|
||
if [[ -n "$hotfix_task_id" && "$hotfix_task_id" != "null" ]]; then | ||
echo "::error::Found active hotfix task: ${asana_app_url}/${hotfix_task_id}" | ||
exit 1 | ||
fi | ||
} | ||
|
||
main() { | ||
local latest_marketing_version | ||
local release_task_id | ||
latest_marketing_version="$(find_latest_marketing_version)" | ||
echo "Latest marketing version: ${latest_marketing_version}" | ||
find_release_task "$latest_marketing_version" | ||
|
||
if [[ -n "$release_task_id" && "$release_task_id" != "null" ]]; then | ||
echo "Found ${latest_marketing_version} release task: ${asana_app_url}/${release_task_id}/f" | ||
echo "task-id=${release_task_id}" >> "$GITHUB_OUTPUT" | ||
echo "task-url=${asana_app_url}/${release_task_id}/f" >> "$GITHUB_OUTPUT" | ||
else | ||
echo "::warning::No release task found for version: ${latest_marketing_version}" | ||
fi | ||
} | ||
|
||
main "%@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.