Skip to content

Commit 6805f85

Browse files
authored
Merge pull request #41 from codewars/automate-release
2 parents fb5c989 + 1947569 commit 6805f85

17 files changed

+16223
-8773
lines changed

.babelrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/config.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"linked": [],
6+
"access": "public",
7+
"baseBranch": "master",
8+
"updateInternalDependencies": "patch",
9+
"ignore": []
10+
}

.changeset/nasty-bats-mix.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
"@codewars/marked-extensions": major
3+
---
4+
5+
Automate release
6+
7+
- Open and update a release PR when changes are merged
8+
- Release the package when a release PR is merged
9+
- Generate `CHANGELOG.md` based on changeset
10+
- Add `prepare` script so `npm install` builds the package
11+
- Remove `dist/` which is now generated before release or locally when developing
12+
- **BREAKING**: Move the package under `@codewars` org
13+
- **BREAKING**: Remove `dist/marked-extensions.js` IIFE build
14+
- **BREAKING**: Update `rollup` and remove `babel`
15+
- The generated code is almost identical except for arrow functions and the use of `const`

.github/workflows/changesets.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Automatically open/update release PR
2+
name: Changesets
3+
on:
4+
push:
5+
branches:
6+
- master
7+
env:
8+
CI: true
9+
jobs:
10+
version:
11+
timeout-minutes: 15
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 0
17+
- uses: actions/setup-node@v2
18+
with:
19+
node-version: "14"
20+
cache: "npm"
21+
- run: npm ci
22+
- name: create versions
23+
uses: changesets/action@master
24+
with:
25+
version: "npm run changeset-version"
26+
commit: "chore: update version"
27+
title: "chore: update version"
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Release when `chore: update version` is merged
2+
name: Release
3+
on:
4+
push:
5+
branches:
6+
- master
7+
jobs:
8+
merged-pr:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
pr: ${{ steps.get-pr-info.outputs.result }}
12+
steps:
13+
- name: Get merged PR
14+
id: get-pr-info
15+
uses: actions/github-script@v5
16+
with:
17+
script: |
18+
const res = await github.rest.pulls.list({
19+
owner: context.repo.owner,
20+
repo: context.repo.repo,
21+
sort: 'updated',
22+
direction: 'desc',
23+
state: 'closed',
24+
per_page: 100,
25+
});
26+
const pull = res.data.find(p => p.merge_commit_sha === context.sha);
27+
if (!pull) {
28+
console.log("No PR");
29+
return {};
30+
}
31+
32+
console.log(`Found #${pull.number} ${pull.title}`);
33+
return {
34+
title: pull.title,
35+
body: pull.body,
36+
number: pull.number,
37+
};
38+
39+
release:
40+
needs: merged-pr
41+
if: "${{ fromJSON(needs.merged-pr.outputs.pr).title == 'chore: update version' }}"
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v2
45+
- uses: actions/setup-node@v2
46+
with:
47+
node-version: "14"
48+
cache: "npm"
49+
- run: npm ci
50+
- run: npm publish --access public
51+
env:
52+
NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}}

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
node_modules/
22
.cache/
33
dist/
4-
!dist/marked-extensions.es.js
5-
!dist/marked-extensions.js
6-
!dist/marked-extensions.js.map

CONTRIBUTING.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Contributing to marked-extensions
2+
3+
## Dev Commands
4+
5+
Install and build:
6+
7+
```bash
8+
npm install
9+
```
10+
11+
Start a watcher:
12+
13+
```bash
14+
npm run watch
15+
```
16+
17+
## Changesets
18+
19+
[Changesets](https://github.com/atlassian/changesets) are used to automate version bumping and releasing the packages.
20+
21+
If you contribute anything that results in a version bump, you ned to write a changeset describing the changes.
22+
23+
To write a changeset, run `npx changeset` and follow the instructions shown. A new changeset will be added to `.changesets/`.
24+
25+
When changesets are pushed to `master`, a PR will be created automatically to keep track of the next version bump. Merging the PR bumps the versions, and release the affected packages.
26+
27+
See [Adding a changeset](https://github.com/atlassian/changesets/blob/main/docs/adding-a-changeset.md) for more.

babel.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: [['@babel/preset-env', {targets: {node: 'current'}}]],
3+
};

0 commit comments

Comments
 (0)