polyci 0.0.11 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/main.js +13 -14
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -141,7 +141,7 @@ function appendGlobalVariables(lines) {
141
141
  lines.push(` IMAGE_DOCKER: docker:latest`);
142
142
  lines.push(` IMAGE_COMPOSE: docker:cli`);
143
143
  lines.push(` GIT_PACKAGE: git`);
144
- lines.push(` GIT_STRATEGY: clone`);
144
+ lines.push(` GIT_STRATEGY: clone`); //this prevents the stale tags in the ci job.
145
145
  lines.push(``);
146
146
  lines.push(`stages:`);
147
147
  lines.push(` - build`);
@@ -221,11 +221,11 @@ function appendModuleReleaseJob(lines, module) {
221
221
  lines.push(` fi`);
222
222
  lines.push(` - |`);
223
223
  lines.push(` if [ "$MODULE_TYPE" = "node-express" ]; then`);
224
- lines.push(` node -e "const fs=require('fs'); const pkg=JSON.parse(fs.readFileSync('package.json','utf8')); pkg.version=process.env.PACKAGE_VERSION; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\\n');"`);
224
+ lines.push(` node -e "const fs=require('fs'); const pkg=JSON.parse(fs.readFileSync('package.json','utf8')); pkg.version=process.argv[1]; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\\n');" "$PACKAGE_VERSION"`);
225
225
  lines.push(` node ci/prepare-deploy-variables.js --instance-branch $CI_COMMIT_BRANCH`);
226
226
  lines.push(` elif [ "$MODULE_TYPE" = "node-vite" ]; then`);
227
- lines.push(` node ci/set-release-data.js -i $CI_COMMIT_BRANCH --version=$NEXT_VERSION -t`);
228
- lines.push(` node -e "const fs=require('fs'); const pkg=JSON.parse(fs.readFileSync('package.json','utf8')); pkg.version=process.env.PACKAGE_VERSION; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\\n');"`);
227
+ lines.push(` node ci/set-release-data.js -i $CI_COMMIT_BRANCH --version=$PACKAGE_VERSION -t`);
228
+ lines.push(` node -e "const fs=require('fs'); const pkg=JSON.parse(fs.readFileSync('package.json','utf8')); pkg.version=process.argv[1]; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\\n');" "$PACKAGE_VERSION"`);
229
229
  lines.push(` node ci/prepare-deploy-variables.js --instance-branch $CI_COMMIT_BRANCH`);
230
230
  lines.push(` else`);
231
231
  lines.push(` echo "Invalid module type: $MODULE_TYPE"`);
@@ -259,7 +259,7 @@ function appendGlobalReleaseJob(lines, modules, mainBranch, tagTemplate, branchT
259
259
  lines.push(` - git config user.email "polyci@anarun.net"`);
260
260
  lines.push(` - git config user.name "polyci"`);
261
261
  lines.push(` - git remote set-url origin "https://oauth2:\${GITLAB_TOKEN}@\${CI_SERVER_HOST}/\${CI_PROJECT_PATH}.git"`);
262
- lines.push(` - TAG_CREATED=false`);
262
+ lines.push(` - TAG_NAMES=""`);
263
263
  lines.push(``);
264
264
  for (const module of modules) {
265
265
  lines.push(` - echo "Tagging release for ${module.moduleName} (${module.modulePath})"`);
@@ -287,8 +287,7 @@ function appendGlobalReleaseJob(lines, modules, mainBranch, tagTemplate, branchT
287
287
  else if (module.moduleType === "node-vite") {
288
288
  lines.push(` git add "${module.modulePath}/package.json" "${module.modulePath}/public/release.json"`);
289
289
  }
290
- lines.push(` git tag "$TAG_NAME"`);
291
- lines.push(` TAG_CREATED=true`);
290
+ lines.push(` TAG_NAMES="\${TAG_NAMES} \${TAG_NAME}"`);
292
291
  lines.push(` fi`);
293
292
  lines.push(` else`);
294
293
  lines.push(` echo "Missing ${module.modulePath}/semalease.env, skipping ${module.moduleName}"`);
@@ -296,13 +295,12 @@ function appendGlobalReleaseJob(lines, modules, mainBranch, tagTemplate, branchT
296
295
  }
297
296
  lines.push(``);
298
297
  lines.push(` - |`);
299
- lines.push(` if [ "$TAG_CREATED" = true ]; then`);
300
- lines.push(` git status`);
301
- lines.push(` git commit -m "release: ${modules.map((m) => m.moduleName).join(", ")}"`);
302
- lines.push(` git status`);
303
- lines.push(` TARGET_BRANCH="\${CI_COMMIT_BRANCH:-\${CI_COMMIT_REF_NAME}}"`);
304
- lines.push(` git push origin "HEAD:refs/heads/\${TARGET_BRANCH}"`);
305
- lines.push(` git push origin --tags`);
298
+ lines.push(` if [ -n "$TAG_NAMES" ]; then`);
299
+ lines.push(` git commit --allow-empty -m "release: ${modules.map((m) => m.moduleName).join(", ")}"`);
300
+ lines.push(` for TAG_NAME in \${TAG_NAMES}; do`);
301
+ lines.push(` git tag "\${TAG_NAME}"`);
302
+ lines.push(` done`);
303
+ lines.push(` git push origin "HEAD:refs/heads/\${TARGET_BRANCH}" && git push origin --tags"`);
306
304
  lines.push(` else`);
307
305
  lines.push(` echo "No new tags created; skipping commit/push"`);
308
306
  lines.push(` fi`);
@@ -332,6 +330,7 @@ function appendModulePublishJob(lines, module) {
332
330
  lines.push(` script:`);
333
331
  lines.push(` - cp -r ci $MODULE_PATH/ci`);
334
332
  lines.push(` - cd $MODULE_PATH`);
333
+ lines.push(` - cat deploy.env`);
335
334
  lines.push(` - source deploy.env`);
336
335
  lines.push(` - npm ci`);
337
336
  lines.push(` - cp ci/$MODULE_TYPE/Dockerfile .`);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "polyci",
3
3
  "description": "Monorepo CI/CD utilities.",
4
- "version": "0.0.11",
4
+ "version": "0.0.12",
5
5
  "type": "module",
6
6
  "private": false,
7
7
  "author": "Alexander Tsarev",