Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions .github/workflows/release-automated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup Node
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: 14
- 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: 20
cache: npm
- name: Install dependencies
run: npm ci
- name: Run semantic-release
Expand Down
49 changes: 31 additions & 18 deletions release.config.js → .releaserc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
* Semantic Release Config
*/

const fs = require('fs').promises;
const path = require('path');
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;
Expand All @@ -24,11 +29,11 @@ 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
//const changelogFile = `./changelogs/CHANGELOG_${branch}.md`;
// const changelogFile = `./changelogs/CHANGELOG_${branch}.md`;
const changelogFile = `./CHANGELOG.md`;
console.log(`Changelog file output to: ${changelogFile}`);

Expand All @@ -38,14 +43,10 @@ async function config() {
const config = {
branches: [
'master',
// { name: 'alpha', prerelease: true },
// { name: 'beta', prerelease: true },
// 'next-major',
// Long-Term-Support branches
// { name: 'release-1', range: '1.x.x', channel: '1.x' },
// { name: 'release-2', range: '2.x.x', channel: '2.x' },
// { name: 'release-3', range: '3.x.x', channel: '3.x' },
// { name: 'release-4', range: '4.x.x', channel: '4.x' },
'main',
'release',
{ name: 'alpha', prerelease: true },
{ name: 'beta', prerelease: true },
],
dryRun: false,
debug: true,
Expand Down Expand Up @@ -82,13 +83,23 @@ async function config() {
'npmPublish': true,
}],
['@semantic-release/git', {
assets: [changelogFile, 'package.json', 'package-lock.json'],
assets: [changelogFile, 'package.json', 'package-lock.json', 'npm-shrinkwrap.json'],
}],
['@semantic-release/github', {
successComment: getReleaseComment(),
labels: ['type:ci'],
releasedLabels: ['state:released<%= nextRelease.channel ? `-\${nextRelease.channel}` : "" %>']
}],
// Back-merge module runs last because if it fails it should not impede the release process
[
"@saithodev/semantic-release-backmerge",
{
"backmergeBranches": [
{ from: "beta", to: "alpha" },
{ from: "release", to: "beta" },
]
}
],
],
};

Expand All @@ -97,15 +108,17 @@ 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}';
const comment = '🎉 This change has been released in version [${nextRelease.version}](' + url + ')';
Expand Down
Loading
Loading