Skip to content

Commit

Permalink
Merge branch 'master' into dist
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis CI User committed Sep 5, 2018
2 parents 6f93a98 + c3c882f commit 5281f6b
Show file tree
Hide file tree
Showing 8 changed files with 3,299 additions and 1,220 deletions.
4 changes: 2 additions & 2 deletions .babelrc
@@ -1,14 +1,14 @@
{
"presets": [
[
"env",
"@babel/preset-env",
{
"modules": false
}
]
],
"plugins": [
"array-includes",
"transform-object-assign"
"@babel/plugin-transform-object-assign"
]
}
10 changes: 10 additions & 0 deletions .travis.yml
Expand Up @@ -7,6 +7,13 @@ addons:
firefox: latest
chrome: stable

# This is needed for the release script, namely for git checkout dist
# https://stackoverflow.com/a/47441734
install:
- git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
- git fetch --unshallow --tags
- yarn

script:
# xvfb-run is needed for headless testing with real browsers
- if [[ "$TRAVIS_EVENT_TYPE" != "cron" ]]; then
Expand All @@ -23,6 +30,9 @@ notifications:
on_success: never

after_success:
- if [[ "$TRAVIS_BRANCH" = "master" ]]; then
yarn release;
fi;
- 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
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: 1 addition & 4 deletions gulpfile.js
Expand Up @@ -43,10 +43,7 @@ gulp.task('build:scripts', () => {
plugins: [
json(),
babel({
exclude: 'node_modules/**',
plugins: [
'external-helpers'
]
exclude: 'node_modules/**'
})
],
input: 'src/sweetalert2.js',
Expand Down
26 changes: 14 additions & 12 deletions package.json
Expand Up @@ -8,12 +8,12 @@
"jsnext:main": "src/sweetalert2.js",
"types": "sweetalert2.d.ts",
"devDependencies": {
"babel-core": "^6.23.1",
"babel-loader": "^7.1.2",
"@babel/core": "^7.0.0",
"@babel/plugin-transform-object-assign": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@semantic-release/exec": "^3.1.2",
"babel-loader": "^8.0.0",
"babel-plugin-array-includes": "^2.0.3",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-transform-object-assign": "^6.22.0",
"babel-preset-env": "^1.6.1",
"browser-sync": "^2.23.3",
"bundlesize": "^0.17.0",
"coveralls": "^3.0.2",
Expand Down Expand Up @@ -49,20 +49,21 @@
"karma-sauce-launcher": "^1.2.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "^0.0.32",
"karma-webpack": "^3.0.0",
"karma-webpack": "3.0.0",
"merge2": "^1.2.1",
"mkdirp": "^0.5.1",
"pify": "^4.0.0",
"promise-polyfill": "^8.1.0",
"qunit": "^2.5.1",
"rimraf": "^2.6.2",
"rollup": "^0.58.0",
"rollup-plugin-babel": "^3.0.2",
"rollup-plugin-json": "^2.3.0",
"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": "^2.1.0",
"webpack": "^3.0.0"
"typescript": "^3.0.3",
"webpack": "^4.17.2"
},
"files": [
"dist",
Expand Down Expand Up @@ -107,7 +108,8 @@
"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"
"switch-to-dist": "git fetch && git checkout . && git checkout -B dist origin/dist && git merge --strategy-option=theirs master",
"release": "yarn switch-to-dist && semantic-release"
},
"bugs": "https://github.com/sweetalert2/sweetalert2/issues",
"license": "MIT"
Expand Down
17 changes: 17 additions & 0 deletions release.config.js
@@ -0,0 +1,17 @@
module.exports = {
debug: true,
verifyConditions: [
],
prepare: [
],
publish: [
{
'path': '@semantic-release/exec',
'cmd': 'node release ${nextRelease.version}'
}
],
success: [
],
fail: [
]
}
45 changes: 28 additions & 17 deletions release.js
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,23 +14,31 @@ 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...')
const { currentBranch: branchToPublish, isCleanWorkingTree } = await getGitStatus()
let { currentBranch: branchToPublish, isCleanWorkingTree } = await getGitStatus()
if (!dryRun) {
assert.equal(branchToPublish, 'master', 'Must be on master branch')
if (isCi) {
branchToPublish = process.env.TRAVIS_BRANCH
log(`CI, switching to ${branchToPublish}...`)
await execute(`git checkout ${branchToPublish}`)

log(`CI, cleaning working tree on ${branchToPublish}...`)
await execute('git checkout .')
} else {
assert.equal(branchToPublish, 'master', 'Must be on master branch')
}
}
assert.equal(isCleanWorkingTree, true, 'Must have clean working tree')

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 All @@ -37,22 +47,18 @@ assert.ok(['patch', 'minor', 'major'].includes(semver), 'Must specify the valid
await removeDir('dist')

log('Switching to the dist branch...')
await execute('git checkout dist')

log('Pulling the latest dist branch from Github...')
await execute('git pull origin')

log(`Merging from "${branchToPublish}" branch...`)
await execute(`git merge --strategy-option=theirs ${branchToPublish}`)
await execute('yarn switch-to-dist')

log('Installing npm dependencies...')
await execute('yarn')

log('Running the build...')
await execute('npm run build')

log('Running the checks...')
await execute('npm run check')
if (!isCi) {
log('Running the checks...')
await execute('npm run check')
}

if (dryRun) {
log('Skipping publishing on npm...')
Expand All @@ -79,13 +85,18 @@ 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 "semantic-release-bot@martynus.net"')
await execute('git config --global user.name "semantic-release-bot"')
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')
}

log(`Purge jsdelivr cache...`)
const distFiles = fs.readdirSync('dist')
for (const distFile of distFiles) {
await execute(`curl --silent https://purge.jsdelivr.net/npm/sweetalert2@latest/dist/${distFile} > /dev/null`, { skipLogging: true })
await execute(`curl --silent https://purge.jsdelivr.net/npm/sweetalert2@latest/dist/${distFile}`, { skipLogging: true })
}

log(`Switching back to "${branchToPublish}" (so you can continue to work)...`)
Expand Down

0 comments on commit 5281f6b

Please sign in to comment.