fix: Tag name can also be changed in pre-changelog-generation
parent
8f6aa1969f
commit
c0f41727e6
|
@ -95,7 +95,7 @@ jobs:
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
path: "./"
|
path: "./"
|
||||||
- run: test -f test-version && (echo should not be here yet && exit 1) || exit 0
|
- run: test -f pre-changelog-generation.test.json && (echo should not be here yet && exit 1) || exit 0
|
||||||
- name: Generate changelog
|
- name: Generate changelog
|
||||||
id: changelog
|
id: changelog
|
||||||
uses: ./
|
uses: ./
|
||||||
|
@ -107,8 +107,8 @@ jobs:
|
||||||
version-file: './test-file.toml'
|
version-file: './test-file.toml'
|
||||||
skip-on-empty: 'false'
|
skip-on-empty: 'false'
|
||||||
|
|
||||||
- run: test -f test-version || (echo should be here && exit 1)
|
- run: test -f pre-changelog-generation.test.json || (echo should be here && exit 1)
|
||||||
- run: cat test-version
|
- run: cat pre-changelog-generation.test.json
|
||||||
test-git:
|
test-git:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
|
@ -59,7 +59,7 @@ A bunch of useful environment variables are available to the script with `proces
|
||||||
|
|
||||||
Same restrictions as for the pre-commit hook, but exported function name should be `preChangelogGeneration`
|
Same restrictions as for the pre-commit hook, but exported function name should be `preChangelogGeneration`
|
||||||
|
|
||||||
Following props will be passed to the function as a single parameter and string output with version is expected:
|
Following props will be passed to the function as a single parameter and same output is expected:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
interface Props {
|
interface Props {
|
||||||
|
@ -67,7 +67,7 @@ interface Props {
|
||||||
version: string; // Next version e.g. 1.12.3
|
version: string; // Next version e.g. 1.12.3
|
||||||
}
|
}
|
||||||
|
|
||||||
export function preChangelogGeneration(props: Props): string {}
|
export function preChangelogGeneration(props: Props): Props {}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Config-File-Path
|
### Config-File-Path
|
||||||
|
|
|
@ -110,13 +110,16 @@ async function run() {
|
||||||
newVersion = versioning[0].newVersion
|
newVersion = versioning[0].newVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
const gitTag = `${tagPrefix}${newVersion}`
|
let gitTag = `${tagPrefix}${newVersion}`
|
||||||
|
|
||||||
if (preChangelogGeneration) {
|
if (preChangelogGeneration) {
|
||||||
newVersion = await require(path.resolve(preChangelogGeneration)).preChangelogGeneration({
|
const newVersionAndTag = await require(path.resolve(preChangelogGeneration)).preChangelogGeneration({
|
||||||
tag: gitTag,
|
tag: gitTag,
|
||||||
version: newVersion,
|
version: newVersion,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
gitTag = newVersionAndTag.tag
|
||||||
|
newVersion = newVersionAndTag.version
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate the string changelog
|
// Generate the string changelog
|
||||||
|
|
|
@ -9,8 +9,14 @@ exports.preChangelogGeneration = (props) => {
|
||||||
t.ok(props.version, 'version should not be empty')
|
t.ok(props.version, 'version should not be empty')
|
||||||
|
|
||||||
const newVersion = '1.0.100'
|
const newVersion = '1.0.100'
|
||||||
|
const newTag = 'v1.0.100'
|
||||||
|
|
||||||
fs.writeFileSync('test-version', newVersion)
|
const body = {
|
||||||
|
version: newVersion,
|
||||||
|
tag: newTag,
|
||||||
|
}
|
||||||
|
|
||||||
return newVersion
|
fs.writeFileSync('pre-changelog-generation.test.json', JSON.stringify(body, null, 2))
|
||||||
|
|
||||||
|
return body
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue