From 013188a9854926dfab3c521189d69c55c7a40a63 Mon Sep 17 00:00:00 2001 From: Jagandeep Brar Date: Tue, 21 Jun 2022 23:47:40 -0400 Subject: [PATCH] chore(ci): publish edge changelogs and update Discord embed layout --- .github/scripts/notify-embed.js | 62 +++++++++++++++++++++++++++++ .github/workflows/notify.yml | 56 ++++++++++---------------- .github/workflows/publish_ios.yml | 7 +++- .github/workflows/publish_macos.yml | 7 +++- ios/fastlane/Fastfile | 2 +- macos/fastlane/Fastfile | 2 +- 6 files changed, 95 insertions(+), 41 deletions(-) create mode 100644 .github/scripts/notify-embed.js diff --git a/.github/scripts/notify-embed.js b/.github/scripts/notify-embed.js new file mode 100644 index 0000000000..1cdef5dee5 --- /dev/null +++ b/.github/scripts/notify-embed.js @@ -0,0 +1,62 @@ +const platforms = () => { + const platforms = []; + const { + ENABLE_ANDROID, + ENABLE_IOS, + ENABLE_LINUX, + ENABLE_MACOS, + ENABLE_WEB, + ENABLE_WINDOWS, + } = process.env; + + if (ENABLE_ANDROID) platforms.push("Android"); + if (ENABLE_IOS) platforms.push("iOS"); + if (ENABLE_LINUX) platforms.push("Linux"); + if (ENABLE_MACOS) platforms.push("macOS"); + if (ENABLE_WEB) platforms.push("Web"); + if (ENABLE_WINDOWS) platforms.push("Windows"); + + if (platforms.length) return platforms.join(", "); + return "None"; +}; + +const changelog = () => { + return process.env.CHANGELOG ?? "No Documented Changes"; +}; + +const web = () => { + let url = ""; + if (process.env.FLAVOR !== "stable") url += `${process.env.FLAVOR}.`; + url += "web.lunasea.app"; + return `[View Deployment](https://${url})`; +}; + +module.exports = () => { + return JSON.stringify([ + { + title: process.env.BUILD_TITLE ?? "Unknown Build", + color: 5164195, + timestamp: new Date().toISOString(), + fields: [ + { + name: "Release", + value: `[Download](https://builds.lunasea.app/#${process.env.BUILD_TITLE}/)`, + inline: true, + }, + { + name: "Web", + value: web(), + inline: true, + }, + { + name: "Platforms", + value: platforms(), + }, + { + name: "Changelog", + value: changelog(), + }, + ], + }, + ]); +}; diff --git a/.github/workflows/notify.yml b/.github/workflows/notify.yml index 1bdc21d3b2..c8c9f3eb36 100644 --- a/.github/workflows/notify.yml +++ b/.github/workflows/notify.yml @@ -3,6 +3,9 @@ name: Notify on: workflow_call: inputs: + build-changelog: + required: true + type: string build-title: required: true type: string @@ -43,6 +46,7 @@ jobs: name: Discord runs-on: ubuntu-latest steps: + - name: Determine Webhook Channel id: webhook uses: actions/github-script@v6 @@ -64,45 +68,27 @@ jobs: default: return process.env.DISCORD_WEBHOOK_EDGE; } - - name: Create Discord Message - id: message + - name: Create Discord Embed + id: embed uses: actions/github-script@v6 env: BUILD_TITLE: ${{ inputs.build-title }} - ANDROID: ${{ inputs.enable-android }} - IOS: ${{ inputs.enable-ios }} - LINUX: ${{ inputs.enable-linux }} - MACOS: ${{ inputs.enable-macos }} - WEB: ${{ inputs.enable-web }} - WINDOWS: ${{ inputs.enable-windows }} + CHANGELOG: ${{ inputs.build-changelog }} + ENABLE_ANDROID: ${{ inputs.enable-android }} + ENABLE_IOS: ${{ inputs.enable-ios }} + ENABLE_LINUX: ${{ inputs.enable-linux }} + ENABLE_MACOS: ${{ inputs.enable-macos }} + ENABLE_WEB: ${{ inputs.enable-web }} + ENABLE_WINDOWS: ${{ inputs.enable-windows }} + FLAVOR: ${{ inputs.flavor }} with: result-encoding: string - script: | - const { ANDROID, IOS, LINUX, MACOS, WEB, WINDOWS } = process.env; - const url = `https://builds.lunasea.app/#${ process.env.BUILD_TITLE }/`; - let _base = `[Download](${url})`; - if ( ANDROID || IOS || LINUX || MACOS || WEB || WINDOWS) { - _base += '\n\nThis release is available on the following platforms: '; - - const platforms = []; - if (ANDROID === 'true') platforms.push('Android'); - if (IOS === 'true') platforms.push('iOS'); - if (LINUX === 'true') platforms.push('Linux'); - if (MACOS === 'true') platforms.push('macOS'); - if (WEB === 'true') platforms.push('Web'); - if (WINDOWS === 'true') platforms.push('Windows'); - - _base += platforms.map((p) => `**${p}**`).join(', '); - } - return _base; + script: return require('.github/scripts/notify-embed.js')(); - name: Send Discord Message - uses: sarisia/actions-status-discord@v1 - with: - webhook: ${{ steps.webhook.outputs.result }} - username: LunaSea Support - avatar_url: https://raw.githubusercontent.com/JagandeepBrar/LunaSea/master/assets/icon/icon.png - noprefix: true - color: 0x4ECCA3 - title: ${{ inputs.build-title }} - description: ${{ steps.message.outputs.result }} + uses: Ilshidur/action-discord@0.3.2 + env: + DISCORD_WEBHOOK: ${{ steps.webhook.outputs.result }} + DISCORD_USERNAME: LunaSea Support + DISCORD_AVATAR: https://raw.githubusercontent.com/JagandeepBrar/LunaSea/master/assets/icon/icon.png + DISCORD_EMBEDS: ${{ steps.embed.outputs.result }} diff --git a/.github/workflows/publish_ios.yml b/.github/workflows/publish_ios.yml index 698e24c022..f2e0c0ce74 100644 --- a/.github/workflows/publish_ios.yml +++ b/.github/workflows/publish_ios.yml @@ -56,7 +56,10 @@ jobs: with: name: ios-appstore-package path: ${{ github.workspace }}/output - + + - name: Generate Changelog + run: echo ${{ inputs.build-changelog }} > ${{ github.workspace }}/ios/fastlane/changelog.txt + - name: Deploy to App Store Connect working-directory: ${{ github.workspace }}/ios env: @@ -66,7 +69,7 @@ jobs: APPLE_STORE_CONNECT_KEY_FILEPATH: ${{ github.workspace }}/keys/appstore.p8 APPLE_STORE_CONNECT_KEY_ID: ${{ secrets.APPLE_STORE_CONNECT_KEY_ID }} APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} - run: bundle exec fastlane deploy_appstore groups:${{ inputs.flavor }} changelog:${{ inputs.build-changelog }} ipa:${{ github.workspace }}/output/lunasea-ios.ipa + run: bundle exec fastlane deploy_appstore groups:${{ inputs.flavor }} ipa:${{ github.workspace }}/output/lunasea-ios.ipa s3: name: S3 diff --git a/.github/workflows/publish_macos.yml b/.github/workflows/publish_macos.yml index 4b95576d97..7828dc64ce 100644 --- a/.github/workflows/publish_macos.yml +++ b/.github/workflows/publish_macos.yml @@ -56,7 +56,10 @@ jobs: with: name: macos-appstore-package path: ${{ github.workspace }}/output - + + - name: Generate Changelog + run: echo ${{ inputs.build-changelog }} > ${{ github.workspace }}/macos/fastlane/changelog.txt + - name: Deploy to App Store Connect working-directory: ${{ github.workspace }}/macos env: @@ -66,7 +69,7 @@ jobs: APPLE_STORE_CONNECT_KEY_FILEPATH: ${{ github.workspace }}/keys/appstore.p8 APPLE_STORE_CONNECT_KEY_ID: ${{ secrets.APPLE_STORE_CONNECT_KEY_ID }} APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} - run: bundle exec fastlane deploy_appstore groups:${{ inputs.flavor }} changelog:${{ inputs.build-changelog }} pkg:${{ github.workspace }}/output/lunasea-macos-amd64.pkg + run: bundle exec fastlane deploy_appstore groups:${{ inputs.flavor }} pkg:${{ github.workspace }}/output/lunasea-macos-amd64.pkg s3: name: S3 diff --git a/ios/fastlane/Fastfile b/ios/fastlane/Fastfile index 64573ea1b6..a600464c86 100644 --- a/ios/fastlane/Fastfile +++ b/ios/fastlane/Fastfile @@ -81,7 +81,7 @@ platform :ios do connect_appstore_connect upload_to_testflight( - changelog: options[:changelog], + changelog: File.read("./changelog.txt"), distribute_external: true, groups: options[:groups], ipa: options[:ipa], diff --git a/macos/fastlane/Fastfile b/macos/fastlane/Fastfile index 434edc0953..aaa13b90d2 100644 --- a/macos/fastlane/Fastfile +++ b/macos/fastlane/Fastfile @@ -162,7 +162,7 @@ platform :mac do connect_appstore_connect upload_to_testflight( - changelog: options[:changelog], + changelog: File.read("./changelog.txt"), distribute_external: true, groups: options[:groups], pkg: options[:pkg],