Skip to content

Commit

Permalink
Fix builds again?
Browse files Browse the repository at this point in the history
  • Loading branch information
koerismo committed Aug 4, 2023
1 parent 33f2a51 commit 08329e8
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 494 deletions.
33 changes: 21 additions & 12 deletions .github/workflows/run-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,39 @@ jobs:

build-all:
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '14'

- run: |
pwd
cd ${{ github.repository }}
node-version: '18'

- name: Install dependencies
run: |
npm install
run: npm ic

- name: Run build
run: npm run build
run: |
mkdir dist
npm run build
npm run build:csgo
- name: Switch to build branch
run: git checkout build
- name: Configure git
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
git fetch --all
git checkout --track origin/build
- name: Copy files
run: cp "./dist/*" "./"
run: cp -r ./dist/* ./

- name: Commit files
run: |
git add *.d.ts
git commit -m "Build for ${{ github.ref }}"
git push
git commit -m "Automated build on ${{ github.ref }}"
git push origin build
31 changes: 19 additions & 12 deletions compile.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
import { createReadStream, createWriteStream, readFileSync } from 'fs';
import { glob } from 'glob';
import { createReadStream, createWriteStream, readFileSync, readdirSync } from 'fs';
import MultiStream from 'multistream';
import ReplaceStream from 'replacestream';

const header = readFileSync('src/header.d.ts', { encoding: 'utf-8' })
.replace('$npm_package_version$', process.env.npm_package_version);

function build(files, out_name) {
function build(files, out_name, replace_chaos=false) {
const output = createWriteStream(`dist/${out_name}.d.ts`, { encoding: 'utf-8' });
output.write(header);

const streams = files.map(x => createReadStream(x, { encoding: 'utf-8' }));
new MultiStream(streams).pipe(output);
const ms = new MultiStream(streams);

if (!replace_chaos) ms.pipe(output);
else ms.pipe(ReplaceStream('Chaos', 'CSGO')).pipe(output);
}

async function eval_globs(sources) {
function list_files(sources) {
const files = [];

for (const source of sources)
files.push(...await glob(`src/${source}/*.d.ts`));

return files;
for (const source of sources) {
const root_dir = `src/${source}/`;
const rawlist = readdirSync(root_dir, { recursive: true });
const remapped = rawlist.map(x => root_dir+x.replace(/\\\\/, '/'));
files.push(...remapped);
}
return files.filter(x => x.endsWith('.d.ts'));
}

if (process.argv.length !== 4) throw('Argument count must equal 4!');
const sources = process.argv[2].split(',');
const files = await eval_globs(sources);
build(files, process.argv[3]);
const files = list_files(sources);

const filename = process.argv[3];
build(files, filename, filename === 'csgo');
Loading

0 comments on commit 08329e8

Please sign in to comment.