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

Doing everything other than the NPM release automatically #2316

Merged
merged 3 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
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
20 changes: 7 additions & 13 deletions internal_docs/releasing/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,17 @@ Before the release, the content designer needs to draft the release notes, based

2. Run `./scripts/prepare-release`.

3. Once someone has merged the pull request, [draft a new release on GitHub](https://github.com/alphagov/govuk-prototype-kit/releases)
3. When the script provides a Pull Request URL review it and approve when it's ready.

4. In Tag version and Release title, put v[version number], for example `v7.0.0`.
4. Once the script has finished checkout the *main* branch and pull the latest changes.

5. In the description, paste the relevant section from the release notes.
5. Sign in to npm (`npm login`), using the credentials for the govuk-prototype-kit npm user from Bitwarden.

6. Checkout the *main* branch and pull the latest changes.
6. Run `npm run clean-publish` and enter the one-time password when prompted.

7. Sign in to npm (`npm login`), using the credentials for the govuk-prototype-kit npm user from Bitwarden.
7. Run `npm logout` to log out from npm.

8. Run `npm run clean-publish` and enter the one-time password when prompted.

9. Run `npm logout` to log out from npm.

10. On GitHub, click 'Publish release'.

11. Let the community know about the release
8. Let the community know about the release

Write a brief summary with highlights from the release then send it to the following slack channels:

Expand All @@ -33,4 +27,4 @@ Write a brief summary with highlights from the release then send it to the follo

Make sure to send a link to the 'create a new prototype' page rather than the GitHub release page: https://prototype-kit.service.gov.uk/docs/create-new-prototype.

12. On the sprint board, move everything that's been released from the Ready for release column to the Done column
9. On the sprint board, move everything that's been released from the Ready for release column to the Done column
32 changes: 24 additions & 8 deletions scripts/utils/create-release-pr
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ function findIndexOfFirstMatchingLine (changelogLines, regExp) {
.at(0)
}

async function exec (command, { allowStderr = false, hideStd = false } = {}) {
async function exec (command, { allowStderr = false, hideStd = false, allowErrorCode = false } = {}) {
const newVersion = await new Promise((resolve) => {
console.log('running command', command)
cp.exec(command, { cwd: projectDir },
(error, stdout, stderr) => {
if (error) {
if (error && !allowErrorCode) {
console.log(`error: ${error.message}`)
process.exit(14)
}
Expand Down Expand Up @@ -118,6 +118,8 @@ const wait = time => new Promise((resolve) => setTimeout(resolve, time))
let isReadyToMerge = false
const requiredReviews = 1

await exec('npm install')

do {
await wait(5000)
await exec(`gh pr view ${prUrl} --json isDraft,reviewDecision,reviews,statusCheckRollup`, { hideStd: true })
Expand Down Expand Up @@ -168,15 +170,29 @@ const wait = time => new Promise((resolve) => setTimeout(resolve, time))

console.log('Tests pass, approval granted, ready to continue.')

console.log('To continue run these commands:')
console.log('')
console.log(`cd ${projectDir}`)
await exec(`gh pr merge ${prUrl} -m -d`)
await exec(`gh release create "v${newVersion}" --notes-file "${prBodyFile}" --target "main" --title "v${newVersion}" --latest`)

let loggedInAsCorrectNpmUser = false
const correctNpmUser = 'govuk-prototype-kit'

do {
await wait(2000)
const output = await exec('npm whoami', { allowStderr: true, allowErrorCode: true, hideStd: true })
if (output === correctNpmUser) {
loggedInAsCorrectNpmUser = true
} else if (output) {
console.log(`Currently logged in as [${output}], should be loggd in as [${correctNpmUser}]. Run [npm login] in another terminal.`)
} else {
console.log(`Please log in as [${correctNpmUser}] to continue by running [npm login] in another terminal.`)
}
} while (!loggedInAsCorrectNpmUser)
console.log('')
console.log(`gh pr merge ${prUrl} -m -d`)
console.log('logged in as the correct user')
console.log('')
console.log(`gh release create "v${newVersion}" --notes-file "${prBodyFile}" --target "main" --title "v${newVersion}" --latest`)
console.log('Everything other than the publish to NPM is complete, to publish to NPM run:')
console.log('')
console.log('npm login')
console.log(`cd ${projectDir}`)
console.log('')
console.log('npm run clean-publish')
console.log('')
Expand Down