Skip to content

Commit f3d8808

Browse files
committed
Get channel from environment instead of branch name
1 parent f2bb15c commit f3d8808

3 files changed

Lines changed: 8 additions & 39 deletions

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ on:
1919
default: false
2020
required: false
2121
type: boolean
22+
environment:
23+
type: string
24+
required: true
2225

2326
jobs:
2427
lint:
@@ -83,6 +86,7 @@ jobs:
8386
- name: Build production app
8487
run: yarn build:prod
8588
env:
89+
RELEASE_CHANNEL: ${{ inputs.environment }}
8690
DESKTOP_OAUTH_CLIENT_ID: ${{ secrets.DESKTOP_OAUTH_CLIENT_ID }}
8791
DESKTOP_OAUTH_CLIENT_SECRET:
8892
${{ secrets.DESKTOP_OAUTH_CLIENT_SECRET }}

script/build-platforms.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,3 @@ export function getSha() {
1212
export function isGitHubActions() {
1313
return process.env.GITHUB_ACTIONS === 'true'
1414
}
15-
16-
export function getReleaseBranchName(): string {
17-
return process.env.GITHUB_REF?.replace(/^refs\/heads\//, '') ?? ''
18-
}

script/dist-info.ts

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@ import * as Path from 'path'
22
import * as Fs from 'fs'
33

44
import { getProductName, getVersion } from '../app/package-info'
5-
import { getReleaseBranchName } from './build-platforms'
65

76
const productName = getProductName()
87
const version = getVersion()
98

109
const projectRoot = Path.join(__dirname, '..')
1110

12-
const publishChannels = ['production', 'test', 'beta']
13-
1411
export function getDistRoot() {
1512
return Path.join(projectRoot, 'dist')
1613
}
@@ -109,39 +106,11 @@ export function getBundleSizes() {
109106
mainBundleSize: Fs.statSync(Path.join(outPath, 'main.js')).size,
110107
}
111108
}
109+
export const isPublishable = () =>
110+
['production', 'beta', 'test'].includes(getChannel())
112111

113-
export function isPublishable(): boolean {
114-
const channelFromBranch = getChannelFromBranch()
115-
return channelFromBranch !== undefined
116-
? publishChannels.includes(channelFromBranch)
117-
: false
118-
}
119-
120-
export function getChannel() {
121-
const channelFromBranch = getChannelFromBranch()
122-
return channelFromBranch !== undefined
123-
? channelFromBranch
124-
: process.env.NODE_ENV || 'development'
125-
}
126-
127-
function getChannelFromBranch(): string | undefined {
128-
// Branch name format: __release-CHANNEL-DEPLOY_ID
129-
const pieces = getReleaseBranchName().split('-')
130-
if (pieces.length < 3 || pieces[0] !== '__release') {
131-
return
132-
}
133-
return pieces[1]
134-
}
135-
136-
export function getReleaseSHA() {
137-
// Branch name format: __release-CHANNEL-DEPLOY_ID
138-
const pieces = getReleaseBranchName().split('-')
139-
if (pieces.length < 3 || pieces[0] !== '__release') {
140-
return null
141-
}
142-
143-
return pieces[2]
144-
}
112+
export const getChannel = () =>
113+
process.env.RELEASE_CHANNEL ?? process.env.NODE_ENV ?? 'development'
145114

146115
export function getDistArchitecture(): 'arm64' | 'x64' {
147116
// If a specific npm_config_arch is set, we use that one instead of the OS arch (to support cross compilation)

0 commit comments

Comments
 (0)