-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
NghiaPham
authored
Dec 11, 2019
1 parent
4f66e2a
commit 202e677
Showing
11 changed files
with
229 additions
and
142 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
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
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
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 |
---|---|---|
|
@@ -21,10 +21,11 @@ A collection of React components and utilities for building apps for Reapit Mark | |
- Styles export from `index.scss` at the root of the styles project, ensure any new files are `@import`ed here. | ||
|
||
### Building and Publishing | ||
- NOTED: THIS PROCESS WON'T BUMP THE PACKAGE VERSION AUTOMATICALLY FOR YOU | ||
|
||
- When a PR is created, checks will run to make sure testcases have been passed, code have passes linter standard. If one of checks fail, the PR won't able to be merged, and require the sumbmitter to update his/her code again. | ||
- Create a PR to merge develop. When the PR merged, npm package will be published to npm as beta tag, and release will be created automatically. | ||
- To release a stable/latest version of npm package, create a PR to merge master. When the PR merged, npm package will be published to npm, release will be created automatically, storybook assets will be deployed to GH-pages | ||
- Create a PR to merge develop. When the PR merged to develop, there will be a tag published that have a version based on version field on package.json file. If there were a tag that has the same tag name created, the old tag would be overridden by the new tag. Install them on other by edit package.json as `@reapit/elements:git+ssh:[email protected]:reapit/elements.git#{tag}`. eg `@reapit/elements: "git+ssh:[email protected]:reapit/elements.git#v0.5.4-beta"`, or commandline: `yarn add @reapit/elements@git+ssh:[email protected]:reapit/elements.git#v0.5.4-beta` | ||
- To release a stable version of npm package, create a PR to merge master. When the PR was merged, npm package will be published to npm , a new release will be created automatically, and storybook assets will be deployed to GH-pages. | ||
|
||
### To use the project | ||
|
||
|
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
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,10 @@ | ||
const {npm_package_version: currentPackageVersion, npm_package_name: npmPackageName} = process.env | ||
const { execSync } = require('child_process'); | ||
const remotePackageVersion = execSync(`yarn info ${npmPackageName} version`).toString().trim() | ||
const compareVersions = require('compare-versions'); | ||
|
||
// currentPackageVersion < remotePackageVersion | ||
if (compareVersions(currentPackageVersion, remotePackageVersion) < 1) { | ||
console.log('Current version is smaller than remote version. Please bump your package version') | ||
process.exit(1) | ||
} |
This file was deleted.
Oops, something went wrong.
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,5 +1,30 @@ | ||
const release = require('./release') | ||
release('dev').catch(err => { | ||
console.error(err.message) | ||
process.exit(1) | ||
}) | ||
const {npm_package_version, GITHUB_TOKEN, GITHUB_ACTOR, GITHUB_REPOSITORY} = process.env | ||
const remoteRepo = `https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git` | ||
const tagName=`v${npm_package_version}-beta` | ||
const { execSync } = require('child_process'); | ||
|
||
// delete tag remotely and locally | ||
execSync(`git remote add origin ${remoteRepo}`) | ||
execSync(`git config --global user.email "${GITHUB_ACTOR}@email.com"`) | ||
execSync(`git config --global user.name "${GITHUB_ACTOR}"`) | ||
|
||
try { | ||
execSync(`git commit -am 'Publish ${tagName} -- with dist files'`) | ||
} catch (err) { | ||
console.log(err); | ||
} | ||
|
||
try { | ||
execSync(`git tag -d ${tagName}`) | ||
execSync(`git push --delete origin ${tagName}`) | ||
} catch (_) { | ||
// Delete existed tag will resulted in Error | ||
// Ignored | ||
} | ||
|
||
// Tag current commit | ||
execSync(`git tag ${tagName}`) | ||
|
||
// Push the tag | ||
execSync(`git push origin ${tagName}`) | ||
|
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,5 +1,27 @@ | ||
const release = require('./release') | ||
release('prod').catch(err => { | ||
console.error(err.message) | ||
process.exit(1) | ||
}) | ||
const Octokit = require('@octokit/rest') | ||
module.exports = async env => { | ||
const currentVersion = process.env.npm_package_version | ||
let tagName = 'v' + currentVersion | ||
|
||
const token = process.env.GITHUB_TOKEN | ||
|
||
const octokit = new Octokit({ | ||
auth: token | ||
}) | ||
|
||
await octokit.git | ||
.createRef({ | ||
owner: 'reapit', | ||
repo: 'elements', | ||
ref: 'refs/tags/' + tagName, | ||
sha: process.env.GITHUB_SHA | ||
}) | ||
|
||
// create new release based on tag | ||
await octokit.repos | ||
.createRelease({ | ||
owner: 'reapit', | ||
repo: 'elements', | ||
tag_name: tagName | ||
}) | ||
} |
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.