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

Commit

Permalink
Migrate release script to bun shell
Browse files Browse the repository at this point in the history
  • Loading branch information
RaniAgus committed Jan 28, 2024
1 parent 7624039 commit 5bd84f2
Show file tree
Hide file tree
Showing 4 changed files with 73 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 --tag=${{ 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.

70 changes: 70 additions & 0 deletions scripts/release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { $ } from 'bun';
import { dirname } from 'path';
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 }) => {
console.log(`cleaning up ${dest}...\n\n`);

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

console.log(`\n\nparsing templates from ${src}...`);

for (const template of templates.split(',')) {
console.log(`\n\nparsing ${template}...\n\n`);

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

const makefile = await parseMakefile(`${src}/${template}/makefile`);
await $`echo ${makefile} | tee makefile`.cwd(`${dest}/${template}`);

console.log(`packing ${template} with tag ${tag}...\n\n`);

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);

console.log(`\n\ncleaning up ${template}...\n\n`);

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

const parseMakefile = async (file) => {
const lines = []
for await(const line of $`cat ${file}`.lines()) {
lines.push(await parseMakefileLine(file, line));
}
return lines.join('\n');
}

const parseMakefileLine = async (file, line) => {
const [_, include] = line.split(/^include /);
return include ? parseMakefile(`${dirname(file)}/${include}`) : line;
}

await main(values);

0 comments on commit 5bd84f2

Please sign in to comment.