Skip to content

Commit

Permalink
chore(ci): initialize semantic-release (#1212)
Browse files Browse the repository at this point in the history
  • Loading branch information
limonte committed Sep 5, 2018
1 parent 6589d5d commit 892e2e4
Show file tree
Hide file tree
Showing 6 changed files with 1,985 additions and 74 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ notifications:
on_success: never

after_success:
- yarn release
- cat ./coverage/lcov.info | coveralls
- zip -r coverage.zip coverage
- curl --upload-file ./coverage.zip https://transfer.sh/coverage.zip
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<a href="https://ci.appveyor.com/project/limonte/sweetalert2/branch/master"><img alt="Build Status: Windows" src="https://ci.appveyor.com/api/projects/status/paqdtx0snu53w5c1/branch/master?svg=true"></a>
<a href="https://coveralls.io/github/sweetalert2/sweetalert2?branch=master"><img src="https://coveralls.io/repos/github/sweetalert2/sweetalert2/badge.svg?branch=master&" alt="Coverage Status"></a>
<a href="https://www.npmjs.com/package/sweetalert2"><img alt="Version" src="https://img.shields.io/npm/v/sweetalert2.svg"></a>
<a href="https://github.com/vaadin/magi-demo-helpers/blob/master/CHANGELOG.md"><img alt="semantic-release badge" src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg"></a>
<a href="https://www.jsdelivr.com/package/npm/sweetalert2"><img alt="jsdelivr" src="https://data.jsdelivr.com/v1/package/npm/sweetalert2/badge?style=rounded"></a>
<a href="https://www.patreon.com/limonte"><img alt="Support me on Patreon" src="http://ionicabizau.github.io/badges/patreon.svg"></a>
<a href="https://www.paypal.me/limonte/5eur"><img alt="PayPal Donate" src="http://ionicabizau.github.io/badges/paypal.svg"></a>
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"@babel/core": "^7.0.0",
"@babel/plugin-transform-object-assign": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@semantic-release/changelog": "^3.0.0",
"@semantic-release/exec": "^3.1.2",
"babel-loader": "^8.0.0",
"babel-plugin-array-includes": "^2.0.3",
"browser-sync": "^2.23.3",
Expand Down Expand Up @@ -58,6 +60,7 @@
"rollup": "^0.65.0",
"rollup-plugin-babel": "^4.0.1",
"rollup-plugin-json": "^3.0.0",
"semantic-release": "^15.9.12",
"sinon": "^6.1.5",
"tslint": "^5.8.0",
"typescript": "^3.0.3",
Expand Down Expand Up @@ -106,7 +109,7 @@
"check:wappalyzer": "curl 'https://api.wappalyzer.com/lookup-basic/v1/?url=https%3A%2F%2Fsweetalert2.github.io' 2>&1 | grep --quiet 'SweetAlert2'",
"check:unpkg": "curl --location 'https://unpkg.com/sweetalert2' 2>&1 | grep --quiet 'window.Swal'",
"check:jsdelivr": "curl --location 'https://cdn.jsdelivr.net/npm/sweetalert2' 2>&1 | grep --quiet 'window.Swal'",
"release": "node release"
"release": "semantic-release"
},
"bugs": "https://github.com/sweetalert2/sweetalert2/issues",
"license": "MIT"
Expand Down
15 changes: 15 additions & 0 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
debug: true,
verifyConditions: [
'@semantic-release/changelog',
],
prepare: [
'@semantic-release/changelog',
],
publish: [
{
'path': '@semantic-release/exec',
'cmd': 'node release ${nextRelease.version}'
}
]
}
16 changes: 11 additions & 5 deletions release.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const pify = require('pify')
const rimraf = require('rimraf')
const fs = require('fs')
const assert = require('assert')
const isCi = require('is-ci')
const semver = require('semver')
const getGitStatus = require('./utils/get-git-status')
const execute = require('./utils/execute')

Expand All @@ -12,8 +14,8 @@ const writeFile = pify(fs.writeFile)

const dryRun = process.argv.includes('--dry-run')

const semver = process.argv[2]
assert.ok(['patch', 'minor', 'major'].includes(semver), 'Must specify the valid semver version: patch | minor | major')
const version = semver.clean(process.argv[2])
assert.ok(semver.valid(version), 'Must specify the valid semver version, e.g. 1.2.3')

;(async () => {
log('Doing sanity checks...')
Expand All @@ -26,9 +28,8 @@ assert.ok(['patch', 'minor', 'major'].includes(semver), 'Must specify the valid
log(`Pulling the latest ${branchToPublish} branch from Github...`)
await execute('git pull origin')

log(`Running npm version ${semver}...`)
await execute(`npm version --no-git-tag-version ${semver}`)
const { version } = require('./package.json')
log(`Running npm version ${version}...`)
await execute(`npm version --no-git-tag-version ${version}`)

log(`Making a version change commit...`)
await execute(`git add package.json && git commit -m "${version}"`)
Expand Down Expand Up @@ -79,6 +80,11 @@ assert.ok(['patch', 'minor', 'major'].includes(semver), 'Must specify the valid
log('Skipping pushing to Github...')
} else {
log('Pushing to Github both master and dist branches...')
if (isCi) {
await execute('git config --global user.email "travis@travis-ci.org"')
await execute('git config --global user.name "Travis CI"')
await execute(`git remote set-url origin https://${process.env.GH_TOKEN}@github.com/sweetalert2/sweetalert2.git`)
}
await execute('git push origin master:master dist:dist --tags')
}

Expand Down
Loading

0 comments on commit 892e2e4

Please sign in to comment.