Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fallback to default release process of 404 from hosted version #386

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions lib/release/release-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ class ReleaseManager {
const [release, workspaces = []] = await this.#getPrReleases({ pullRequest })
const releaseItems = await this.#getReleaseProcess({ release, workspaces })

core.info(
`Filtered ${releaseItems.length} release process items:\n`,
releaseItems.map(r => r.split('\n')[0].replace('- [ ] ', '')).join(', ')
)
core.info(`Filtered ${releaseItems.length} release process items:`)
core.info(releaseItems.map(r => r.split('\n')[0].replace('- [ ] ', '')).join(', '))

const checklist = releaseItems
.join('\n\n')
Expand Down Expand Up @@ -125,7 +123,7 @@ class ReleaseManager {
throw new Error('Could not find version with:', ROOT_VERSION)
}

core.info('Found version', version)
core.info(`Found version: ${version}`)
return [getReleaseInfo({ version })]
}

Expand All @@ -136,10 +134,10 @@ class ReleaseManager {
const release = getReleaseInfo({ name, version })

if (!name) {
core.info('Found root', release)
core.info(`Found root: ${JSON.stringify(release)}`)
acc[0] = release
} else {
core.info('Found workspace', release)
core.info(`Found workspace: ${JSON.stringify(release)}`)
acc[1].push(release)
}

Expand All @@ -150,13 +148,22 @@ class ReleaseManager {
async #getReleaseProcess ({ release, workspaces }) {
const RELEASE_LIST_ITEM = /^\d+\.\s/gm

core.info(`Fetching release process from:`, this.#owner, this.#repo, 'wiki')
core.info(`Fetching release process from repo wiki: ${this.#owner}/${this.#repo}`)

const releaseProcess = await fetch(
`https://raw.githubusercontent.com/wiki/${this.#owner}/${this.#repo}/Release-Process.md`
)
.then(r => r.text())
.catch(() => this.#getReleaseSteps())
.then(r => {
if (r.status === 200) {
core.info('Found release process from wiki')
return r.text()
} else if (r.status === 404) {
core.info('No release process found in wiki, falling back to default process')
return this.#getReleaseSteps()
} else {
throw new Error(`Release process fetch failed with status: ${r.status}`)
}
})

// XXX: the release steps need to always be the last thing in the doc for this to work
const releaseLines = releaseProcess.split('\n')
Expand Down