Skip to content

Commit

Permalink
Merge pull request #4348 from EdgeApp/paul/fixVersion
Browse files Browse the repository at this point in the history
Fix missing version suffix
  • Loading branch information
paullinator authored Jul 26, 2023
2 parents 42f4eeb + 4f78e61 commit 9a3322b
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 132 deletions.
47 changes: 42 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ Otherwise, to get an APK, do:

### Build release version of app

First, run `yarn update-version` to copy the `package.json` version into the native project files, and to assign a unique build number.

#### iOS

- Open `edge-react-gui/ios/edge.xcworkspace` in Xcode
Expand All @@ -98,18 +96,41 @@ First, run `yarn update-version` to copy the `package.json` version into the nat

---

## Deploying (macOS Only)
## Deploying (MacOS Only)

This repo includes several utility scripts that can be used in a CI/CD
environment to build and deploy a release version of the app. The
included `Jenkinsfile` utilizes all the scripts but you are free to
use them in your own CI environment.

### Update the version file

Set `BUILD_REPO_URL` to the URL of an empty Git repo that will hold a version
file that will be auto updated to increment the version and build number. Then
run the following to update a local `release-version.json` file

yarn gitVersionFile

Update the project files based on the version in `release-version.json`

yarn updateVersion


### Build, sign, and deploy

The included `deploy.js` is a script to automate building, signing, and deploying release builds of Edge. It provides the following:
The included `deploy.ts` is a script to automate building, signing, and deploying release builds of Edge. It provides the following:

- Auto sign Android APK with Android keystore files
- Auto sign iOS IPA with provisioning profiles
- Build release version of iOS and Android
- Upload iOS IPA and Android APK files to AppCenter for developer testing

### To Use

