Skip to content

Commit

Permalink
Update release workflow to support Apple monorepo (#756)
Browse files Browse the repository at this point in the history
Asana: https://app.asana.com/0/72649045549333/1209197424401946

Description

This PR updates the release workflow to support the Apple monorepo.

There are a few TODOs left deliberately in place, which I'll resolve after the review. They're in place to allow the reviewer to test the workflow manually if desired, without causing noise for other platforms.
  • Loading branch information
samsymons authored Feb 17, 2025
1 parent c6929f2 commit fb06780
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 340 deletions.
181 changes: 44 additions & 137 deletions .github/workflows/asana-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,22 @@ name: Autofill Release Workflow
on:
release:
types: [created]
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name for the release'
required: true
release_url:
description: 'URL for the release'
required: true
release_notes:
description: 'Release notes for the release'
required: true

env:
VERSION: ${{ github.event.release.tag_name }}
RELEASE_URL: ${{ github.event.release.html_url }}
RELEASE_NOTES: ${{ github.event.release.body }}
VERSION: ${{ github.event.inputs.tag_name || github.event.release.tag_name }}
RELEASE_URL: ${{ github.event.inputs.release_url || github.event.release.html_url }}
RELEASE_NOTES: ${{ github.event.inputs.release_notes || github.event.release.body }}

jobs:
# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -60,7 +71,7 @@ jobs:
- name: Update Android autofill reference
run: |
cd android
npm install github:duckduckgo/duckduckgo-autofill#${{ github.event.release.tag_name }}
npm install github:duckduckgo/duckduckgo-autofill#${{ env.VERSION }}
cd ..
- name: Create Android PR Body
env:
Expand All @@ -82,17 +93,17 @@ jobs:
package.json
package-lock.json
node_modules/@duckduckgo/autofill
commit-message: Update autofill to ${{ github.event.release.tag_name }}
branch: update-autofill-${{ github.event.release.tag_name }}
title: Update autofill to ${{ github.event.release.tag_name }}
commit-message: Update autofill to ${{ env.VERSION }}
branch: update-autofill-${{ env.VERSION }}
title: Update autofill to ${{ env.VERSION }}
body: '${{ env.PR_BODY_ANDROID }}'
token: ${{ secrets.DAXMOBILE_AUTOFILL_AUTOMATION }}

# ------------------------------------------------------------------------------
# Create PR with updated autofill on BrowserServicesKit
# Create PR with updated autofill on Apple platforms
# ------------------------------------------------------------------------------

update_bsk:
update_apple:
runs-on: ubuntu-20.04
outputs:
pull-request-url: ${{ steps.create-pr.outputs.pull-request-url }}
Expand All @@ -105,138 +116,36 @@ jobs:
path: autofill/
- uses: ./autofill/.github/actions/setup-release-scripts
# --- Action ---
- name: Checkout BSK
- name: Checkout Apple monorepo
uses: actions/checkout@v3
with:
repository: duckduckgo/BrowserServicesKit
path: bsk/
repository: duckduckgo/apple-browsers
path: apple-monorepo/
token: ${{ secrets.DAXMOBILE_AUTOFILL_AUTOMATION }}
- name: Update BSK autofill reference
- name: Update Apple autofill reference
run: |
node ./autofill/scripts/release/update-bsk-repo.js
- name: Create BSK PR Body
- name: Create Apple PR Body
env:
ASANA_OUTPUT: ${{ needs.create_asana_tasks.outputs.asana-output }}
run: |
TEMPLATE="$(node ./autofill/scripts/release/create-pr-template.js bsk)"
TEMPLATE="$(node ./autofill/scripts/release/create-pr-template.js apple)"
# Creates a randomised delimiter. See https://app.asana.com/0/1199892415909552/1203243297643584/f
DELIMITER=$(echo $RANDOM | md5sum | head -c 20;)
echo "PR_BODY_BSK<<$DELIMITER" >> $GITHUB_ENV
echo "PR_BODY_APPLE<<$DELIMITER" >> $GITHUB_ENV
echo "$TEMPLATE" >> $GITHUB_ENV
echo "$DELIMITER" >> $GITHUB_ENV
# --- Effect ---
- name: Create PR for BSK
- name: Create PR for Apple monorepo
uses: peter-evans/create-pull-request@b3a2c5d525a1eb75e75c781e45a1bf3bfc23bdc6
id: create-pr
with:
path: bsk/
add-paths: Package.swift,Package.resolved
commit-message: Update autofill to ${{ github.event.release.tag_name }}
branch: update-autofill-${{ github.event.release.tag_name }}
title: Update autofill to ${{ github.event.release.tag_name }}
body: ${{ env.PR_BODY_BSK }}
token: ${{ secrets.DAXMOBILE_AUTOFILL_AUTOMATION }}

# ------------------------------------------------------------------------------
# Create PR with updated BrowserServicesKit on iOS
# ------------------------------------------------------------------------------

update_ios:
runs-on: ubuntu-20.04
outputs:
pull-request-url: ${{ steps.create-pr.outputs.pull-request-url }}
needs: [create_asana_tasks, update_bsk]
steps:
# --- Setup ---
- uses: actions/checkout@v3
with:
path: autofill/
- uses: ./autofill/.github/actions/setup-release-scripts
# --- Action ---
- name: Checkout iOS
uses: actions/checkout@v3
with:
repository: duckduckgo/iOS
path: ios/
token: ${{ secrets.DAXMOBILE_AUTOFILL_AUTOMATION }}
- name: Update iOS autofill reference
env:
BSK_SHA: ${{ needs.update_bsk.outputs.pull-request-head-sha }}
run: |
node ./autofill/scripts/release/update-apple-device-repo.js 'ios'
- name: Create iOS PR Body
env:
ASANA_OUTPUT: ${{ needs.create_asana_tasks.outputs.asana-output }}
BSK_PR_URL: ${{ needs.update_bsk.outputs.pull-request-url }}
run: |
TEMPLATE="$(node ./autofill/scripts/release/create-pr-template.js ios)"
# Creates a randomised delimiter. See https://app.asana.com/0/1199892415909552/1203243297643584/f
DELIMITER=$(echo $RANDOM | md5sum | head -c 20;)
echo "PR_BODY_IOS<<$DELIMITER" >> $GITHUB_ENV
echo "$TEMPLATE" >> $GITHUB_ENV
echo "$DELIMITER" >> $GITHUB_ENV
# --- Effect ---
- name: Create PR for iOS
uses: peter-evans/create-pull-request@b3a2c5d525a1eb75e75c781e45a1bf3bfc23bdc6
id: create-pr
with:
path: ios/
add-paths: DuckDuckGo-iOS.xcodeproj/project.pbxproj
commit-message: Update BSK with autofill ${{ github.event.release.tag_name }}
branch: update-bsk-with-autofill-${{ github.event.release.tag_name }}
title: Update BSK with autofill ${{ github.event.release.tag_name }}
body: ${{ env.PR_BODY_IOS }}
token: ${{ secrets.DAXMOBILE_AUTOFILL_AUTOMATION }}

# ------------------------------------------------------------------------------
# Create PR with updated BrowserServicesKit on macOS
# ------------------------------------------------------------------------------

update_macos:
runs-on: ubuntu-20.04
outputs:
pull-request-url: ${{ steps.create-pr.outputs.pull-request-url }}
needs: [create_asana_tasks, update_bsk]
steps:
# --- Setup ---
- uses: actions/checkout@v3
with:
path: autofill/
- uses: ./autofill/.github/actions/setup-release-scripts
# --- Action ---
- name: Checkout macOS
uses: actions/checkout@v3
with:
repository: duckduckgo/macos-browser
path: macos/
token: ${{ secrets.DAXMOBILE_AUTOFILL_AUTOMATION }}
- name: Update macOS autofill reference
env:
BSK_SHA: ${{ needs.update_bsk.outputs.pull-request-head-sha }}
run: |
node ./autofill/scripts/release/update-apple-device-repo.js 'macos'
- name: Create macOS PR Body
env:
ASANA_OUTPUT: ${{ needs.create_asana_tasks.outputs.asana-output }}
BSK_PR_URL: ${{ needs.update_bsk.outputs.pull-request-url }}
run: |
TEMPLATE="$(node ./autofill/scripts/release/create-pr-template.js macos)"
# Creates a randomised delimiter. See https://app.asana.com/0/1199892415909552/1203243297643584/f
DELIMITER=$(echo $RANDOM | md5sum | head -c 20;)
echo "PR_BODY_MACOS<<$DELIMITER" >> $GITHUB_ENV
echo "$TEMPLATE" >> $GITHUB_ENV
echo "$DELIMITER" >> $GITHUB_ENV
# --- Effect ---
- name: Create PR for macOS
uses: peter-evans/create-pull-request@b3a2c5d525a1eb75e75c781e45a1bf3bfc23bdc6
id: create-pr
with:
path: macos/
add-paths: DuckDuckGo-macOS.xcodeproj/project.pbxproj
commit-message: Update BSK with autofill ${{ github.event.release.tag_name }}
branch: update-bsk-with-autofill-${{ github.event.release.tag_name }}
title: Update BSK with autofill ${{ github.event.release.tag_name }}
body: ${{ env.PR_BODY_MACOS }}
path: apple-monorepo/
add-paths: BrowserServicesKit/Package.swift,BrowserServicesKit/Package.resolved
commit-message: Update autofill to ${{ env.VERSION }}
branch: update-autofill-${{ env.VERSION }}
title: Update autofill to ${{ env.VERSION }}
body: ${{ env.PR_BODY_APPLE }}
token: ${{ secrets.DAXMOBILE_AUTOFILL_AUTOMATION }}

# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -267,7 +176,7 @@ jobs:
- name: Update Extensions autofill reference
run: |
cd extensions
npm install github:duckduckgo/duckduckgo-autofill#${{ github.event.release.tag_name }}
npm install github:duckduckgo/duckduckgo-autofill#${{ env.VERSION }}
cd ..
- name: Create Extensions PR Body
env:
Expand All @@ -288,9 +197,9 @@ jobs:
add-paths: |
package.json
package-lock.json
commit-message: Update autofill to ${{ github.event.release.tag_name }}
branch: update-autofill-${{ github.event.release.tag_name }}
title: Update autofill to ${{ github.event.release.tag_name }}
commit-message: Update autofill to ${{ env.VERSION }}
branch: update-autofill-${{ env.VERSION }}
title: Update autofill to ${{ env.VERSION }}
body: '${{ env.PR_BODY_EXTENSIONS }}'
token: ${{ secrets.DAXMOBILE_AUTOFILL_AUTOMATION }}

Expand Down Expand Up @@ -321,7 +230,7 @@ jobs:
run: |
cd windows/submodules/duckduckgo-autofill
git fetch --tags
git checkout ${{ github.event.release.tag_name }}
git checkout ${{ env.VERSION }}
cd ../../../
- name: Create Windows PR Body
env:
Expand All @@ -341,9 +250,9 @@ jobs:
path: windows/
add-paths: |
submodules/duckduckgo-autofill
commit-message: Update autofill to ${{ github.event.release.tag_name }}
branch: update-autofill-${{ github.event.release.tag_name }}
title: Update autofill to ${{ github.event.release.tag_name }}
commit-message: Update autofill to ${{ env.VERSION }}
branch: update-autofill-${{ env.VERSION }}
title: Update autofill to ${{ env.VERSION }}
body: '${{ env.PR_BODY_WINDOWS }}'
token: ${{ secrets.DAXMOBILE_AUTOFILL_AUTOMATION }}

Expand All @@ -356,7 +265,7 @@ jobs:
# Always run this final step, even if any of the updates have failed
# unless the previous jobs were cancelled
if: ${{ always() && !contains(needs.*.result, 'cancelled') }}
needs: [create_asana_tasks, update_bsk, update_ios, update_macos, update_android, update_extensions, update_windows]
needs: [create_asana_tasks, update_apple, update_android, update_extensions, update_windows]
steps:
# --- Setup ---
- uses: actions/checkout@v3
Expand All @@ -368,9 +277,7 @@ jobs:
env:
ASANA_ACCESS_TOKEN: ${{ secrets.NATIVE_APPS_WORKFLOW }}
ASANA_OUTPUT: ${{ needs.create_asana_tasks.outputs.asana-output }}
BSK_PR_URL: ${{ needs.update_bsk.outputs.pull-request-url }}
IOS_PR_URL: ${{ needs.update_ios.outputs.pull-request-url }}
MACOS_PR_URL: ${{ needs.update_macos.outputs.pull-request-url }}
APPLE_PR_URL: ${{ needs.update_apple.outputs.pull-request-url }}
ANDROID_PR_URL: ${{ needs.update_android.outputs.pull-request-url }}
WINDOWS_PR_URL: ${{ needs.update_windows.outputs.pull-request-url }}
run: |
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DuckDuckGo Autofill

This code is installed using `npm` in our [extension](https://github.com/duckduckgo/duckduckgo-privacy-extension) and as a git submodule by native apps ([iOS](https://github.com/duckduckgo/iOS) and [Android](https://github.com/duckduckgo/Android)).
This code is installed using `npm` in our [extension](https://github.com/duckduckgo/duckduckgo-privacy-extension) and as a git submodule by native apps ([iOS/macOS](https://github.com/duckduckgo/apple-browsers) and [Android](https://github.com/duckduckgo/Android)).

DuckDuckGo Autofill is distributed under the Apache 2.0 [License](LICENSE.md).

Expand All @@ -21,7 +21,7 @@ Now you can run `npm start` in this repo and the changes will be picked up autom

### Apple apps (iOS and macOS)

On Apple clients, autofill is included as part of the [BrowserServicesKit](https://github.com/duckduckgo/BrowserServicesKit) (BSK) package. If your changes involve native code, you probably want to work within BSK, otherwise you can work directly within the client codebases.
On Apple clients, autofill is included as part of the [BrowserServicesKit](https://github.com/duckduckgo/apple-browsers) (BSK) package. If your changes involve native code, you probably want to work within BSK, otherwise you can work directly within the client codebases.

The easiest way to override the client version of autofill is to drag-and-drop your local autofill folder from the Finder right into Xcode project navigator, at the root level. If you're working in BSK, you can drag-and-drop autofill in the BSK project and then drag-and-drop BSK itself in the platform project.

Expand Down
2 changes: 1 addition & 1 deletion docs/runtime.ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

on Apple devices, this data is retrieved from the following string-replacements

- [BrowserServices Kit String replacements](https://github.com/duckduckgo/BrowserServicesKit/blob/main/Sources/BrowserServicesKit/Autofill/AutofillUserScript+SourceProvider.swift#L54-L56)
- [BrowserServices Kit String replacements](https://github.com/duckduckgo/apple-browsers/blob/main/BrowserServicesKit/Sources/BrowserServicesKit/Autofill/AutofillUserScript+SourceProvider.swift#L54-L56)

Internally, we force it into the following shape in order to conform to the following schema definition:
- [Runtime Configuration Schema](https://github.com/duckduckgo/content-scope-scripts/blob/shane/unify-config/src/schema/runtime-configuration.schema.json)
Expand Down
6 changes: 3 additions & 3 deletions scripts/release/asana-create-tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const projectExtractorRegex = /\[\[project_gids=(.+)]]\s/;
*
* @typedef {{
* android: platformData,
* bsk: platformData,
* apple: platformData,
* windows: platformData
* }} AsanaOutput
*/
Expand All @@ -34,8 +34,8 @@ const platforms = {
taskGid: '',
taskUrl: '',
},
bsk: {
displayName: 'BrowserServicesKit',
apple: {
displayName: 'Apple',
taskGid: '',
taskUrl: '',
},
Expand Down
15 changes: 3 additions & 12 deletions scripts/release/asana-update-tasks.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
const Asana = require('asana');
const { replaceAllInString, getLink, wrapInLi } = require('./release-utils.js');
const { replaceAllInString, getLink } = require('./release-utils.js');

const ASANA_ACCESS_TOKEN = process.env.ASANA_ACCESS_TOKEN;
const prUrls = {
android: process.env.ANDROID_PR_URL,
bsk: process.env.BSK_PR_URL,
ios: process.env.IOS_PR_URL,
macos: process.env.MACOS_PR_URL,
apple: process.env.APPLE_PR_URL,
windows: process.env.WINDOWS_PR_URL,
};
const asanaOutputRaw = process.env.ASANA_OUTPUT;
Expand Down Expand Up @@ -43,14 +41,7 @@ const asanaUpdateTasks = async () => {
/** @type {[[RegExp, string]]} */
const taskDescriptionSubstitutions = [[/\[\[pr_url]]/, prLink]];

let extraContent = '';
if (platformName === 'bsk') {
// On the BSK task we also substitute the ios and macos placeholders
const iosPrLink = prUrls.ios ? getLink(prUrls.ios, 'iOS PR') : 'Error creating iOS PR';
const macosPrLink = prUrls.macos ? getLink(prUrls.macos, 'macOS PR') : 'Error creating macOS PR';
extraContent = `${wrapInLi(iosPrLink)}${wrapInLi(macosPrLink)}`;
}

const extraContent = '';
taskDescriptionSubstitutions.push([/<li>\[\[extra_content]]<\/li>/, extraContent]);

const updatedNotes = replaceAllInString(notes, taskDescriptionSubstitutions);
Expand Down
12 changes: 6 additions & 6 deletions scripts/release/create-pr-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ const filepath = (...path) => join(cwd, ...path);
/**
* @typedef {{
* releaseNotesRaw: string,
* bskPrUrl: string,
* applePrUrl: string,
* asanaOutputRaw: string,
* releaseUrl: string,
* version: string
* }} CreatePRTemplateData
* @typedef {'android' | 'extensions' | 'bsk' | 'ios' | 'macos' | 'windows'} ReleasePlatform
* @typedef {'android' | 'extensions' | 'apple' | 'windows'} ReleasePlatform
*/

const platform = /** @type {ReleasePlatform} */ (process.argv[2]);
Expand All @@ -22,7 +22,7 @@ const data = {
version: process.env.VERSION || '',
releaseUrl: process.env.RELEASE_URL || '',
releaseNotesRaw: process.env.RELEASE_NOTES || '',
bskPrUrl: process.env.BSK_PR_URL || '',
applePrUrl: process.env.APPLE_PR_URL || '',
asanaOutputRaw: process.env.ASANA_OUTPUT || '{}',
};

Expand All @@ -47,9 +47,9 @@ function createPRTemplate(platform, data) {

let asanaUrl = asanaOutput[platform]?.taskUrl;

if (['ios', 'macos'].includes(platform)) {
asanaUrl = asanaOutput.bsk?.taskUrl;
extraContent = `BSK PR: ${data.bskPrUrl}`;
if (['apple'].includes(platform)) {
asanaUrl = asanaOutput.apple?.taskUrl;
extraContent = `Apple PR: ${data.applePrUrl}`;
}

const updatedTemplate = replaceAllInString(template, [
Expand Down
Loading

0 comments on commit fb06780

Please sign in to comment.