Skip to content

Commit

Permalink
Post-rebase adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
iLiftALot committed Nov 13, 2024
1 parent ccec41a commit 3be2078
Show file tree
Hide file tree
Showing 7 changed files with 590 additions and 1,306 deletions.
44 changes: 37 additions & 7 deletions .github/workflows/release_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ name: Release and Publish
on:
push:
tags:
- 'v*' # Triggers the workflow when a new version tag (e.g., v1.0.0) is pushed.
- 'v*'
branches:
- 'master'

workflow_dispatch:
inputs:
version_type:
Expand All @@ -19,22 +18,40 @@ on:
- minor
- major

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/[email protected]
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v4.1.0
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'

- name: Configure Git
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
- name: Install dependencies
run: npm install
run: npm ci

- name: Run Version Bump Script
run: npm run bump-version

- name: Commit Version Bump Changes
run: |
git add .
git commit -m "Update manifest and versions"
- name: Update Version
id: update_version
Expand All @@ -46,21 +63,34 @@ jobs:
- name: Build Project
run: npm run build

- name: Commit Build Artifacts
run: |
git add .
git commit -m "Build artifacts for version ${{ steps.update_version.outputs.new_version }}"
- name: Set up authentication
run: |
git remote set-url origin https://x-access-token:${{ secrets.REPO_TOKEN }}@github.com/${{ github.repository }}.git
- name: Push Changes
run: |
git push origin HEAD --follow-tags
- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2.1.0
with:
tag_name: "v${{ steps.update_version.outputs.new_version }}"
name: "Release v${{ steps.update_version.outputs.new_version }}"
body: |
Automated release of version v${{ steps.update_version.outputs.new_version }}.
- name: Upload Plugin Files
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4.4.3
with:
name: insta-toc-${{ steps.update_version.outputs.new_version }}
path: |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ A plugin to dyamically generate a table of contents while you are writing.

![./assets/media/demonstration.gif](https://raw.githubusercontent.com/iLiftALot/insta-toc/master/media/demonstration.gif)

⚠️ **This is a beta plugin and is not yet ready for production use.**
⚠️ **This is a beta plugin and is not yet ready for production use.**
42 changes: 23 additions & 19 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import {
existsSync,
writeFileSync,
readFileSync,
symlinkSync,
unlinkSync
copyFileSync
} from "fs";

const banner =
Expand Down Expand Up @@ -110,8 +109,11 @@ if (envFilePath) {
}
}

const sourcePath = `${pluginRoot}/${packageMain}`;
const targetPath = `${pluginRoot}/main.js`;
const sourcePath = path.resolve(`${pluginRoot}/${packageMain}`);
const targetPath = path.resolve(`${pluginRoot}/main.js`);

logs.push(`Source Path: ${sourcePath}`);
logs.push(`Target Path: ${targetPath}`);

const context = await esbuild.context({
banner: {
Expand Down Expand Up @@ -148,25 +150,27 @@ const context = await esbuild.context({
}).catch((error) => {
console.error(error);
process.exit(1);
})

try {
if (existsSync(targetPath)) {
unlinkSync(targetPath); // Remove existing symlink or file
});

function copyMainJs() {
try {
// Copy the file instead of creating a symlink
copyFileSync(sourcePath, targetPath);
logs.push(`Copied file: ${sourcePath} -> ${targetPath}`);

logs = logs.join('\n');
if (shouldLog) console.log(logs);
} catch (error) {
console.error(`Error creating symlink: ${error}\nLogs:\n${logs.join('\n')}`);
process.exit(1);
}
symlinkSync(sourcePath, targetPath);
logs.push(`Symlink created: ${targetPath} -> ${sourcePath}`);
} catch (error) {
console.error('Error creating symlink:', error);
process.exit(1);
}

logs = logs.join('\n');
if (shouldLog) console.log(logs);

if (prod) {
await context.rebuild();
process.exit(0);
copyMainJs();
await context.dispose();
} else {
copyMainJs();
await context.watch();
}
}
Loading

0 comments on commit 3be2078

Please sign in to comment.