- Run `yarn update-version` to set up your build number & version.
- Set the env var KEYCHAIN_PASSWORD to the keychain password of the current user
- Copy the `deploy-config.sample.json` to `deploy-config.json` and edit the parameters accordingly. You'll need a HockeyApp account to get ids and keys
- Download a copy of the Google Bundle tool (https://github.com/google/bundletool/releases)
- Set the `bundleToolPath` in `deploy-config.json` to the path to the bundle tool `.jar` file
- Put any Android keystore files into `edge-react-gui/keystores/`
- If using Firebase, put your account's `google-services.json` and `GoogleService-Info.plist` into `edge-react-gui/`
- Install xcpretty `sudo gem install xcpretty`
Expand All @@ -121,6 +142,22 @@ yarn deploy edge ios master
yarn deploy edge android master
```

## Fastlane support

This repo supports utilizing Fastlane to automate updates to iOS Provisioning
Profiles. To use Fastlane, set the following environment variables and run
`yarn deploy` as mentioned above

BUILD_REPO_URL // Git repo used to store encrypted provisioning
// keys.
// Will be shared with the gitVersionFile.ts script
FASTLANE_USER // Apple ID email
FASTLANE_PASSWORD // Apple ID password
GITHUB_SSH_KEY // (Optional) SSH Key file to use when accessing
// BUILD_REPO_URL
MATCH_KEYCHAIN_PASSWORD // Password to unlock the current users keychain
MATCH_PASSWORD // Password used to encrypt profile information
// before being saved to the BUILD_REPO_URL
---

## Debugging
Expand Down
6 changes: 5 additions & 1 deletion deploy-config.sample.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
{
"edge": {
"productName": "Edge Wallet",
"xcodeProject": "edge.xcodeproj",
"xcodeWorkspace": "edge.xcworkspace",
"xcodeScheme": "edge",
"androidKeyStore": "edge-release-keystore.jks",
"androidKeyStoreAlias": "edge",
"androidKeyStorePassword": "xxxxxxxxx",
"androidTask": "assembleRelease",
"androidTask": "bundleRelease",
"hockeyAppToken": "xxxxx",
"hockeyAppTags": "internal",
"bugsnagApiKey": "xxxxxxxxxx",
"appCenterApiToken": "xxxxxxxxxx",
"appCenterGroupName": "xxxxxxxxxx",
"appCenterDistroGroup": "xxxxxxxxxx",
"appleDeveloperTeamId": "xxxxxxxxxx",
"appleDeveloperTeamName": "edge",
"bundleId": "co.edgesecure.app",
"bundleToolPath": "/Users/jenkins/bin/bundletool-all-1.11.2.jar",
"ios": {
"master": {
"hockeyAppId": "xxxxxxxxx"
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"fix-java": "cd android; ./format-java.sh",
"fix-swift": "swift-format format -i ios/*.swift",
"fix": "npm run lint -- --fix && yarn-deduplicate",
"gitVersionFile": "node -r sucrase/register scripts/gitVersionFile.ts",
"ios": "react-native run-ios",
"lint": "eslint .",
"localize": "node -r sucrase/register ./scripts/localizeLanguage.ts; git add ./src/locales/strings",
Expand All @@ -49,7 +50,7 @@
"start": "react-native start",
"test": "jest",
"theme": "node -r sucrase/register ./scripts/themeServer.ts",
"update-version": "node -r sucrase/register scripts/updateVersion.ts",
"updateVersion": "node -r sucrase/register scripts/updateVersion.ts",
"updot": "EDGE_MODE=development updot",
"watch": "npm test -- --watch"
},
Expand Down
2 changes: 1 addition & 1 deletion scripts/gitVersionFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const versionFileName = 'release-version.json'

async function main() {
const cwd = join(__dirname, '..')
const [branch] = process.argv.slice(2)
const branch = process.argv[2] ?? 'master'

// Determine the current version:
const packageJson = JSON.parse(fs.readFileSync(join(cwd, 'package.json'), { encoding: 'utf8' }))
Expand Down
68 changes: 2 additions & 66 deletions scripts/updateVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,83 +24,19 @@ import path from 'path'

import { asVersionFile, VersionFile } from './cleaners'

const specialBranches: { [branch: string]: string } = {
develop: '-d',
master: '',
beta: '',
coinhub: '',
staging: '-rc',
test: '-t',
yolo: '-yolo',
'test-cheddar': '-cheddar',
'test-feta': '-feta',
'test-gouda': '-gouda',
'test-halloumi': '-halloumi',
'test-paneer': '-paneer'
}

async function main() {
const cwd = path.join(__dirname, '..')
const disklet = makeNodeDisklet(cwd)
const [branch] = process.argv.slice(2)

// Determine the current build number:
const build = Math.max(pickBuildNumber(), 1 + (await readLastBuildNumber(disklet)))

// Determine the current version:
const packageJson = JSON.parse(await disklet.getText('package.json'))
const version = `${packageJson.version}${pickVersionSuffix(branch)}`
const file = await disklet.getText('release-version.json')
const versionFile = asVersionFile(file)

// Write the vesion info file:
const versionFile = {
branch,
build,
version
}
console.log(versionFile)
await disklet.setText('release-version.json', JSON.stringify(versionFile, null, 2))

// Update the native project files:
await Promise.all([updateAndroid(disklet, versionFile), updateIos(cwd, versionFile)])
}

/**
* Pick a build number based on the current date.
*/
function pickBuildNumber(now: Date = new Date()) {
const year = now.getFullYear() - 2000
const month = now.getMonth() + 1
const day = now.getDate()
const counter = 1

return (year % 100) * 1000000 + month * 10000 + day * 100 + counter
}

/**
* Pick a suffix to add to the package.json version.
*/
function pickVersionSuffix(branch?: string): string {
if (branch == null || branch === '') return ''

const specialSuffix = specialBranches[branch]
if (specialSuffix != null) return specialSuffix

return '-' + branch.replace(/[^0-9a-zA-Z]+/g, '-')
}

/**
* Read the previous build number from release-version.json file.
*/
async function readLastBuildNumber(disklet: Disklet): Promise<number> {
try {
const text = await disklet.getText('release-version.json')
const { build } = asVersionFile(text)
return build
} catch (e) {
return 0
}
}

/**
* Inserts the build information into the Android project files.
*/
Expand Down
58 changes: 0 additions & 58 deletions scripts/updateVersions.ts

This file was deleted.

0 comments on commit 9a3322b

Please sign in to comment.