Merge pull request #144 from apr-1985/skip_git_pull
feat:Allow skipping of the Git pull before taggingreleases/v3
commit
f05181d095
|
@ -139,6 +139,37 @@ jobs:
|
|||
github-token: ${{ secrets.github_token }}
|
||||
skip-commit: 'true'
|
||||
|
||||
test-git-no-pull:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
path: "./"
|
||||
|
||||
- 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
|
||||
SKIPPED_PULL: true
|
||||
with:
|
||||
github-token: ${{ secrets.github_token }}
|
||||
skip-commit: 'true'
|
||||
skip-git-pull: 'true'
|
||||
|
||||
test-git-fallback:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
|
17
README.md
17
README.md
|
@ -16,6 +16,7 @@ This action will bump version, tag commit and generate a changelog with conventi
|
|||
- **Optional** `release-count`: Number of releases to preserve in changelog. Default `5`, use `0` to regenerate all.
|
||||
- **Optional** `version-file`: The path to the file that contains the version to bump. Default `./package.json`.
|
||||
- **Optional** `version-path`: The place inside the version file to bump. Default `version`.
|
||||
- **Optional** `skip-git-pull`: Do not pull the repo before tagging. Ensure you full cloned the repo in the first place to get tags. Default `'false'`.
|
||||
- **Optional** `skip-on-empty`: Boolean to specify if you want to skip empty release (no-changelog generated). This case occured when you push `chore` commit with `angular` for example. Default `'true'`.
|
||||
- **Optional** `skip-version-file`: Do not update the version file. Default `'false'`.
|
||||
- **Optional** `skip-commit`: Do not create a release commit. Default `'false'`.
|
||||
|
@ -148,6 +149,22 @@ Tag only
|
|||
skip-commit: "true"
|
||||
```
|
||||
|
||||
Skip Git Pull
|
||||
In CI you might not want to pull extra changes before tagging e.g. if running a long build before tagging, another commit may have come into the branch which would get pulled leading to tagging a different commit to the one which was built.
|
||||
|
||||
```yaml
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Conventional Changelog Action
|
||||
uses: TriPSs/conventional-changelog-action@v3
|
||||
with:
|
||||
github-token: ${{ secrets.github_token }}
|
||||
skip-git-pull: "true"
|
||||
```
|
||||
|
||||
Use a custom file for versioning
|
||||
|
||||
```yaml
|
||||
|
|
|
@ -70,6 +70,11 @@ inputs:
|
|||
default: 'version'
|
||||
required: false
|
||||
|
||||
skip-git-pull:
|
||||
description: 'Do not pull the repo before tagging. Ensure you full cloned the repo in the first place to get tags'
|
||||
default: 'false'
|
||||
required: false
|
||||
|
||||
skip-on-empty:
|
||||
description: 'Do nothing when the changelog from the latest release is empty'
|
||||
default: 'true'
|
||||
|
|
|
@ -161,14 +161,17 @@ module.exports = new (class Git {
|
|||
*/
|
||||
testHistory = () => {
|
||||
if (ENV === 'dont-use-git') {
|
||||
const { EXPECTED_TAG, SKIPPED_COMMIT, EXPECTED_NO_PUSH } = process.env
|
||||
const { EXPECTED_TAG, SKIPPED_COMMIT, EXPECTED_NO_PUSH, SKIPPED_PULL } = process.env
|
||||
|
||||
const expectedCommands = [
|
||||
'git config user.name "Conventional Changelog Action"',
|
||||
'git config user.email "conventional.changelog.action@github.com"',
|
||||
'git pull --tags --ff-only',
|
||||
]
|
||||
|
||||
if (!SKIPPED_PULL) {
|
||||
expectedCommands.push('git pull --tags --ff-only')
|
||||
}
|
||||
|
||||
if (!SKIPPED_COMMIT) {
|
||||
expectedCommands.push('git add .')
|
||||
expectedCommands.push(`git commit -m "chore(release): ${EXPECTED_TAG}"`)
|
||||
|
|
|
@ -36,6 +36,7 @@ async function run() {
|
|||
const releaseCount = core.getInput('release-count')
|
||||
const versionFile = core.getInput('version-file')
|
||||
const versionPath = core.getInput('version-path')
|
||||
const skipGitPull = core.getInput('skip-git-pull').toLowerCase() === 'true'
|
||||
const skipVersionFile = core.getInput('skip-version-file').toLowerCase() === 'true'
|
||||
const skipCommit = core.getInput('skip-commit').toLowerCase() === 'true'
|
||||
const skipEmptyRelease = core.getInput('skip-on-empty').toLowerCase() === 'true'
|
||||
|
@ -64,8 +65,10 @@ async function run() {
|
|||
core.info(`Skipping empty releases is "${skipEmptyRelease ? 'enabled' : 'disabled'}"`)
|
||||
core.info(`Skipping the update of the version file is "${skipVersionFile ? 'enabled' : 'disabled'}"`)
|
||||
|
||||
core.info('Pull to make sure we have the full git history')
|
||||
await git.pull()
|
||||
if (!skipGitPull) {
|
||||
core.info('Pull to make sure we have the full git history')
|
||||
await git.pull()
|
||||
}
|
||||
|
||||
const config = conventionalConfigFile && requireScript(conventionalConfigFile)
|
||||
|
||||
|
|
Loading…
Reference in New Issue