Skip to content

Commit

Permalink
chore: implemented git-conventional-commits
Browse files Browse the repository at this point in the history
this helps enable generating our versions and changelog from our git tree

helps close in-toto#9
  • Loading branch information
kriscoleman committed Jun 13, 2023
1 parent 120aa80 commit 091622f
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 4 deletions.
51 changes: 51 additions & 0 deletions git-conventional-commits.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
convention:
commitTypes:
- feat
- fix
- perf
- refactor
- style
- story
- test
- build
- ops
- docs
- chore
- merge
- spike
- revert
commitScopes: []
releaseTagGlobPattern: v[0-9]*.[0-9]*.[0-9]*
changelog:
commitTypes:
- chore
- docs
- feat
- fix
- perf
- story
- merge
includeInvalidCommits: true
commitIgnoreRegexPattern: "^WIP "
headlines:
feat: Features
fix: Bug Fixes
perf: Performance Improvements
merge: Merges
chore: Chores
docs: Documentation
story: Stories
breakingChange: BREAKING CHANGES

## GitHub
# commitUrl: https://github.com/ACCOUNT/REPOSITORY/commit/%commit%
# commitRangeUrl: https://github.com/ACCOUNT/REPOSITORY/compare/%from%...%to%?diff=split

## GitHub Issues
# issueRegexPattern: "#[0-9]+"
# issueUrl: https://github.com/ACCOUNT/REPOSITORY/issues/%issue%

## Jira Issues
# issueRegexPattern: "[A-Z][A-Z0-9]+-[0-9]+"
# issueUrl: https://WORKSPACE.atlassian.net/browse/%issue%
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"name": "judge",
"version": "0.0.0",
"version": "0.2.0",
"description": "Judge is a SaaS (Software as a Service) which aims to provide our open source software in a ready-to-use state, so that anyone with an interest in using it for supply-chain security can spin up our solutions quickly, easily, and effectively.",
"main": "index.js",
"scripts": {
"version": "./scripts/update-platform-version.sh",
"version:perms": "chmod +x ./scripts/update-platform-version.sh",
"changelog": "npx git-conventional-commits changelog",
"pre-commit": "npm run pre-commit -w web",
"pre-push": "npm run pre-push -w web",
"prepare": "husky install",
Expand Down Expand Up @@ -35,6 +38,7 @@
"devDependencies": {
"@commitlint/cli": "^17.6.5",
"@commitlint/config-conventional": "^17.6.5",
"git-conventional-commits": "^2.6.5",
"husky": "8.0.3",
"jest-fetch-mock": "^3.0.3",
"prepush-if-changed": "^1.0.8"
Expand All @@ -44,4 +48,4 @@
],
"author": "TestifySec",
"license": "UNLICENSED"
}
}
31 changes: 31 additions & 0 deletions scripts/update-platform-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# update-platform-version
# This script helps us keep our platform version up to date

version_output=$(npx git-conventional-commits version)
latest_version=$(echo "$version_output" | tail -n 1)
current_version=$(node -pe "require('./package.json').version")

# Update the package.json file with the new version
if [[ $latest_version != $current_version ]]; then
node -e "
const fs = require('fs');
const packageJson = JSON.parse(fs.readFileSync('package.json'));
const packageLockJson = JSON.parse(fs.readFileSync('package-lock.json'));
packageJson.version = '${latest_version}';
packageLockJson.version = '${latest_version}';
fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 2));
fs.writeFileSync('package-lock.json', JSON.stringify(packageLockJson, null, 2));
"

# Stage the updated package.json file
git add package.json
git add package-lock.json

echo "Updated package.json version to ${latest_version} and staged the file."
else
echo "No version update found in git-conventional-commits."
fi

0 comments on commit 091622f

Please sign in to comment.