Skip to content

Commit

Permalink
chore(ci): publish edge changelogs and update Discord embed layout
Browse files Browse the repository at this point in the history
  • Loading branch information
JagandeepBrar committed Jun 22, 2022
1 parent 2e90ba3 commit 013188a
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 41 deletions.
62 changes: 62 additions & 0 deletions .github/scripts/notify-embed.js
Original file line number Diff line number Diff line change
@@ -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(),
},
],
},
]);
};
56 changes: 21 additions & 35 deletions .github/workflows/notify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: Notify
on:
workflow_call:
inputs:
build-changelog:
required: true
type: string
build-title:
required: true
type: string
Expand Down Expand Up @@ -43,6 +46,7 @@ jobs:
name: Discord
runs-on: ubuntu-latest
steps:

- name: Determine Webhook Channel
id: webhook
uses: actions/github-script@v6
Expand All @@ -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/[email protected]
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 }}
7 changes: 5 additions & 2 deletions .github/workflows/publish_ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/publish_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ios/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
2 changes: 1 addition & 1 deletion macos/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down

0 comments on commit 013188a

Please sign in to comment.