-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add publish with changeset in workflow
- Loading branch information
Showing
7 changed files
with
634 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Changesets | ||
|
||
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works with mono-repos or single package repos to help you verion and release your code. You can find the full documentation for it [in our repository](https://github.com/changesets/changesets) | ||
|
||
We have a quick list of common questions to get you started engaging with this project in [our documentation](https://github.com/changesets/changesets/blob/master/docs/common-questions.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
require('dotenv').config(); | ||
const { getInfo } = require('@changesets/get-github-info'); | ||
|
||
const changesetOptions = { | ||
// If true, we will automatically commit the changeset when the command is run | ||
commit: false, | ||
}; | ||
|
||
// This function takes information about a changeset to generate an entry for it in your | ||
// changelog. We provide the full changeset object as well as the version. | ||
// It may be a good idea to replace the commit hash with a link to the commit. | ||
|
||
/* the default shape is: | ||
### Bump Type | ||
- GIT_HASH: A summary message you wrote, indented? | ||
*/ | ||
|
||
const getReleaseLine = async (changeset, type) => { | ||
const [firstLine, ...futureLines] = changeset.summary | ||
.split('\n') | ||
.map(l => l.trimRight()); | ||
// getInfo exposes the GH username and PR number if you want them directly | ||
// but it also exposes a set of links for the commit, PR and GH username | ||
let { user, pull, links } = await getInfo({ | ||
repo: process.env.GITHUB_REPOSITORY, | ||
commit: changeset.commit, | ||
}); | ||
return `- ${links.commit}${links.pull === null ? '' : ` ${links.pull}`}${ | ||
links.user === null ? '' : ` Thanks ${links.user}!` | ||
}: ${firstLine}\n${futureLines.map(l => ` ${l}`).join('\n')}`; | ||
}; | ||
|
||
// This function takes information about what dependencies we are updating in the package. | ||
// It provides an array of related changesets, as well as the dependencies updated. | ||
|
||
/* | ||
- Updated dependencies: [ABCDEFG]: | ||
- Updated dependencies: [HIJKLMN]: | ||
- [email protected] | ||
- [email protected] | ||
*/ | ||
const getDependencyReleaseLine = async (changesets, dependenciesUpdated) => { | ||
if (dependenciesUpdated.length === 0) return ''; | ||
|
||
const changesetLinks = changesets.map( | ||
changeset => `- Updated dependencies [${changeset.commit}]:` | ||
); | ||
|
||
const updatedDepenenciesList = dependenciesUpdated.map( | ||
dependency => ` - ${dependency.name}@${dependency.version}` | ||
); | ||
|
||
return [...changesetLinks, ...updatedDepenenciesList].join('\n'); | ||
}; | ||
|
||
const versionOptions = { | ||
// If true, we will automatically commit the version updating when the command is run | ||
commit: false, | ||
// Adds a skipCI flag to the commit - only valid if `commit` is also true. | ||
skipCI: false, | ||
// Do not modify the `changelog.md` files for packages that are updated | ||
updateChangelog: true, | ||
// A function that returns a string. It takes in options about a change. This allows you to customise your changelog entries | ||
getReleaseLine, | ||
// A function that returns a string. It takes in options about when a pacakge is updated because | ||
getDependencyReleaseLine, | ||
// An array of arrays that defines packages that are linked. | ||
// Linked packages are packages that should be at the same version when they're released. | ||
// If you've used Lerna to version packages before, this is very similar. | ||
linked: [[]], | ||
}; | ||
|
||
const publishOptions = { | ||
// This sets whether unpublished packages are public by default. We err on the side of caution here. | ||
public: true, | ||
}; | ||
|
||
module.exports = { | ||
versionOptions, | ||
changesetOptions, | ||
publishOptions, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: CI | ||
|
||
on: [push] | ||
on: push | ||
|
||
jobs: | ||
test: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- '.changeset/*/*' | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
|
||
- name: Use Node.js 10.x | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 10.x | ||
|
||
- name: Install Yarn | ||
run: curl -o- -L https://yarnpkg.com/install.sh | bash | ||
|
||
- name: Install Dependencies | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: Build | ||
run: yarn build | ||
|
||
- name: Publish to npm | ||
uses: changesets/action@master | ||
with: | ||
# The --otp=1 is to get around a bug in changesets | ||
# It will be fixed in Changesets 2 | ||
publish: yarn release --otp=1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
/coverage/ | ||
*.log | ||
.vscode | ||
.env | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.