Skip to content

Commit

Permalink
feat: provide executables on release
Browse files Browse the repository at this point in the history
This adds actions to create executables on every release and adds them as assets to each release, respectively.
  • Loading branch information
geographika committed May 31, 2023
1 parent 1bad5db commit eadbd8f
Show file tree
Hide file tree
Showing 6 changed files with 1,213 additions and 101 deletions.
3 changes: 3 additions & 0 deletions .commitlintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional']
};
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Release

on:
workflow_dispatch:

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout sources 🔰
uses: actions/checkout@v3

- name: Setup Node.js 18 👷🏻
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install dependencies ⏬
run: npm ci

- name: Build artifacts 🏗️
run: npm run package-binaries

- name: Release 🚀
uses: cycjimmy/semantic-release-action@v3
id: semantic
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
32 changes: 32 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"branches": ["main"],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits",
"presetConfig": {
"header": "Changelog of GeoStyler Client"
}
}
],
"@semantic-release/changelog",
"@semantic-release/npm",
[
"@semantic-release/git",
{
"assets": [
"./binaries/geostyler-cli-linux.zip", "./binaries/geostyler-cli-macos.zip", "./binaries/geostyler-cli-win.exe.zip"
],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
],
"@semantic-release/github"
]
}
51 changes: 51 additions & 0 deletions package-binaries.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const fs = require('fs');
const path = require('path');
const AdmZip = require('adm-zip');


// Define the folder path and the list of file names
const folderPath = './binaries/';
const fileNames = ['geostyler-cli-win.exe', 'geostyler-cli-linux', 'geostyler-cli-macos'];

function renameFile(oldPath, newPath) {
return new Promise((resolve, reject) => {
fs.rename(oldPath, newPath, (error) => {
if (error) {
reject(error);
} else {
resolve();
}
});
});
}

// Function to execute the renaming and zipping process
async function processFiles() {
try {
for (const fileName of fileNames) {
const filePath = folderPath + fileName;
const renamedFilePath = folderPath + fileName.replace('-win', '').replace('-macos', '').replace('-linux', '');

// Rename the file
await renameFile(filePath, renamedFilePath);

// Zip the file
const outputZipFilePath = filePath + '.zip';
const zip = new AdmZip();
zip.addLocalFile(renamedFilePath);

// Save the zip archive
zip.writeZip(outputZipFilePath);

// Rename the zipped file back to its original name
await renameFile(renamedFilePath, filePath);
console.log(`Processed file: ${fileName}`);

Check warning on line 42 in package-binaries.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Unexpected console statement

Check warning on line 42 in package-binaries.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Unexpected console statement
}

console.log('All files processed successfully.');

Check warning on line 45 in package-binaries.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Unexpected console statement

Check warning on line 45 in package-binaries.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Unexpected console statement
} catch (error) {
console.error('An error occurred:', error);

Check warning on line 47 in package-binaries.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Unexpected console statement

Check warning on line 47 in package-binaries.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Unexpected console statement
}
}

processFiles();

0 comments on commit eadbd8f

Please sign in to comment.