Skip to content

Commit

Permalink
extract tag prefix and account for different latest tag alias in UI r…
Browse files Browse the repository at this point in the history
…elease task
  • Loading branch information
mojavelinux committed Nov 21, 2023
1 parent ca0e19e commit 5e80c16
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ui/gulp.d/tasks/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ const map = (transform, flush = undefined) => new Transform({ objectMode: true,
const vfs = require('vinyl-fs')
const zip = require('@vscode/gulp-vinyl-zip')

function getNextReleaseNumber ({ octokit, owner, repo, variant }) {
const prefix = `${variant}-`
const filter = ({ name }) => name.startsWith(prefix) && !name.endsWith('-latest')
function getNextReleaseNumber ({ octokit, owner, repo, tagPrefix, latestTagName }) {
const filter = ({ name }) => name !== latestTagName && name.startsWith(tagPrefix)
return collectReleases({ octokit, owner, repo, filter }).then((releases) => {
if (releases.length) {
releases.sort((a, b) => -1 * a.name.localeCompare(b.name, 'en', { numeric: true }))
const latestName = releases[0].name
return Number(latestName.slice(prefix.length)) + 1
return Number(latestName.slice(tagPrefix.length)) + 1
} else {
return 1
}
Expand Down Expand Up @@ -80,8 +79,9 @@ module.exports = (dest, bundleName, owner, repo, dir, ref, token, updateBranch,
let variant = ref ? ref.replace(/^refs\/heads\//, '') : 'main'
if (variant === 'main' || variant === 'master') variant = 'prod'
ref = ref.replace(/^refs\//, '')
const tagName = `ui-${variant}-${await getNextReleaseNumber({ octokit, owner, repo, variant })}`
const latestTagName = latestAlias === false ? undefined : `ui-${variant}-${latestAlias || 'latest'}`
const tagPrefix = `ui-${variant}-`
const latestTagName = latestAlias === false ? undefined : `${tagPrefix}${latestAlias || 'latest'}`
const tagName = `${tagPrefix}${await getNextReleaseNumber({ octokit, owner, repo, tagPrefix, latestTagName })}`
const message = `Release ${tagName}`
const bundleFileBasename = `${bundleName}-bundle.zip`
const bundleFile = await versionBundle(ospath.join(dest, bundleFileBasename), tagName)
Expand Down

0 comments on commit 5e80c16

Please sign in to comment.