do not push to npm
This commit is contained in:
parent
fbfd53a737
commit
a0ace87e9b
10
Dockerfile
10
Dockerfile
|
@ -1,12 +1,12 @@
|
|||
FROM node:10-slim
|
||||
|
||||
LABEL version="1.0.0"
|
||||
LABEL repository="http://github.com/mikeal/merge-release"
|
||||
LABEL homepage="http://github.com/merge-release"
|
||||
LABEL maintainer="Mikeal Rogers <mikeal.rogers@gmail.com>"
|
||||
LABEL repository="http://github.com/phips28/gh-action-bump-version"
|
||||
LABEL homepage="http://github.com/gh-action-bump-version"
|
||||
LABEL maintainer="Philipp Holly <phips28@gmx.at>"
|
||||
|
||||
LABEL com.github.actions.name="Automated releases for npm packages."
|
||||
LABEL com.github.actions.description="Release npm package based on commit metadata."
|
||||
LABEL com.github.actions.name="Automated version bump for npm packages."
|
||||
LABEL com.github.actions.description="Automated version bump for npm packages."
|
||||
LABEL com.github.actions.icon="package"
|
||||
LABEL com.github.actions.color="red"
|
||||
COPY LICENSE README.md /
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
## merge-release
|
||||
## gh-action-bump-version
|
||||
|
||||
GitHub Action for automated npm publishing.
|
||||
GitHub Action for automated npm version bump.
|
||||
|
||||
This Action publishes a package to npm. It is meant to be used on every successful merge to master but
|
||||
you'll need to configured that workflow yourself. You can look to the
|
||||
|
|
|
@ -21,15 +21,15 @@ fi
|
|||
|
||||
remote_repo="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
|
||||
|
||||
git config user.name "Merge Release"
|
||||
git config user.email "merge-release@users.noreply.github.com"
|
||||
git remote add merge-release "${remote_repo}"
|
||||
git config user.name "Bump Version"
|
||||
git config user.email "gh-action-bump-version@users.noreply.github.com"
|
||||
git remote add gh-action-bump-version "${remote_repo}"
|
||||
|
||||
if [ "$GITHUB_REPOSITORY" = "mikeal/merge-release" ]
|
||||
if [ "$GITHUB_REPOSITORY" = "phips28/gh-action-bump-version" ]
|
||||
then
|
||||
echo "node merge-release-run.js"
|
||||
sh -c "node merge-release-run.js $*"
|
||||
echo "node gh-action-bump-version-run.js"
|
||||
sh -c "node gh-action-bump-version-run.js $*"
|
||||
else
|
||||
echo "npx merge-release"
|
||||
sh -c "npx merge-release $*"
|
||||
echo "npx gh-action-bump-version"
|
||||
sh -c "npx gh-action-bump-version $*"
|
||||
fi
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env node
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const { execSync } = require('child_process')
|
||||
|
||||
const event = JSON.parse(fs.readFileSync('/github/workflow/event.json').toString())
|
||||
|
||||
let pkg = require(path.join(process.cwd(), 'package.json'))
|
||||
|
||||
const run = async () => {
|
||||
if (!process.env.NPM_AUTH_TOKEN) throw new Error('gh-action-bump-version requires NPM_AUTH_TOKEN')
|
||||
|
||||
let messages = event.commits.map(commit => commit.message + '\n' + commit.body)
|
||||
|
||||
let version = 'patch'
|
||||
if (messages.map(message => message.includes('BREAKING CHANGE')).includes(true)) {
|
||||
version = 'major'
|
||||
} else if (messages.map(message => message.toLowerCase().startsWith('feat')).includes(true)) {
|
||||
version = 'minor'
|
||||
}
|
||||
|
||||
const exec = str => process.stdout.write(execSync(str))
|
||||
|
||||
let current = execSync(`npm view ${pkg.name} version`).toString()
|
||||
exec(`npm version --allow-same-version=true --git-tag-version=false ${current} `)
|
||||
console.log('current:', current, '/', 'version:', version)
|
||||
let newVersion = execSync(`npm version --git-tag-version=false ${version}`).toString()
|
||||
console.log('new version:', newVersion)
|
||||
exec(`git checkout package.json`) // cleanup
|
||||
exec(`git tag ${newVersion}`)
|
||||
exec(`git push gh-action-bump-version --tags`)
|
||||
}
|
||||
run()
|
|
@ -1,65 +0,0 @@
|
|||
#!/usr/bin/env node
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const bent = require('bent')
|
||||
const git = require('simple-git')()
|
||||
const { execSync } = require('child_process')
|
||||
const { promisify } = require('util')
|
||||
|
||||
const getlog = promisify(git.log.bind(git))
|
||||
|
||||
const get = bent('json', 'https://registry.npmjs.org/')
|
||||
|
||||
const event = JSON.parse(fs.readFileSync('/github/workflow/event.json').toString())
|
||||
|
||||
let pkg = require(path.join(process.cwd(), 'package.json'))
|
||||
|
||||
const run = async () => {
|
||||
if (!process.env.NPM_AUTH_TOKEN) throw new Error('Merge-release requires NPM_AUTH_TOKEN')
|
||||
let latest
|
||||
try {
|
||||
latest = await get(pkg.name + '/latest')
|
||||
} catch (e) {
|
||||
// unpublished
|
||||
}
|
||||
|
||||
let messages
|
||||
|
||||
if (latest) {
|
||||
if (latest.gitHead === process.env.GITHUB_SHA) return console.log('SHA matches latest release, skipping.')
|
||||
if (latest.gitHead) {
|
||||
try {
|
||||
let logs = await getlog({ from: latest.gitHead, to: process.env.GITHUB_SHA })
|
||||
messages = logs.all.map(r => r.message + '\n' + r.body)
|
||||
} catch (e) {
|
||||
latest = null
|
||||
}
|
||||
// g.log({from: 'f0002b6c9710f818b9385aafeb1bde994fe3b370', to: '53a92ca2d1ea3c55977f44d93e48e31e37d0bc69'}, (err, l) => console.log(l.all.map(r => r.message + '\n' + r.body)))
|
||||
} else {
|
||||
latest = null
|
||||
}
|
||||
}
|
||||
if (!latest) {
|
||||
messages = event.commits.map(commit => commit.message + '\n' + commit.body)
|
||||
}
|
||||
|
||||
let version = 'patch'
|
||||
if (messages.map(message => message.includes('BREAKING CHANGE')).includes(true)) {
|
||||
version = 'major'
|
||||
} else if (messages.map(message => message.toLowerCase().startsWith('feat')).includes(true)) {
|
||||
version = 'minor'
|
||||
}
|
||||
|
||||
const exec = str => process.stdout.write(execSync(str))
|
||||
|
||||
let current = execSync(`npm view ${pkg.name} version`).toString()
|
||||
exec(`npm version --allow-same-version=true --git-tag-version=false ${current} `)
|
||||
console.log('current:', current, '/', 'version:', version)
|
||||
let newVersion = execSync(`npm version --git-tag-version=false ${version}`).toString()
|
||||
console.log('new version:', newVersion)
|
||||
exec(`npm publish --access=public`)
|
||||
exec(`git checkout package.json`) // cleanup
|
||||
exec(`git tag ${newVersion}`)
|
||||
exec(`git push merge-release --tags`)
|
||||
}
|
||||
run()
|
14
package.json
14
package.json
|
@ -1,27 +1,25 @@
|
|||
{
|
||||
"name": "merge-release",
|
||||
"version": "0.0.0-dev",
|
||||
"name": "gh-action-bump-version",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"scripts": {
|
||||
"test": "standard"
|
||||
},
|
||||
"bin": {
|
||||
"merge-release": "./merge-release-run.js"
|
||||
"gh-action-bump-version": "./gh-action-bump-version-run.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/mikeal/auto-release.git"
|
||||
"url": "git+https://github.com/phips28/gh-action-bump-version.git"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/mikeal/auto-release/issues"
|
||||
"url": "https://github.com/phips28/gh-action-bump-version/issues"
|
||||
},
|
||||
"homepage": "https://github.com/mikeal/auto-release#readme",
|
||||
"homepage": "https://github.com/phips28/gh-action-bump-version#readme",
|
||||
"dependencies": {
|
||||
"bent": "1.5.13",
|
||||
"simple-git": "^1.113.0",
|
||||
"yargs": "^12.0.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
Loading…
Reference in New Issue