Skip to content

Commit e287fde

Browse files
authored
Feat: add tpl(eslint, stylelint, autotag ci, release ci) (#58)
1 parent d3221bc commit e287fde

5 files changed

Lines changed: 75 additions & 8 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: "Automatically tag new version"
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
- "**/bugfixes"
8+
paths:
9+
- "setup.php"
10+
11+
jobs:
12+
auto-tag-new-version:
13+
name: "Automatically tag new version"
14+
uses: "glpi-project/plugin-release-workflows/.github/workflows/auto-tag-new-version.yml@v1"
15+
secrets:
16+
github-token: "${{ secrets.AUTOTAG_TOKEN }}"

‎.github/workflows/release.yml.tpl‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: "Publish release"
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
publish-release:
10+
permissions:
11+
contents: "write"
12+
name: "Publish release"
13+
uses: "glpi-project/plugin-release-workflows/.github/workflows/publish-release.yml@v1"

‎.stylelintrc.js.tpl‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
extends: [
3+
'../../.stylelintrc.js'
4+
],
5+
ignoreFiles: [
6+
'node_modules/**/*',
7+
'vendor/**/*'
8+
],
9+
};

‎eslint.config.mjs.tpl‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import glpiEslintConfig from '../../eslint.config.mjs';
2+
3+
const filteredConfig = glpiEslintConfig.filter(config => !config.ignores);
4+
5+
export default [
6+
...filteredConfig,
7+
{
8+
ignores: [
9+
'node_modules/*',
10+
"public/lib/*",
11+
'vendor/*',
12+
],
13+
},
14+
{
15+
// Modules
16+
files: ["public/js/libs.js"],
17+
languageOptions: {
18+
sourceType: "module"
19+
}
20+
}
21+
];

‎plugin.sh‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,23 @@ if [ -d "$DEST" ]; then
6060
exit 1
6161
fi
6262

63+
read -r -p "Does your plugin include JS/TS files? [y/N] " has_js
64+
read -r -p "Does your plugin include CSS/SCSS/SASS/LESS files? [y/N] " has_css
65+
6366
mkdir "$DEST"
6467

65-
rsync \
66-
--exclude '.git' \
67-
--exclude '.github/workflows/continuous-integration.yml' \
68-
--exclude '.github/workflows/create-plugin.sh' \
69-
--exclude 'plugin.sh' \
70-
--exclude 'dist' \
71-
--exclude 'README.md' \
72-
-a . "$DEST"
68+
rsync_excludes=(
69+
--exclude '.git'
70+
--exclude '.github/workflows/continuous-integration.yml'
71+
--exclude '.github/workflows/create-plugin.sh'
72+
--exclude 'plugin.sh'
73+
--exclude 'dist'
74+
--exclude 'README.md'
75+
)
76+
[[ ! "$has_js" =~ ^[Yy]$ ]] && rsync_excludes+=(--exclude 'eslint.config.mjs.tpl')
77+
[[ ! "$has_css" =~ ^[Yy]$ ]] && rsync_excludes+=(--exclude '.stylelintrc.js.tpl')
78+
79+
rsync "${rsync_excludes[@]}" -a . "$DEST"
7380

7481
pushd "$DEST" > /dev/null
7582

@@ -97,3 +104,4 @@ sed -i '/^[[:space:]]*composer\.lock[[:space:]]*$/d' .gitignore
97104
popd > /dev/null
98105

99106
echo -e "\033[0;32mPlugin $NAME created under $DEST\033[0m"
107+
echo -e "\033[0;33mDon't forget to add a RELEASE_TOKEN secret in your GitHub repository settings (Settings → Secrets and variables → Actions) with a personal access token having 'contents: write' permission.\033[0m"

0 commit comments

Comments
 (0)