GitHub Action to automatically generate version numbers based on conventional commits
Design Descisions
- Easily generate automatic version numbers based on conventional commits spec.
- Should work with any language or repository structure
- Should be used a building block and not try to manage the whole versioning process. (although may handle optional tagging in the future with the
mode
input)
- uses: jveldboom/action-conventional-versioning@v1
with:
# GitHub token with read access to repo
# Default: github.token
github-token: ''
# Default version bump (major, minor or patch)
# Used when unable to calculate the bump from the commit messages
# For example when not using conventional commits
# Default: patch
default-bump: ''
# Ignore prereleases when calculating the next version (true or false)
# Default: false
ignore-drafts: ''
# Ignore draft releases when calculating the next version (true or false)
# Default: false
ignore-prereleases: ''
# Set the versioning mode to run (future use-case)
# Default: default
mode: ''
Name | Description |
---|---|
version |
full semantic version number (1.2.3 ) |
version-with-prefix |
version number with v prefix (v1.2.3 ) |
major |
major version number |
major-with-prefix |
major version number with v prefix (v1 ) |
minor |
minor version number |
patch |
patch version number |
bump |
version bump type (major, minor, or patch) |
This example will create a new GitHub release on any push to the main
branch as well as update the floating major version (eg v1
)
---
name: release
on:
push:
branches:
- main
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: jveldboom/action-conventional-versioning@v1
id: version
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "${{ steps.version.outputs.version-with-prefix }}" \
--generate-notes \
--target "${{ github.sha }}"
- name: Update Major Tag
env:
MAJOR: ${{ steps.version.outputs.major }}
run: |
git tag -d ${MAJOR} || true
git push origin :refs/tags/${MAJOR}
git tag ${MAJOR} ${GITHUB_SHA}
git push origin ${MAJOR}
I'll take all the help I can get so please feel free to contribute in anyway! Spelling & grammar errors, improve testing. Please check out the TODO list below for known items I'd like to resolve.
# install dependencies
yarn install
# unit tests
yarn test:watch
# lint code via standardjs
yarn lint
# build distribution bundle
yarn build
- Release v1 of action
- Workflow to run regresssion tests with compiled action
- List action in marketplace
- Improve index.js file
- Should it be simplified and wrapped in a try/catch?
- How can we get 100% test coverage on it?
- Output version bump (major, minor, patch) No specific use case but I believe it will be useful
- Add version suffix that are semver
- Improve integration testing to cover all use-case. May require the ability to pass in a list of commits
- Better error messaging for all GH API calls.
- This call is currently only caught by outside try/catch
- Commit Analyzer https://github.com/semantic-release/commit-analyzer#releaserules
- Other Alternatives
This action is licensed under the MIT License. See the LICENSE file for more information.