Skip to content

Commit

Permalink
Automate DDG releases (#528)
Browse files Browse the repository at this point in the history
* Propagate to DDG apps on every release

* Make it possible to toggle propagation per platform

* Update existing PRs if they exist
  • Loading branch information
muodov authored Nov 15, 2024
1 parent e3f9e01 commit c0c3a95
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 14 deletions.
67 changes: 59 additions & 8 deletions .github/workflows/ddg-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,53 @@ on:
tag_name:
description: 'The tag of the release to propagate'
required: true
android:
description: 'Propagate to Android'
type: boolean
required: true
default: true
ios:
description: 'Propagate to iOS'
type: boolean
required: true
default: true
macos:
description: 'Propagate to macOS'
type: boolean
required: true
default: true
windows:
description: 'Propagate to Windows'
type: boolean
required: true
default: true

workflow_call:
inputs:
tag_name:
type: string
description: 'The tag of the release to propagate'
required: true
android:
description: 'Propagate to Android'
type: boolean
required: true
default: true
ios:
description: 'Propagate to iOS'
type: boolean
required: true
default: true
macos:
description: 'Propagate to macOS'
type: boolean
required: true
default: true
windows:
description: 'Propagate to Windows'
type: boolean
required: true
default: true

env:
TAG: ${{ inputs.tag_name }}
Expand Down Expand Up @@ -77,6 +124,7 @@ jobs:
# ------------------------------------------------------------------------------

update_android:
if: ${{ inputs.android }}
runs-on: ubuntu-latest
outputs:
pull-request-url: ${{ steps.create-pr.outputs.pull-request-url }}
Expand Down Expand Up @@ -119,7 +167,7 @@ jobs:
echo "$DELIMITER" >> $GITHUB_ENV
# --- Effect ---
- name: Create PR for Android
uses: peter-evans/create-pull-request@88bf0de51c7487d91e1abbb4899332e602c58bbf
uses: peter-evans/create-pull-request@v7
id: create-pr
with:
path: android/
Expand All @@ -128,7 +176,7 @@ jobs:
package-lock.json
autoconsent/
commit-message: Update autoconsent to ${{ env.TAG }}
branch: update-autoconsent-${{ env.TAG }}
branch: update-autoconsent
title: Update autoconsent to ${{ env.TAG }}
body: '${{ env.PR_BODY_ANDROID }}'
token: ${{ secrets.DAX_WEB_AUTOFILL_AUTOMATION }}
Expand All @@ -138,6 +186,7 @@ jobs:
# ------------------------------------------------------------------------------

update_ios:
if: ${{ inputs.ios }}
runs-on: ubuntu-latest
outputs:
pull-request-url: ${{ steps.create-pr.outputs.pull-request-url }}
Expand Down Expand Up @@ -180,7 +229,7 @@ jobs:
echo "$DELIMITER" >> $GITHUB_ENV
# --- Effect ---
- name: Create PR for iOS
uses: peter-evans/create-pull-request@88bf0de51c7487d91e1abbb4899332e602c58bbf
uses: peter-evans/create-pull-request@v7
id: create-pr
with:
path: ios/
Expand All @@ -189,7 +238,7 @@ jobs:
package-lock.json
DuckDuckGo/Autoconsent/
commit-message: Update autoconsent to ${{ env.TAG }}
branch: update-autoconsent-${{ env.TAG }}
branch: update-autoconsent
title: Update autoconsent to ${{ env.TAG }}
body: '${{ env.PR_BODY_IOS }}'
token: ${{ secrets.DAX_WEB_AUTOFILL_AUTOMATION }}
Expand All @@ -199,6 +248,7 @@ jobs:
# ------------------------------------------------------------------------------

update_macos:
if: ${{ inputs.macos }}
runs-on: ubuntu-latest
outputs:
pull-request-url: ${{ steps.create-pr.outputs.pull-request-url }}
Expand Down Expand Up @@ -241,7 +291,7 @@ jobs:
echo "$DELIMITER" >> $GITHUB_ENV
# --- Effect ---
- name: Create PR for macOS
uses: peter-evans/create-pull-request@88bf0de51c7487d91e1abbb4899332e602c58bbf
uses: peter-evans/create-pull-request@v7
id: create-pr
with:
path: macos/
Expand All @@ -250,7 +300,7 @@ jobs:
package-lock.json
DuckDuckGo/Autoconsent/
commit-message: Update autoconsent to ${{ env.TAG }}
branch: update-autoconsent-${{ env.TAG }}
branch: update-autoconsent
title: Update autoconsent to ${{ env.TAG }}
body: '${{ env.PR_BODY_MACOS }}'
token: ${{ secrets.DAX_WEB_AUTOFILL_AUTOMATION }}
Expand All @@ -260,6 +310,7 @@ jobs:
# ------------------------------------------------------------------------------

update_windows:
if: ${{ inputs.windows }}
runs-on: ubuntu-latest
outputs:
pull-request-url: ${{ steps.create-pr.outputs.pull-request-url }}
Expand Down Expand Up @@ -302,14 +353,14 @@ jobs:
echo "$DELIMITER" >> $GITHUB_ENV
# --- Effect ---
- name: Create PR for Windows
uses: peter-evans/create-pull-request@88bf0de51c7487d91e1abbb4899332e602c58bbf
uses: peter-evans/create-pull-request@v7
id: create-pr
with:
path: windows/
add-paths: |
WindowsBrowser/Application/Autoconsent/
commit-message: Update autoconsent to ${{ env.TAG }}
branch: update-autoconsent-${{ env.TAG }}
branch: update-autoconsent
title: Update autoconsent to ${{ env.TAG }}
body: '${{ env.PR_BODY_WINDOWS }}'
token: ${{ secrets.DAX_WEB_AUTOFILL_AUTOMATION }}
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ on:
jobs:
release:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')"
if: ${{ !contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci') }}
outputs:
tag_name: ${{ steps.remember_tag.outputs.tag_name }}
steps:
- uses: actions/checkout@v3

Expand All @@ -33,3 +35,15 @@ jobs:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm run release
- name: Remember git tag
id: remember_tag
run: echo "tag_name=$(git describe --exact-match --tags)" >> "$GITHUB_OUTPUT"

ddg-release:
name: Propagate to DDG apps
needs: release
if: ${{ !contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci') }}
uses: ./.github/workflows/ddg-release.yml
with:
tag_name: ${{ needs.release.outputs.tag_name }}
13 changes: 8 additions & 5 deletions ci/asana-update-tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ const { replaceAllInString, getLink } = require('./release-utils.js');

const ASANA_ACCESS_TOKEN = process.env.ASANA_ACCESS_TOKEN;
const prUrls = {
android: process.env.ANDROID_PR_URL || 'https://example.com/',
ios: process.env.IOS_PR_URL || 'https://example.com/',
macos: process.env.MACOS_PR_URL || 'https://example.com/',
windows: process.env.WINDOWS_PR_URL || 'https://example.com/',
android: process.env.ANDROID_PR_URL,
ios: process.env.IOS_PR_URL,
macos: process.env.MACOS_PR_URL,
windows: process.env.WINDOWS_PR_URL,
};
const asanaOutputRaw = process.env.ASANA_OUTPUT;

Expand Down Expand Up @@ -34,7 +34,10 @@ const asanaUpdateTasks = async () => {
for (const [platformName, platformObj] of platformEntries) {
// If we're missing required data, either we haven't implemented automation for that platform yet,
// or something went wrong in a previous job
if (!platformObj.taskGid || !prUrls[platformName]) continue;
if (!platformObj.taskGid || !prUrls[platformName]) {
console.error(`Skipping ${platformName} task update`);
continue;
}

const { html_notes: notes } = await asana.tasks.getTask(platformObj.taskGid, { opt_fields: 'html_notes' });

Expand Down

0 comments on commit c0c3a95

Please sign in to comment.