Skip to content

Commit

Permalink
extract tag prefix and account for different latest tag alias in rele…
Browse files Browse the repository at this point in the history
…ase task
  • Loading branch information
mojavelinux committed Nov 21, 2023
1 parent c4dea04 commit 8174eb8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions 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, ref, token, updateBranch, lates
let variant = ref ? ref.replace(/^refs\/heads\//, '') : 'main'
if (variant === 'main') variant = 'prod'
ref = ref.replace(/^refs\//, '')
const tagName = `${variant}-${await getNextReleaseNumber({ octokit, owner, repo, variant })}`
const latestTagName = latestAlias === false ? undefined : `${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 8174eb8

Please sign in to comment.