Get channel from environment instead of branch name

This commit is contained in:
Markus Olsson 2023-06-28 10:56:56 +02:00
parent f2bb15c447
commit f3d8808ddf
3 changed files with 8 additions and 39 deletions

View file

@ -19,6 +19,9 @@ on:
default: false
required: false
type: boolean
environment:
type: string
required: true
jobs:
lint:
@ -83,6 +86,7 @@ jobs:
- name: Build production app
run: yarn build:prod
env:
RELEASE_CHANNEL: ${{ inputs.environment }}
DESKTOP_OAUTH_CLIENT_ID: ${{ secrets.DESKTOP_OAUTH_CLIENT_ID }}
DESKTOP_OAUTH_CLIENT_SECRET:
${{ secrets.DESKTOP_OAUTH_CLIENT_SECRET }}

View file

@ -12,7 +12,3 @@ export function getSha() {
export function isGitHubActions() {
return process.env.GITHUB_ACTIONS === 'true'
}
export function getReleaseBranchName(): string {
return process.env.GITHUB_REF?.replace(/^refs\/heads\//, '') ?? ''
}

View file

@ -2,15 +2,12 @@ import * as Path from 'path'
import * as Fs from 'fs'
import { getProductName, getVersion } from '../app/package-info'
import { getReleaseBranchName } from './build-platforms'
const productName = getProductName()
const version = getVersion()
const projectRoot = Path.join(__dirname, '..')
const publishChannels = ['production', 'test', 'beta']
export function getDistRoot() {
return Path.join(projectRoot, 'dist')
}
@ -109,39 +106,11 @@ export function getBundleSizes() {
mainBundleSize: Fs.statSync(Path.join(outPath, 'main.js')).size,
}
}
export const isPublishable = () =>
['production', 'beta', 'test'].includes(getChannel())
export function isPublishable(): boolean {
const channelFromBranch = getChannelFromBranch()
return channelFromBranch !== undefined
? publishChannels.includes(channelFromBranch)
: false
}
export function getChannel() {
const channelFromBranch = getChannelFromBranch()
return channelFromBranch !== undefined
? channelFromBranch
: process.env.NODE_ENV || 'development'
}
function getChannelFromBranch(): string | undefined {
// Branch name format: __release-CHANNEL-DEPLOY_ID
const pieces = getReleaseBranchName().split('-')
if (pieces.length < 3 || pieces[0] !== '__release') {
return
}
return pieces[1]
}
export function getReleaseSHA() {
// Branch name format: __release-CHANNEL-DEPLOY_ID
const pieces = getReleaseBranchName().split('-')
if (pieces.length < 3 || pieces[0] !== '__release') {
return null
}
return pieces[2]
}
export const getChannel = () =>
process.env.RELEASE_CHANNEL ?? process.env.NODE_ENV ?? 'development'
export function getDistArchitecture(): 'arm64' | 'x64' {
// If a specific npm_config_arch is set, we use that one instead of the OS arch (to support cross compilation)