Merge pull request #135 from TriPSs/improvements

refactor: Use compiled index.js instead of node_modules
releases/v3
Tycho Bokdam 2021-10-05 22:57:54 +02:00 committed by GitHub
commit ae4858875f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 127 additions and 13 deletions

View File

@ -11,8 +11,9 @@ jobs:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v2 uses: actions/checkout@v2
- run: npm ci --prod - run: npm ci
- run: git add node_modules -f - run: npm run build
- run: git add ./lib -f
- name: Generate changelog - name: Generate changelog
id: changelog id: changelog

View File

@ -13,7 +13,11 @@ jobs:
with: with:
path: "./" path: "./"
- run: npm ci
- run: npm run build
- run: rm -rf node_modules
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log - run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
@ -47,7 +51,11 @@ jobs:
with: with:
path: "./" path: "./"
- run: npm ci
- run: npm run build
- run: rm -rf node_modules
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log - run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
@ -81,7 +89,11 @@ jobs:
with: with:
path: "./" path: "./"
- run: npm ci
- run: npm run build
- run: rm -rf node_modules
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log - run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
@ -115,7 +127,11 @@ jobs:
with: with:
path: "./" path: "./"
- run: npm ci
- run: npm run build
- run: rm -rf node_modules
- run: npm ci --prod - run: npm ci --prod
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
@ -143,7 +159,11 @@ jobs:
with: with:
path: "./" path: "./"
- run: npm ci
- run: npm run build
- run: rm -rf node_modules
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log - run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
@ -162,6 +182,40 @@ jobs:
github-token: ${{ secrets.github_token }} github-token: ${{ secrets.github_token }}
skip-commit: 'true' skip-commit: 'true'
test-git-no-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
path: "./"
- run: npm ci
- run: npm run build
- run: rm -rf node_modules
- run: npm ci --prod
- run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'"
- run: git tag | xargs git tag -d
- name: Create fake tag
run: "git tag -a 'v0.55.8' -m 'v0.55.8'"
- run: "git add . && git commit -m 'fix: Added fake file so version will be bumped'"
- name: Generate changelog
id: changelog
uses: ./
env:
ENV: 'dont-use-git'
EXPECTED_TAG: 'v0.55.9'
SKIPPED_COMMIT: true
EXPECTED_NO_PUSH: true
with:
github-token: ${{ secrets.github_token }}
skip-commit: 'true'
git-push: 'false'
test-yaml: test-yaml:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@ -170,7 +224,11 @@ jobs:
with: with:
path: "./" path: "./"
- run: npm ci
- run: npm run build
- run: rm -rf node_modules
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log - run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
@ -240,7 +298,11 @@ jobs:
with: with:
path: "./" path: "./"
- run: npm ci
- run: npm run build
- run: rm -rf node_modules
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log - run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
@ -278,7 +340,11 @@ jobs:
with: with:
path: "./" path: "./"
- run: npm ci
- run: npm run build
- run: rm -rf node_modules
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log - run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
@ -314,7 +380,11 @@ jobs:
with: with:
path: "./" path: "./"
- run: npm ci
- run: npm run build
- run: rm -rf node_modules
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log - run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
@ -350,7 +420,11 @@ jobs:
with: with:
path: "./" path: "./"
- run: npm ci
- run: npm run build
- run: rm -rf node_modules
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log - run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
@ -386,7 +460,11 @@ jobs:
with: with:
path: "./" path: "./"
- run: npm ci
- run: npm run build
- run: rm -rf node_modules
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log - run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
@ -425,7 +503,11 @@ jobs:
with: with:
path: "./" path: "./"
- run: npm ci
- run: npm run build
- run: rm -rf node_modules
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log - run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
@ -457,7 +539,11 @@ jobs:
with: with:
path: "./" path: "./"
- run: npm ci
- run: npm run build
- run: rm -rf node_modules
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log - run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
@ -491,7 +577,11 @@ jobs:
with: with:
path: "./" path: "./"
- run: npm ci
- run: npm run build
- run: rm -rf node_modules
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log - run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"
@ -532,7 +622,11 @@ jobs:
with: with:
path: "./" path: "./"
- run: npm ci
- run: npm run build
- run: rm -rf node_modules
- run: npm ci --prod - run: npm ci --prod
- run: touch ./fake-file.log - run: touch ./fake-file.log
- run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.email 'changelog@github.com'"
- run: "git config --global user.name 'Awesome Github action'" - run: "git config --global user.name 'Awesome Github action'"

3
.gitignore vendored
View File

@ -64,3 +64,6 @@ typings/
# next.js build output # next.js build output
.next .next
# build output
lib

View File

