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

Automate mithril's release workflow #2760

Merged
merged 9 commits into from
Apr 27, 2022
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
2 changes: 1 addition & 1 deletion .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
auto-merge:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ahmadnassri/action-dependabot-auto-merge@v2
with:
target: patch
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: merge

on:
push:
dead-claudia marked this conversation as resolved.
Show resolved Hide resolved
branches: [ main ]

workflow_dispatch:

concurrency: prr:deploy

jobs:
merge:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]

steps:
- uses: actions/checkout@v3
with:
ref: 'next'
fetch-depth: 0

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build
- run: npx pr-release merge --target main --source next --commit --force --clean --changelog ./docs/recent-changes.md --compact
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

# The following will publish the release to npm
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
name: Setup NPM Auth
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: npm publish
name: Publish
41 changes: 41 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: pr

on:
push:
branches: [ next ]

workflow_dispatch:

pull_request:
types: [labeled, unlabeled, edited]

concurrency: prr:pre-release

jobs:
pr:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build
- run: npx pr-release pr --verbose --target main --source next --compact --verbose
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
# The following will publish a prerelease to npm
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
name: Setup NPM Auth
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: npx pr-release infer-prerelease --preid=next --verbose --publish
name: Publish
31 changes: 31 additions & 0 deletions .github/workflows/rollback.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: rollback

on:
workflow_dispatch:

concurrency: prr:deploy

jobs:
pr:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]

steps:
- uses: actions/checkout@v3
with:
ref: 'next'
fetch-depth: 0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build
- run: npx pr-release rollback --verbose --target main --source next --verbose --ignore 'package*' --ignore docs/changelog.md --ignore docs/recent-changes.md
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
101 changes: 0 additions & 101 deletions .travis.yml

This file was deleted.

104 changes: 22 additions & 82 deletions docs/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,102 +4,40 @@ Describes how we do releases of Mithril.js

# Mithril.js Release Processes

**Note** These steps all assume that `MithrilJS/mithril.js` is a git remote named `mithriljs`, adjust accordingly if that doesn't match your setup.
Mithril.js' release process is automated by [pr-release]. pr-release is maintained by a long time Mithril.js community member [@JAForbes](https://github.com/JAForbes).

- [Releasing a new Mithril.js version](#releasing-a-new-mithriljs-version)
- [Updating mithril.js.org](#updating-mithriljsorg)
pr-release handles the following:

## Releasing a new Mithril.js version
- Generating changelog entries
- Automating the semver version
- Publishing releases and pre-releases to npm
- Creating github releases
- Rollbacks

### Prepare the release
## For contributors

1. Ensure your local branch is up to date
Contributors should create their feature branch targetting the default branch `next`. When this branch is merged `pr-release` will either generate or update a release PR from `next` to `main`.

```bash
$ git checkout next
$ git pull --rebase mithriljs next
```

2. Determine patch level of the change
3. Update information in `docs/changelog.md` to match reality of the new version being prepared for release.
- Don't forget to add today's date under the version heading!
4. Replace all existing references to `mithril@next` to `mithril` if moving from a release candidate to stable.
- Note: if making an initial release candidate, don't forget to move all the playground snippets to pull from `mithril@next`!
5. Commit changes to `next`

```
$ git add .
$ git commit -m "Preparing for release"

# Push to your branch
$ git push

# Push to MithrilJS/mithril.js
$ git push mithriljs next
```

### Merge from `next` to `master`

6. Switch to `master` and make sure it's up to date

```bash
$ git checkout master
$ git pull --rebase mithriljs master
```

7. merge `next` on top of it

```bash
$ git merge next
```
The description and title will be managed by [pr-release], including the semver version.

8. Clean & update npm dependencies and ensure the tests are passing.
Contributors who have permissions should add the correct semver label to their PR (`major` | `minor` | `patch`). If no label is set, `patch` is assumed.

```bash
$ npm prune
$ npm i
$ npm test
```

### Publish the release
If you do not have permissions, the maintainer will set the label on your behalf.

9. `npm run release <major|minor|patch|semver>`, see the docs for [`npm version`](https://docs.npmjs.com/cli/version)
10. The changes will be automatically pushed to your fork
11. Push the changes to `MithrilJS/mithril.js`

```bash
$ git push mithriljs master
```
## Changelog

12. Travis will push the new release to npm & create a GitHub release
There are two changelogs in the Mithril.js project

### Merge `master` back into `next`
- `docs/changelog.md` a hand written curated reflection of changes to the codebase
- `docs/release.md` an automatically prepended log of changes, managed by pr-release

This helps to ensure that the `version` field of `package.json` doesn't get out of date.
In future we may collapse these into a single file, the separation is due to the fact the `changelog.md` predates the `release.md` file.

13. Switch to `next` and make sure it's up to date
## For maintainers

```bash
$ git checkout next
$ git pull --rebase mithriljs next
```
Whenever a new feature branch is opened, a reviewing maintainer should add the correct semver label to their PR (`major` | `minor` | `patch`). If no label is set, `patch` is assumed.
JAForbes marked this conversation as resolved.
Show resolved Hide resolved

14. Merge `master` back onto `next`

```bash
$ git merge master
```

15. Push the changes to your fork & `MithrilJS/mithril.js`

```bash
$ git push
$ git push mithriljs next
```

### Update the GitHub release

16. The GitHub Release will require a manual description & title to be added. I suggest coming up with a fun title & then copying the `docs/changelog.md` entry for the build.
If a `major` or `minor` feature branch is merged but no labels were set, you can still go back and edit the semver labels. On label change the release pr will automatically be regenerated and will recalculate the semver version.

## Updating mithril.js.org

Expand All @@ -124,3 +62,5 @@ $ node scripts/update-docs
After the docs build completes, the updated docs should appear on https://mithril.js.org in a few minutes.

**Note:** When updating the stable version with a release candidate out, ***make sure to update the index + navigation to point to the new stable version!!!***

[pr-release]: https://pr-release.org/
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
"pretest": "npm run lint",
"test": "run-s test:js",
"test:js": "ospec",
"cover": "istanbul cover --print both ospec/bin/ospec",
"release": "npm version -m 'v%s'",
"version": "npm run build && git add mithril.js mithril.min.js stream.js stream.min.js README.md"
"cover": "istanbul cover --print both ospec/bin/ospec"
},
"devDependencies": {
"@alrra/travis-scripts": "^3.0.1",
Expand Down
Loading