Skip to content

Commit

Permalink
add github ci for bun
Browse files Browse the repository at this point in the history
  • Loading branch information
tahsinature committed Nov 10, 2024
1 parent 0c126ca commit df6b5a9
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 44 deletions.
34 changes: 9 additions & 25 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,22 @@
name: Node.js Package
name: Bun Publish

on:
push:
branches:
- master
create:
tags:
- "*"

jobs:
create-tag:
if: github.ref == 'refs/heads/master'
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
- name: Set up Bun
uses: oven-sh/setup-bun@v2
with:
node-version: "lts/*"
bun-version: latest
- name: Install dependencies
run: npm ci
- name: Bump version and add -SNAPSHOT suffix
run: |
npm version prerelease --preid=SNAPSHOT
git add package.json
git commit -m "Bump version to $(node -p "require('./package.json').version")"
- name: Create and push tag
run: |
TAG_NAME=$(node -p "require('./package.json').version")
git tag $TAG_NAME
git push origin $TAG_NAME
run: bun install
- name: publish
run: bun publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Push changes
run: git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_CONFIG_TOKEN: ${{ secrets.NPM_CONFIG_TOKEN }}
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://registry.npmjs.org/
5 changes: 5 additions & 0 deletions bin/hardbrake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bun

import hardbrake from "../src/index";

await hardbrake();
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
{
"name": "hardbrake",
"version": "1.0.7",
"module": "src/index.ts",
"type": "module",
"license": "MIT",
"files": [
"src",
"bin"
],
"bin": {
"hardbrake": "bin/hardbrake"
},
"scripts": {
"start": "bun run src/index.ts"
},
Expand Down
42 changes: 23 additions & 19 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,31 @@ import { askFiles, askPreset, askToggle } from "./prompts";
import { main } from "./engine";
import { checkRequiredBinaries } from "./check";

await checkRequiredBinaries();
const hardbrake = async () => {
await checkRequiredBinaries();

const files = await askFiles();
if (files.length === 0) {
console.log("No files selected. Exiting.");
process.exit(0);
}
const files = await askFiles();
if (files.length === 0) {
console.log("No files selected. Exiting.");
process.exit(0);
}

const preset = await askPreset();
const preset = await askPreset();

await main(files, preset);
await main(files, preset);

const happyWithResults = await askToggle("Are you happy with the results?");
if (!happyWithResults) {
for (const file of files) await file.deleteOutput();
console.log("Deleted all the output files.");
process.exit(0);
}
const happyWithResults = await askToggle("Are you happy with the results?");
if (!happyWithResults) {
for (const file of files) await file.deleteOutput();
console.log("Deleted all the output files.");
process.exit(0);
}

const deleteOriginalFiles = await askToggle("Do you want to delete the original files?");
if (deleteOriginalFiles) {
for (const file of files) await file.deleteOriginal();
console.log("Deleted all the original files.");
}
const deleteOriginalFiles = await askToggle("Do you want to delete the original files?");
if (deleteOriginalFiles) {
for (const file of files) await file.deleteOriginal();
console.log("Deleted all the original files.");
}
};

export default hardbrake;

0 comments on commit df6b5a9

Please sign in to comment.