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

Tweak release shell scripts and publishing docs #589

Merged
merged 4 commits into from
Mar 16, 2018
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Breaking changes:
`govuk-c-radios--inline` which will automatically make all the radio buttons
within that block inline.
(PR [#607](https://github.com/alphagov/govuk-frontend/pull/607))

Internal:
- Update check script for new components and tweak docs
(PR [#589](https://github.com/alphagov/govuk-frontend/pull/589))

## 0.0.26-alpha (Breaking release)

Expand Down
21 changes: 11 additions & 10 deletions bin/check-and-create-package-json.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ ALL_PACKAGE_JSON_FILES_PRESENT=true;

# function to create a sample package.json
# and add latest published version of globals as dependency (as it's most common)
# we're currently matching the version number with other compoments
# we need to decide what the initial version for new components is
create_package_json()
{
GLOBALS_PACKAGE_VERSION=$(node -p "require('./packages/globals/package.json').version")
PACKAGE_JSON='
{
"name": "@govuk-frontend/'${D##*/}'",
"version": "0.0.0",
"dependencies": {
"@govuk-frontend/globals": "'$GLOBALS_PACKAGE_VERSION'"
}
}'
GLOBALS_PACKAGE_VERSION=$(node -p "require('./packages/globals/package.json').version")
PACKAGE_JSON='{
"name": "@govuk-frontend/'${D##*/}'",
"version": "'$GLOBALS_PACKAGE_VERSION'",
"dependencies": {
"@govuk-frontend/globals": "^'$GLOBALS_PACKAGE_VERSION'"
}
}'

# create a package.json file
echo "$PACKAGE_JSON" >> "${D}/package.json"
Expand All @@ -35,7 +36,7 @@ for D in $PACKAGES_DIR*; do
# ${D##*/} strips everything before /
COMPONENT_NAME=${D##*/}
echo "⚠️ 🆕 $COMPONENT_NAME 🆕 component is missing a package.json file.\n"
echo "⚠️ I've created a sample package.json file. Please amended it with correct data.\n"
echo "⚠️ I've created a sample package.json file. Please specify all required dependencies and save the changes. No need to commit.\n"

create_package_json ${D}

Expand Down
10 changes: 5 additions & 5 deletions bin/npm-publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ set -e

PACKAGE=$(node -p "require('./package.json').name")
VERSION=$(node -p "require('./package.json').version")
PUBLISHED=$(npm info $PACKAGE@$VERSION version)

if [ "$VERSION" == "$PUBLISHED" ]; then
echo "⚠️ $PACKAGE@$VERSION is already published!"
else
echo "📦 Publishing: $PACKAGE@$VERSION"
# check if package exists or if the current version of the package is already published
if [ -z "$(npm info ${PACKAGE} 2> /dev/null)" ] || [ "$(npm info $PACKAGE@$VERSION version)" != "$VERSION" ]; then
npm publish $@
echo "🗒 Package published!"
else
echo "⚠️ $PACKAGE@$VERSION is already published!"
fi
Binary file modified docs/img/lerna-confirm-publish.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/img/lerna-select-version.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/img/new-component-prompt.png
Binary file not shown.
102 changes: 47 additions & 55 deletions docs/publishing.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,76 +12,68 @@ version bumped.

### Publishing components manually (while in Alpha/Private beta)

*First time only: Shell scripts will require permission to run.
Run `chmod u+x **/*.sh` which will give the permission to all shell
scripts in the current directory.*
1. Checkout **master** and pull latest changes.

1. Create a new branch that's up to date with master and:
2. Create and checkout a new branch (`release-[version-number]`).

2. Update `CHANGELOG` version heading with the next version number.
3. Update [`CHANGELOG.md`](../CHANGELOG.md) "Unreleased" heading with the new version number.
This should be incremented based on [Semantic versioning](https://semver.org/) from the unreleased changes listed.

3. Run `npm run pre-release` task.
This will:
- run `npm build:packages` that copies any changes from`src/component-name` to `packages/component-name` and runs `after-build-packages.test.js` test
to ensure the contents of `packages` matches `src`.


If you have a new component was added to `src` and copied over to `packages` in the above task, then then script will detect those components, notify the developer, create a sample `package.json` file for each.
4. Save the changes. Do not commit.

It will reminnd the developer to check the version number, dependencies and add new components to `all/package.json` dependencies.
5. Run `npm run pre-release`.

It will also prompt the develoeper to signal to the scipt once changes have been made, so that the rest of the `npm run pre-release` tasks can run.**
![New component added](./img/new-component-prompt.png)
This will:
- copy components from `src/` to `packages/` and run tests
- add [vendor prefixes](https://github.com/postcss/autoprefixer) to CSS in `packages/`
- build "all" Sass and JavaScript files into `dist/`
- copy components from `src/` to `dist/components/` and run tests

Note: If a previously unreleased component is found, then you will be prompted to make changes before continuing.

- run `lerna publish --skip-git --skip-npm` which will check for updated packages and
suggest a version for each as seen below.
Lerna will prompt you to select the new version for each package. If you
select `minor`/`major` etc., Lerna will complete the version number for you. In
private beta, we have selected `custom` and specified the new version number
manually for each package (see below). Also see step 3 regarding the versioning
of new components:
6. For each package specify a new version number, based on changelog updates (Step 3.).
![Select version in Lerna](./img/lerna-select-version.png)
Once you confirm changes, all files are automatically added and commited with
the commit message `Release <version number>` and pushed to origin.

7. Review proposed version number updates.
![Confirm publishing of changes in Lerna](./img/lerna-confirm-publish.png)

- run `npm build:dist` that copies any changes from`src/component-name` to `dist/components/component-name` and runs `after-build-dist.test.js` test
to ensure the contents of `dist/componenents` matches `src`.
It compiles and minifies CSS and JavaScript and applies version number
(taken from `all/package.json` file), e.g `govuk-frontend-<version>-alpha.min`.
Finally it copies all icons from the `src/icons`.
Once you publish changes, all files are automatically pushed to the remote origin branch.

4. Create a pull request for these changes. When reviewing the PR check version of compile assets and check release notes for the changes made.
8. Create a pull request and copy the changelog text.
When reviewing the PR, check that the version numbers have been updated and that the compiled assets use this verson number.

5. Once the pull request is approved, merge to **master** and run `npm run release` in **master**.
9. Once the pull request is approved, merge to **master**.

This will:
- check if you're logged in to NPM as the correct user. If not, it will abort.
- run `npm publish` for each package if the package hasn't been published yet
(check that the currect version matches the version on NPM)
- run `git tag v<version>` to create a new tag if current git tag doesn't match latest published tag
- push the tag to remote with `git push --tags`
- create a zip file of the `dist` directory with
`git archive -o ./release-<version>.zip HEAD:dist`
10. Checkout **master** and pull the latest changes.

6. Create a release in Github interface, ddd release notes to and attach the ZIP.
11. Log into npm, using team [credentials](https://github.com/alphagov/design-system-team-credentials/tree/master/npm/govuk-patterns-and-tools).

7. Add Trello cards to "This Sprint" column for
- updating GOV.UK Design System to use the latest releasex
- updating the Prototype Kit to use the latest release
12. Run `npm run release`.

This will:
- check that you're logged in to npm as the correct user.
- publish each package if the package has not been published yet
- create a new tag if the current git tag does not match the latest published tag
- push the tag to remote origin
- create a zip file of the `dist` directory

13. Create a release in the [Github interface](https://github.com/alphagov/govuk-frontend/releases/new)
- select the latest tag version
- set "GOV.UK Frontend release v[version-number]" as the title
- add release notes from changelog
- attach the generated ZIP that is located at the root of the project
- publish release

14. (Required for private beta) Grant "test" user access to any newly published package(s).
```bash
npm access grant read-only govuk-frontend:test @govuk-frontend/[component-name]
```
15. Log out from npm
```bash
npm logout
```
#### Test published packages

1. To test the packages have published correctly, in console login as the test
user. In the Design System, run `npm install` and then `npm start`. Check that
the changes have taken effect.

## Updating other repos that consume `govuk-frontend`

If you need to update `govuk-frontend` to the latest release on another repo
that consumes it, make sure you are logged in as the npm test user to ensure that
the permissions of `govuk-frontend` packages have been correctly set.

You can use `npm whoami` to check your current user.
16. Add Trello cards to "This Sprint" column for
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this step, I see it more as part of our release plan/process rather than the publishing process.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leaving it there for now until there is a better home

- Update the GOV.UK Design System to use the latest release
- Update the GOV.UK Prototype Kit to use the latest release