Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
Release with bun shell
Browse files Browse the repository at this point in the history
  • Loading branch information
RaniAgus committed Jan 27, 2024
1 parent d7f3c46 commit 6c721ea
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 56 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ jobs:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: oven-sh/setup-bun@v1
with:
python-version: '3.10'
check-latest: true
bun-version: latest
- name: Generate release files
run: ./release.sh ${{ github.ref_name }}
run: bun ./scripts/release.js ${{ github.ref_name }}
- name: Create pre-release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
Expand Down
28 changes: 0 additions & 28 deletions makegen.py

This file was deleted.

24 changes: 0 additions & 24 deletions release.sh

This file was deleted.

77 changes: 77 additions & 0 deletions scripts/release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { $ } from 'bun';
import { parseArgs } from 'util';

const { values } = parseArgs({
args: Bun.argv,
options: {
tag: {
type: 'string',
default: 'SNAPSHOT'
},
src: {
type: 'string',
default: 'src'
},
dest: {
type: 'string',
default: 'dist'
},
templates: {
type: 'string',
default: 'project,static,shared'
}
},
allowPositionals: true,
});

const main = async ({ tag, src, dest, templates }) => {
await log(`cleaning up ${dest}...`);

await $`rm -rfv ${dest}`
await $`mkdir -p ${dest}`

await log(`parsing templates from ${src}...`);

for (const template of templates.split(',')) {
await log(`generating ${template}...`);

await $`rsync -r --exclude-from=${src}/${template}/.gitignore ${src}/${template} ${dest}`
await $`rsync -r ${src}/${template}/.vscode ${dest}/${template}`

const lines = await generate(`${src}/${template}`)
await $`echo ${lines.join('\n')} | tee ${dest}/${template}/makefile`

await log(`generating release files for ${template}...`);

await $`tar -czvf ${template}-${tag}.tar.gz ${template}`.cwd(dest)
await $`md5sum ${template}-${tag}.tar.gz > ${template}-${tag}.tar.gz.md5`.cwd(dest)
await $`sha1sum ${template}-${tag}.tar.gz > ${template}-${tag}.tar.gz.sha1`.cwd(dest)

await log(`cleaning up ${template}...`);

await $`rm -rfv ${template}`.cwd(dest)
}
}

const log = async (line) => {
await $`echo '\n\n'${line}'\n\n'`
}

const generate = async (dir) => {
const lines = await $`cat ${dir}/makefile`.text()
return Promise.all(lines.split('\n').map(line => parseLine(line, dir)))
}

const parseLine = async (line = '', dir = '.') => {
if (line.startsWith('include ../')) {
return await include(line, dir)
}
return line;
}

const include = async (line, dir) => {
const [_, filename] = line.split(' ')
return await $`cat ${dir}/${filename}`.text()
}

await main(values);

0 comments on commit 6c721ea

Please sign in to comment.