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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust deploy scripts to archive old releases in a separate branch, move existing releases out of master #2426

Merged
merged 11 commits into from Jan 28, 2022
2 changes: 0 additions & 2 deletions .prettierignore
Expand Up @@ -6,5 +6,3 @@ tmp/
docs/_site/
docs/js/
docs/assets/js/
CHANGELOG.md
docs/changelog.md
2 changes: 1 addition & 1 deletion RELEASE.md
Expand Up @@ -9,9 +9,9 @@ The release process is mostly automated, here is a brief overview of the steps
- Updates `AUTHORS`
- Updates `package.json` with new version
- Creates a new git tag
- Copies new release documentation into place in `docs/_releases/`, using the new release id
2. `npm publish` publishes the new release to the npm registry
3. `git push origin --follow-tags` pushes the changes to GitHub
4. Archive the new release in the `releases` branch under the new release id

Each step is described in detail below.

Expand Down
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -49,13 +49,12 @@
"lint": "eslint '**/*.{js,cjs,mjs}'",
"pretest-webworker": "npm run build",
"prebuild": "rimraf pkg && npm run check-dependencies",
"postbuild": "npm run test-esm-bundle",
"prebuild-docs": "./scripts/update-compatibility.js",
"prepublishOnly": "npm run build",
"prettier:check": "prettier --check '**/*.{js,css,md}'",
"prettier:write": "prettier --write '**/*.{js,css,md}'",
"preversion": "./scripts/preversion.sh",
"version": "changes --commits --footer",
"version": "./scripts/version.sh",
"postversion": "./scripts/postversion.sh"
},
"nyc": {
Expand Down
5 changes: 5 additions & 0 deletions scripts/copy-documentation-for-new-release.sh
Expand Up @@ -32,6 +32,11 @@ function copy_source_to(){
cp -r "$SOURCE_PATH/release/"* "$DIR"
cp "$SOURCE_PATH/release.md" "$FILE_PATH"

# Remove .gitignore'd files from copies
# Otherwise they will remain on the local filesytem
rm -r "$DIR/examples/node_modules"
rm "$DIR/examples/package-lock.json"

fatso83 marked this conversation as resolved.
Show resolved Hide resolved
# replace `release_id: master` with `release_id: $RELEASE_VERSION` in
# $FILE_PATH
sed -i.bak "s/release_id: master/release_id: $RELEASE_VERSION/g" "$FILE_PATH"
Expand Down
31 changes: 16 additions & 15 deletions scripts/postversion.sh
@@ -1,29 +1,30 @@
#!/bin/bash
set -e
PACKAGE_VERSION=$(node -p -e "require('./package.json').version")
ARCHIVE_BRANCH="releases"
SOURCE_BRANCH=$(git rev-parse --abbrev-ref HEAD)

echo 'postversion tasks'
prettier --write CHANGES.md # after manually hand-editing this might need fixes
./scripts/copy-documentation-for-new-release.sh $PACKAGE_VERSION

echo 'set new current/next release id in documentation'
node ./scripts/set-release-id-in-config-yml.cjs
# npm publish will generate the pkg/sinon.js that we use below
echo 'publish to npm'
git push --follow-tags
npm publish --dry-run
fatso83 marked this conversation as resolved.
Show resolved Hide resolved

echo 'update changelog'
./scripts/update-changelog-page.sh
# Now update the releases branch and archive the new release
git checkout $ARCHIVE_BRANCH
git merge --no-edit -m "Merge version $PACKAGE_VERSION" $SOURCE_BRANCH

echo 'build new package'
node ./build.cjs
./scripts/copy-documentation-for-new-release.sh $PACKAGE_VERSION

echo 'copying latest sinon to webpage assets'
cp pkg/sinon.js ./docs/assets/js/
echo 'copying new version to webpage assets'
cp "./pkg/sinon.js" "./docs/assets/js/"

echo 'copy new version'
echo 'copy new version to release archive'
cp "./pkg/sinon.js" "./docs/releases/sinon-$PACKAGE_VERSION.js"

git add "docs/releases/sinon-$PACKAGE_VERSION.js"
git add docs/changelog.md
git add docs/_config.yml
git commit -n -m "Update docs/changelog.md and set new release id in docs/_config.yml"
git commit -n -m "Add version $PACKAGE_VERSION to releases"

git push --follow-tags && npm publish
git push
git checkout $SOURCE_BRANCH
2 changes: 1 addition & 1 deletion scripts/update-changelog-page.sh
Expand Up @@ -5,5 +5,5 @@ title: Changelog
permalink: /releases/changelog
---
# Changelog
$(<CHANGES.md)
$(tail -n+2 CHANGES.md)
EOL
19 changes: 19 additions & 0 deletions scripts/version.sh
@@ -0,0 +1,19 @@
#!/bin/bash
set -e

echo 'update CHANGES.md'
changes --commits --footer

# Tidy CHANGES.md after any manual hand-editing
prettier --write CHANGES.md

echo 'set new current/next release id in documentation'
node ./scripts/set-release-id-in-config-yml.cjs

echo 'update changelog'
./scripts/update-changelog-page.sh

# Add our updates
git add docs/changelog.md
git add docs/_config.yml
git add CHANGES.md