Skip to content

Commit

Permalink
feat: add keys to env file
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinand11 committed Feb 17, 2023
1 parent 123a186 commit de616fc
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 13 deletions.
15 changes: 11 additions & 4 deletions .github/workflows/publish_to_stores.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ jobs:
run: yarn
- name: Setup Project
run: yarn bin:project:setup
env:
CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
- name: Version Project
run: node bin/version.js
env:
Expand All @@ -40,4 +37,14 @@ jobs:
needs: build
runs-on: macos-latest
steps:
- run: ls .
- name: Build android
run: node bin/project appBuild android
- name: Publish to play store
run: ls -R ./android/app/build
ios:
name: Publish to IOS
needs: build
runs-on: macos-latest
steps:
- name: Build and push to app store
run: node bin/project appBuild ios
21 changes: 14 additions & 7 deletions bin/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
const { execSync, exec } = require('child_process')
const { parse } = require('plist')
const { readFileSync } = require('fs')
const { ios: iosEnv, android: androidEnv } = require('../env.json')

const installCertAndProfile = (profileFile, certificateFile) => {
const keychain = 'login.keychain'
const kcp = process.env.KEYCHAIN_PASSWORD
const cp = process.env.CERTIFICATE_PASSWORD
const keychain = 'appsigning.keychain'
const kcp = iosEnv.keychain_password
const cp = iosEnv.certificate_password

const rawPlist = readFileSync(profileFile).toString()
const startIndex = rawPlist.indexOf('<?xml')
Expand All @@ -16,9 +17,12 @@ const installCertAndProfile = (profileFile, certificateFile) => {
const { UUID } = data
const command = `
cp -fr "${profileFile}" "$HOME/Library/MobileDevice/Provisioning Profiles/${UUID}.mobileprovision" &&
security unlock-keychain ${kcp ? `-p ${kcp}` : ''} ${keychain} && security set-keychain-settings ${keychain} &&
security import ${certificateFile} -k ${keychain} ${cp ? `-P ${cp}` : ''} -T /usr/bin/codesign &&
security set-key-partition-list ${kcp ? `-k ${kcp}` : ''} -S apple-tool:,apple:,codesign: -s ${keychain}
security delete-keychain ${keychain} &&
security create-keychain -p ${kcp} ${keychain} &&
security set-keychain-settings -lut 21600 ${keychain} &&
security unlock-keychain -p ${kcp} ${keychain} &&
security import ${certificateFile} -k ${keychain} -P ${cp} -T /usr/bin/codesign &&
security set-key-partition-list -k ${kcp} -S apple-tool:,apple:,codesign: -s ${keychain}
`
execSync(command, { maxBuffer: 1024 * 1024 * 5 })

Expand Down Expand Up @@ -51,10 +55,13 @@ const appBuild = async (args) => {
process.exit(1)
}

const ksp = androidEnv.keystore_password
const ksa = androidEnv.keystore_alias

const isAssemble = type === validTypes[0]
const isBundle = type === validTypes[1]

const sign = 'apksigner sign --ks ./app.keystore --ks-key-alias kevin@stranerd.com'
const sign = `apksigner sign --ks ./app.keystore --ks-pass pass:${ksp} --ks-key-alias ${ksa}`
const signAssemble = `zipalign 4 ./app/build/outputs/apk/release/app-release-unsigned.apk ./app/build/outputs/apk/release/app-release.apk && ${sign} ./app/build/outputs/apk/release/app-release.apk`
const signBundle = `${sign} --min-sdk-version 22 ./app/build/outputs/bundle/release/app-release.aab`

Expand Down
4 changes: 3 additions & 1 deletion bin/unzip.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ rm ${encodedFileName} &&
unzip -o ${zippedFileName} -d ./bin/config/ &&
rm ${zippedFileName}`

console.log(execSync(command).toString())
console.log(
execSync(command, { maxBuffer: 1024 * 1024 * 5 }).toString()
)
4 changes: 3 additions & 1 deletion bin/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ console.log(details)

const command = `yarn bin:project:version ${details.join(' ')}`

console.log(execSync(command).toString())
console.log(
execSync(command, { maxBuffer: 1024 * 1024 * 5 }).toString()
)
8 changes: 8 additions & 0 deletions env.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
"domain": "localhost:8080",
"package_name": "com.stranerd.app.dev",
"app_name": "Stranerd Local",
"ios": {
"certificate_password": "",
"keychain_password": ""
},
"android": {
"keystore_alias": "",
"keystore_password": ""
},
"asset_links": {
"android": [],
"ios": {}
Expand Down

0 comments on commit de616fc

Please sign in to comment.