Skip to content

Commit 8e2c546

Browse files
committed
feat(php): update deprecation version number in semantic-release run
* References: - saltstack-formulas/php-formula#175 (comment) - saltstack-formulas/php-formula#185 (comment) * Ensure this only runs until `v1.0.0` (done in the script)
1 parent 18697a7 commit 8e2c546

File tree

2 files changed

+149
-0
lines changed

2 files changed

+149
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/sh
2+
3+
###############################################################################
4+
# (A) Update `FORMULA` with `${nextRelease.version}`
5+
###############################################################################
6+
sed -i -e "s_^\(version:\).*_\1 ${1}_" FORMULA
7+
8+
9+
###############################################################################
10+
# (B) Use `m2r` to convert automatically produced `.md` docs to `.rst`
11+
###############################################################################
12+
13+
# Install `m2r`
14+
sudo -H pip install m2r
15+
16+
# Copy and then convert the `.md` docs
17+
cp *.md docs/
18+
cd docs/
19+
m2r --overwrite *.md
20+
21+
# Change excess `H1` headings to `H2` in converted `CHANGELOG.rst`
22+
sed -i -e '/^=.*$/s/=/-/g' CHANGELOG.rst
23+
sed -i -e '1,4s/-/=/g' CHANGELOG.rst
24+
25+
# Use for debugging output, when required
26+
# cat AUTHORS.rst
27+
# cat CHANGELOG.rst
28+
29+
# Return back to the main directory
30+
cd ..
31+
32+
33+
###############################################################################
34+
# (C) Update last version before `v1.0.0` with `${nextRelease.version}`
35+
###############################################################################
36+
# Only apply this while the version number is below `v1.0.0`!
37+
V_REPR=v${1}
38+
MAJOR=$(echo ${V_REPR} | cut -c-2)
39+
if [ ${MAJOR} = "v0" ]; then
40+
sed -i -e "s@^\(\s\+\`\).*\(\s<https://github.com/saltstack-formulas/php-formula/releases/tag/\).*\(>\`_\.\)@\1${V_REPR}\2${V_REPR}\3@" docs/README.rst
41+
sed -i -e "s@^\(\s\+# the final release tag before \`v1.0.0\`, which is expected to be \`\).*\(\`.\s\+#\)@\1${V_REPR}\2@" php/deprecated.sls
42+
sed -i -e "s@^\(\s\+# the final release tag before \`v1.0.0\`, which is expected to be \`\).*\(\`.\s\+#\)@\1${V_REPR}\2@" php/ng/deprecated.sls
43+
fi
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
module.exports = {
2+
branch: 'master',
3+
plugins: [
4+
['@semantic-release/commit-analyzer', {
5+
preset: 'angular',
6+
releaseRules: './release-rules.js',
7+
}],
8+
'@semantic-release/release-notes-generator',
9+
['@semantic-release/changelog', {
10+
changelogFile: 'CHANGELOG.md',
11+
changelogTitle: '# Changelog',
12+
}],
13+
['@semantic-release/exec', {
14+
prepareCmd: 'sh ./pre-commit_semantic-release.sh ${nextRelease.version}',
15+
}],
16+
['@semantic-release/git', {
17+
assets: ['*.md', 'docs/*.rst', 'FORMULA', 'php/deprecated.sls', 'php/ng/deprecated.sls'],
18+
}],
19+
'@semantic-release/github',
20+
],
21+
generateNotes: {
22+
preset: 'angular',
23+
writerOpts: {
24+
// Required due to upstream bug preventing all types being displayed.
25+
// Bug: https://github.com/conventional-changelog/conventional-changelog/issues/317
26+
// Fix: https://github.com/conventional-changelog/conventional-changelog/pull/410
27+
transform: (commit, context) => {
28+
const issues = []
29+
30+
commit.notes.forEach(note => {
31+
note.title = `BREAKING CHANGES`
32+
})
33+
34+
// NOTE: Any changes here must be reflected in `CONTRIBUTING.md`.
35+
if (commit.type === `feat`) {
36+
commit.type = `Features`
37+
} else if (commit.type === `fix`) {
38+
commit.type = `Bug Fixes`
39+
} else if (commit.type === `perf`) {
40+
commit.type = `Performance Improvements`
41+
} else if (commit.type === `revert`) {
42+
commit.type = `Reverts`
43+
} else if (commit.type === `docs`) {
44+
commit.type = `Documentation`
45+
} else if (commit.type === `style`) {
46+
commit.type = `Styles`
47+
} else if (commit.type === `refactor`) {
48+
commit.type = `Code Refactoring`
49+
} else if (commit.type === `test`) {
50+
commit.type = `Tests`
51+
} else if (commit.type === `build`) {
52+
commit.type = `Build System`
53+
// } else if (commit.type === `chore`) {
54+
// commit.type = `Maintenance`
55+
} else if (commit.type === `ci`) {
56+
commit.type = `Continuous Integration`
57+
} else {
58+
return
59+
}
60+
61+
if (commit.scope === `*`) {
62+
commit.scope = ``
63+
}
64+
65+
if (typeof commit.hash === `string`) {
66+
commit.hash = commit.hash.substring(0, 7)
67+
}
68+
69+
if (typeof commit.subject === `string`) {
70+
let url = context.repository
71+
? `${context.host}/${context.owner}/${context.repository}`
72+
: context.repoUrl
73+
if (url) {
74+
url = `${url}/issues/`
75+
// Issue URLs.
76+
commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => {
77+
issues.push(issue)
78+
return `[#${issue}](${url}${issue})`
79+
})
80+
}
81+
if (context.host) {
82+
// User URLs.
83+
commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => {
84+
if (username.includes('/')) {
85+
return `@${username}`
86+
}
87+
88+
return `[@${username}](${context.host}/${username})`
89+
})
90+
}
91+
}
92+
93+
// remove references that already appear in the subject
94+
commit.references = commit.references.filter(reference => {
95+
if (issues.indexOf(reference.issue) === -1) {
96+
return true
97+
}
98+
99+
return false
100+
})
101+
102+
return commit
103+
},
104+
},
105+
},
106+
};

0 commit comments

Comments
 (0)