From 2f8b0ffecd0919d7dfee277c0d339ce944579926 Mon Sep 17 00:00:00 2001 From: Manuel Trezza <5673677+mtrezza@users.noreply.github.com> Date: Sat, 13 Jul 2024 00:26:34 +0200 Subject: [PATCH] update other files --- .github/workflows/release-automated.yml | 10 ++-------- release.config.cjs => .releaserc.js | 23 +++++++++++++++-------- 2 files changed, 17 insertions(+), 16 deletions(-) rename release.config.cjs => .releaserc.js (83%) diff --git a/.github/workflows/release-automated.yml b/.github/workflows/release-automated.yml index 55272ed69..40be2d42b 100644 --- a/.github/workflows/release-automated.yml +++ b/.github/workflows/release-automated.yml @@ -13,14 +13,8 @@ jobs: - name: Setup Node uses: actions/setup-node@v2 with: - node-version: 18 - - name: Cache Node.js modules - uses: actions/cache@v2 - with: - path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-node- + node-version: 22 + cache: 'npm' - name: Install dependencies run: npm ci - name: Run semantic-release diff --git a/release.config.cjs b/.releaserc.js similarity index 83% rename from release.config.cjs rename to .releaserc.js index 7eb04a311..021346cf4 100644 --- a/release.config.cjs +++ b/.releaserc.js @@ -2,8 +2,14 @@ * Semantic Release Config */ -const fs = require('fs').promises; -const path = require('path'); +// For CommonJS use: +// const { readFile } = require('fs').promises; +// const { resolve } = require('path'); + +// For ES6 modules use: +import { readFile } from 'fs/promises'; +import { resolve, dirname } from 'path'; +import { fileURLToPath } from 'url'; // Get env vars const ref = process.env.GITHUB_REF; @@ -24,7 +30,7 @@ const templates = { async function config() { // Get branch - const branch = ref.split('/').pop(); + const branch = ref?.split('/')?.pop()?.split('-')[0] || '(current branch could not be determined)'; console.log(`Running on branch: ${branch}`); // Set changelog file @@ -97,15 +103,16 @@ async function config() { async function loadTemplates() { for (const template of Object.keys(templates)) { - const text = await readFile(path.resolve(__dirname, resourcePath, templates[template].file)); + // For ES6 modules use: + const fileUrl = import.meta.url; + const __dirname = dirname(fileURLToPath(fileUrl)); + + const filePath = resolve(__dirname, resourcePath, templates[template].file); + const text = await readFile(filePath, 'utf-8'); templates[template].text = text; } } -async function readFile(filePath) { - return await fs.readFile(filePath, 'utf-8'); -} - function getReleaseComment() { const url = repositoryUrl + '/releases/tag/${nextRelease.gitTag}'; let comment = '🎉 This change has been released in version [${nextRelease.version}](' + url + ')';