@ -9,6 +9,7 @@ This action will bump version, tag commit and generate a changelog with conventi
- **Optional** `git-user-name`: The git user.name to use for the commit. Default `Conventional Changelog Action` - **Optional** `git-user-name`: The git user.name to use for the commit. Default `Conventional Changelog Action`
- **Optional** `git-user-email`: The git user.email to use for the commit. Default `conventional.changelog.action@github.com` - **Optional** `git-user-email`: The git user.email to use for the commit. Default `conventional.changelog.action@github.com`
- **Optional** `git-pull-method`: The git pull method used when pulling all changes from remote. Default `--ff-only` - **Optional** `git-pull-method`: The git pull method used when pulling all changes from remote. Default `--ff-only`
- **Optional** `git-push`: Push all the GIT changes. Default `true`
- **Optional** `preset`: Preset that is used from conventional commits. Default `angular`. - **Optional** `preset`: Preset that is used from conventional commits. Default `angular`.
- **Optional** `tag-prefix`: Prefix for the git tags. Default `v`. - **Optional** `tag-prefix`: Prefix for the git tags. Default `v`.
- **Optional** `output-file`: File to output the changelog to. Default `CHANGELOG.md`, when providing `'false'` no file will be generated / updated. - **Optional** `output-file`: File to output the changelog to. Default `CHANGELOG.md`, when providing `'false'` no file will be generated / updated.

View File

@ -3,7 +3,7 @@ description: 'Bump version, tag commit and generates changelog with conventional
author: 'Tycho Bokdam' author: 'Tycho Bokdam'
runs: runs:
using: 'node12' using: 'node12'
main: 'src/index.js' main: 'lib/index.js'
branding: branding:
icon: 'edit' icon: 'edit'

12
package-lock.json generated
View File

@ -454,6 +454,12 @@
"integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==", "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==",
"dev": true "dev": true
}, },
"@vercel/ncc": {
"version": "0.31.1",
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.31.1.tgz",
"integrity": "sha512-g0FAxwdViI6UzsiVz5HssIHqjcPa1EHL6h+2dcJD893SoCJaGdqqgUF09xnMW6goWnnhbLvgiKlgJWrJa+7qYA==",
"dev": true
},
"JSONStream": { "JSONStream": {
"version": "1.3.5", "version": "1.3.5",
"resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz",
@ -1182,9 +1188,9 @@
} }
}, },
"chalk": { "chalk": {
"version": "4.1.0", "version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dev": true, "dev": true,
"requires": { "requires": {
"ansi-styles": "^4.1.0", "ansi-styles": "^4.1.0",

View File

@ -7,7 +7,8 @@
"changelog", "changelog",
"commits", "commits",
"conventional", "conventional",
"github" "github",
"conventional commits"
], ],
"homepage": "https://github.com/TriPSs/conventional-changelog-action#readme", "homepage": "https://github.com/TriPSs/conventional-changelog-action#readme",
"bugs": { "bugs": {
@ -22,7 +23,11 @@
"name": "Tycho Bokdam", "name": "Tycho Bokdam",
"email": "tycho@palmtreecoding.com" "email": "tycho@palmtreecoding.com"
}, },
"main": "src/index.js", "main": "lib/index.js",
"scripts": {
"build": "ncc build src/index.js --minify --out lib",
"watch": "ncc build src/index.js --watch"
},
"dependencies": { "dependencies": {
"@actions/core": "1.6.0", "@actions/core": "1.6.0",
"@actions/exec": "1.1.0", "@actions/exec": "1.1.0",
@ -37,6 +42,7 @@
"devDependencies": { "devDependencies": {
"@commitlint/cli": "13.2.0", "@commitlint/cli": "13.2.0",
"@commitlint/config-conventional": "13.2.0", "@commitlint/config-conventional": "13.2.0",
"@vercel/ncc": "^0.31.1",
"husky": "4.3.6" "husky": "4.3.6"
} }
} }

View File

@ -48,7 +48,7 @@ module.exports = new (class Git {
* @param command * @param command
* @return {Promise<>} * @return {Promise<>}
*/ */
exec = (command) => new Promise(async(resolve, reject) => { exec = (command) => new Promise(async (resolve, reject) => {
let execOutput = '' let execOutput = ''
const options = { const options = {
@ -102,7 +102,7 @@ module.exports = new (class Git {
* *
* @return {Promise<>} * @return {Promise<>}
*/ */
pull = async() => { pull = async () => {
const args = ['pull'] const args = ['pull']
// Check if the repo is unshallow // Check if the repo is unshallow
@ -130,7 +130,7 @@ module.exports = new (class Git {
* *
* @return {Promise<>} * @return {Promise<>}
*/ */
isShallow = async() => { isShallow = async () => {
if (ENV === 'dont-use-git') { if (ENV === 'dont-use-git') {
return false return false
} }
@ -161,7 +161,7 @@ module.exports = new (class Git {
*/ */
testHistory = () => { testHistory = () => {
if (ENV === 'dont-use-git') { if (ENV === 'dont-use-git') {
const { EXPECTED_TAG, SKIPPED_COMMIT } = process.env const { EXPECTED_TAG, SKIPPED_COMMIT, EXPECTED_NO_PUSH } = process.env
const expectedCommands = [ const expectedCommands = [
'git config user.name "Conventional Changelog Action"', 'git config user.name "Conventional Changelog Action"',
@ -175,7 +175,10 @@ module.exports = new (class Git {
} }
expectedCommands.push(`git tag -a ${EXPECTED_TAG} -m "${EXPECTED_TAG}"`) expectedCommands.push(`git tag -a ${EXPECTED_TAG} -m "${EXPECTED_TAG}"`)
expectedCommands.push(`git push origin ${branch} --follow-tags`)
if (!EXPECTED_NO_PUSH) {
expectedCommands.push(`git push origin ${branch} --follow-tags`)
}
assert.deepStrictEqual( assert.deepStrictEqual(
this.commandsRun, this.commandsRun,