Skip to content

Commit

Permalink
feat: add BUILD_DESCRIPTION support (#1466)
Browse files Browse the repository at this point in the history
* add: BUILD_DESCRIPTION support

* add: margins

* fix: slack notify

* update: slack-notify.yml

* test: slack

* fix: slack

* add: comment

* add: creds

* add: creds

* fix: secrets

* fix: app_identifier

* add: api_key

* fix: api_key

* test: slack

* update: fastlane

* update: lane name

* fix: job

* fix: params

* fix: build description

* fix: slack

* fix: last-build path

* fix: last-build path

* test: job

* fix: path

* fix: multiline

* fix: job

* fix: path

* test: job

* fix: script

* remove: debug code
  • Loading branch information
ragozin-nikita authored Nov 15, 2023
1 parent 3b12634 commit 486dbce
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 40 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/distribute-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ on:
- true
- false

BUILD_DESCRIPTION:
required: true
description: Please add a short note for a new build

workflow_call:
inputs:
IS_DEVELOPMENT:
Expand All @@ -25,6 +29,9 @@ on:
IS_SSS_ENABLED:
required: true
type: string
BUILD_DESCRIPTION:
required: true
type: string

jobs:
build:
Expand Down Expand Up @@ -98,3 +105,4 @@ jobs:
HAQQ_UPLOAD_KEY_PASSWORD: ${{ secrets.HAQQ_UPLOAD_KEY_PASSWORD }}
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
FIREBASE_TESTERS: ${{ secrets.FIREBASE_TESTERS }}
BUILD_DESCRIPTION: ${{github.event.inputs.BUILD_DESCRIPTION}}
8 changes: 8 additions & 0 deletions .github/workflows/distribute-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ on:
- true
- false

BUILD_DESCRIPTION:
required: true
description: Please add a short note for a new build

workflow_call:
inputs:
IS_DEVELOPMENT:
Expand All @@ -25,6 +29,9 @@ on:
IS_SSS_ENABLED:
required: true
type: string
BUILD_DESCRIPTION:
required: true
type: string

jobs:
build:
Expand Down Expand Up @@ -120,3 +127,4 @@ jobs:
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
DEVELOPER_APP_ID: ${{ secrets.DEVELOPER_APP_ID }}
PROVISIONING_PROFILE_SPECIFIER: ${{ secrets.PROVISIONING_PROFILE_SPECIFIER }}
BUILD_DESCRIPTION: ${{github.event.inputs.BUILD_DESCRIPTION}}
11 changes: 9 additions & 2 deletions .github/workflows/distribute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
- true
- false

BUILD_DESCRIPTION:
required: true
description: Please add a short note for a new build

jobs:
test:
name: Tests
Expand All @@ -33,6 +37,7 @@ jobs:
with:
IS_DEVELOPMENT: false
IS_SSS_ENABLED: ${{github.event.inputs.IS_SSS_ENABLED}}
BUILD_DESCRIPTION: ${{github.event.inputs.BUILD_DESCRIPTION}}
needs:
- test

Expand All @@ -43,6 +48,7 @@ jobs:
with:
IS_DEVELOPMENT: false
IS_SSS_ENABLED: ${{github.event.inputs.IS_SSS_ENABLED}}
BUILD_DESCRIPTION: ${{github.event.inputs.BUILD_DESCRIPTION}}
needs:
- test

Expand All @@ -52,8 +58,9 @@ jobs:
- build_android
name: Create changelogs
uses: ./.github/workflows/slack-notify.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
secrets: inherit
with:
BUILD_DESCRIPTION: ${{github.event.inputs.BUILD_DESCRIPTION}}

patch_build:
name: Patch build versions
Expand Down
36 changes: 31 additions & 5 deletions .github/workflows/slack-notify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,59 @@ name: Slack notify
on:
workflow_dispatch:
workflow_call:
inputs:
BUILD_DESCRIPTION:
required: true
type: string

secrets:
SLACK_WEBHOOK_URL:
required: true

jobs:
slack_notify:
name: Slack notify
runs-on: ubuntu-latest
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Install Fastlane
run: |
bundle install
- name: Create Changelog
shell: bash
id: changelog
run: |
log="$(node ./utils/changelog.js $(cat .last-build))"
echo "log=$log" >> $GITHUB_OUTPUT
echo ${{secrets.GOOGLE_SERVICE_ACCOUNT}} | base64 -d > android/app/google-account.json
bundle exec fastlane ios slack_notification
echo "changelog=$(cat fastlane/changelog.txt)" >> $GITHUB_OUTPUT
env:
BUILD_DESCRIPTION: ${{github.event.inputs.BUILD_DESCRIPTION}}
DEVELOPER_APP_IDENTIFIER: ${{ secrets.IOS_IDENTIFIER }}
GIT_AUTHORIZATION: ${{ secrets.GIT_AUTHORIZATION }}
APP_STORE_CONNECT_TEAM_ID: ${{ secrets.APP_STORE_CONNECT_TEAM_ID }}
DEVELOPER_PORTAL_TEAM_ID: ${{ secrets.DEVELOPER_PORTAL_TEAM_ID }}
MATCH_DEPLOY_KEY: ${{ secrets.MATCH_DEPLOY_KEY }}
TEMP_KEYCHAIN_USER: ${{ secrets.TEMP_KEYCHAIN_USER }}
TEMP_KEYCHAIN_PASSWORD: ${{ secrets.TEMP_KEYCHAIN_PASSWORD }}
APPLE_KEY_ID: ${{ secrets.APPLE_KEY_ID }}
APPLE_ISSUER_ID: ${{ secrets.APPLE_ISSUER_ID }}
APPLE_KEY_CONTENT: ${{ secrets.APPLE_KEY_CONTENT }}
FASTLANE_PASSWORD: ${{ secrets.APPLE_FASTLANE_PASSWORD }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
DEVELOPER_APP_ID: ${{ secrets.DEVELOPER_APP_ID }}
PROVISIONING_PROFILE_SPECIFIER: ${{ secrets.PROVISIONING_PROFILE_SPECIFIER }}
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
FIREBASE_TESTERS: ${{ secrets.FIREBASE_TESTERS }}

- name: Send GitHub Action trigger data to Slack workflow
uses: slackapi/slack-github-action@v1
with:
payload: |
${{ steps.changelog.outputs.log }}
${{ steps.changelog.outputs.changelog }}
env:
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
39 changes: 21 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ GEM
artifactory (3.0.15)
atomos (0.1.3)
aws-eventstream (1.2.0)
aws-partitions (1.821.0)
aws-sdk-core (3.181.0)
aws-partitions (1.849.0)
aws-sdk-core (3.186.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.5)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.71.0)
aws-sdk-core (~> 3, >= 3.177.0)
aws-sdk-kms (1.72.0)
aws-sdk-core (~> 3, >= 3.184.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.134.0)
aws-sdk-s3 (1.136.0)
aws-sdk-core (~> 3, >= 3.181.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.6)
aws-sigv4 (1.6.0)
aws-sigv4 (1.6.1)
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
claide (1.1.0)
Expand Down Expand Up @@ -85,7 +85,7 @@ GEM
escape (0.0.4)
ethon (0.16.0)
ffi (>= 1.15.0)
excon (0.102.0)
excon (0.104.0)
faraday (1.10.3)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
Expand Down Expand Up @@ -154,16 +154,17 @@ GEM
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.3.0)
xcpretty-travis-formatter (>= 0.0.3)
fastlane-plugin-firebase_app_distribution (0.6.1)
fastlane-plugin-firebase_app_distribution (0.7.4)
google-apis-firebaseappdistribution_v1 (~> 0.3.0)
fastlane-plugin-increment_version_code (0.4.3)
fastlane-plugin-increment_version_name (0.0.10)
ffi (1.15.5)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
google-apis-androidpublisher_v3 (0.49.0)
google-apis-androidpublisher_v3 (0.52.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-core (0.11.1)
google-apis-core (0.11.2)
addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.16.2, < 2.a)
httpclient (>= 2.8.1, < 3.a)
Expand All @@ -172,27 +173,29 @@ GEM
retriable (>= 2.0, < 4.a)
rexml
webrick
google-apis-firebaseappdistribution_v1 (0.3.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-iamcredentials_v1 (0.17.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-playcustomapp_v1 (0.13.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-storage_v1 (0.19.0)
google-apis-core (>= 0.9.0, < 2.a)
google-apis-storage_v1 (0.29.0)
google-apis-core (>= 0.11.0, < 2.a)
google-cloud-core (1.6.0)
google-cloud-env (~> 1.0)
google-cloud-errors (~> 1.0)
google-cloud-env (1.6.0)
faraday (>= 0.17.3, < 3.0)
google-cloud-errors (1.3.1)
google-cloud-storage (1.44.0)
google-cloud-storage (1.45.0)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-iamcredentials_v1 (~> 0.1)
google-apis-storage_v1 (~> 0.19.0)
google-apis-storage_v1 (~> 0.29.0)
google-cloud-core (~> 1.6)
googleauth (>= 0.16.2, < 2.a)
mini_mime (~> 1.0)
googleauth (1.8.0)
googleauth (1.8.1)
faraday (>= 0.17.3, < 3.a)
jwt (>= 1.4, < 3.0)
multi_json (~> 1.11)
Expand Down Expand Up @@ -221,7 +224,7 @@ GEM
os (1.1.4)
plist (3.7.0)
public_suffix (4.0.7)
rake (13.0.6)
rake (13.1.0)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
Expand Down Expand Up @@ -256,11 +259,11 @@ GEM
uber (0.1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.8.2)
unf_ext (0.0.9)
unicode-display_width (1.8.0)
webrick (1.8.1)
word_wrap (1.0.0)
xcodeproj (1.22.0)
xcodeproj (1.23.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
Expand Down
29 changes: 27 additions & 2 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,30 @@ platform :ios do
create_temp_keychain(name, password)
end

lane :slack_notification do
api_key = app_store_connect_api_key(
key_id: ENV["APPLE_KEY_ID"],
issuer_id: ENV["APPLE_ISSUER_ID"],
key_content: ENV["APPLE_KEY_CONTENT"],
duration: 1200,
in_house: false
)

current_build_number_android = google_play_track_version_codes(
package_name: 'com.haqq.wallet',
track: "internal",
json_key: './android/app/google-account.json',
)[0] + 1

current_build_number_ios = latest_testflight_build_number(
app_identifier: ENV["IOS_IDENTIFIER"],
api_key: api_key,
) + 1

sh("IOS=#{current_build_number_ios} ANDROID=#{current_build_number_android} BUILD_DESCRIPTION=\"#{ENV['BUILD_DESCRIPTION']}\" node ../utils/changelog.js $(cat ../.last-build) >> changelog.txt")
sh("echo Generated Changelog: $(cat changelog.txt)")
end

lane :version do
increment_version_number(
xcodeproj: './ios/haqq.xcodeproj',
Expand Down Expand Up @@ -209,9 +233,10 @@ platform :ios do
app_identifier: app_identifier,
ipa: "haqq.ipa",
skip_submission: true,
skip_waiting_for_build_processing: true
skip_waiting_for_build_processing: true,
changelog: ENV["BUILD_DESCRIPTION"]
)

delete_temp_keychain(keychain_name)
end
end
end
26 changes: 13 additions & 13 deletions utils/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ new Promise(resolve => {
}
}

let blocks = [];
let blocks = formatBlock('title', {value: process.env.BUILD_DESCRIPTION, ios: process.env.IOS, android: process.env.ANDROID});

const viewed = [];

Expand Down Expand Up @@ -126,6 +126,18 @@ const blockNames = {
function formatBlock(type, variants = {}) {
const block = [];

if (type === 'title') {
return [
{
type: 'header',
text: {
type: 'plain_text',
text: `${process.env.BUILD_DESCRIPTION}\niOS: ${process.env.IOS}, Android: ${process.env.ANDROID}`,
},
},
]
}

for (const variant of Object.entries(variants)) {
if (variant[1].length) {
const title =
Expand Down Expand Up @@ -155,17 +167,5 @@ function formatBlock(type, variants = {}) {
}
}

if (block.length && blockNames[type]) {
return [
{
type: 'header',
text: {
type: 'plain_text',
text: blockNames[type],
},
},
].concat(block);
}

return block;
}

0 comments on commit 486dbce

Please sign in to comment.