Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release: v1.9.0 #37

Merged
merged 12 commits into from
Dec 9, 2024
Merged
31 changes: 31 additions & 0 deletions .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Publish npm package

on:
push:
tags: [ 'v*' ]


jobs:
publish-npm:
runs-on: ubuntu-latest
steps:

- uses: actions/setup-node@v1
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'

- uses: actions/checkout@v3

- name: Place tag in environment
run: |
echo "SOURCE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV

- name: Setting package.json version
run: npm version --no-git-tag-version "${SOURCE_TAG#v}"

- run: npm install

- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
20 changes: 20 additions & 0 deletions .github/workflows/release-prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 'Release: Prepare PR'

on:
push:
branches: [ develop ]

permissions:
contents: read
pull-requests: write

jobs:
release-prepare:

runs-on: ubuntu-latest
steps:

- uses: JarvusInnovations/infra-components@channels/github-actions/release-prepare/latest
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
release-branch: main
16 changes: 16 additions & 0 deletions .github/workflows/release-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: 'Release: Publish PR'

on:
pull_request:
branches: [ main ]
types: [ closed ]

jobs:
release-publish:

runs-on: ubuntu-latest
steps:

- uses: JarvusInnovations/infra-components@channels/github-actions/release-publish/latest
with:
github-token: ${{ secrets.BOT_GITHUB_TOKEN }}
16 changes: 16 additions & 0 deletions .github/workflows/release-validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: 'Release: Validate PR'

on:
pull_request:
branches: [ main ]
types: [ opened, edited, reopened, synchronize ]

jobs:
release-validate:

runs-on: ubuntu-latest
steps:

- uses: JarvusInnovations/infra-components@channels/github-actions/release-validate/latest
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
32 changes: 32 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Tests

on:
pull_request:

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]

steps:
- uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Configure Git
run: |
git config --global user.name "GitHub Actions Bot"
git config --global user.email "[email protected]"

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
**/test/
**/.vscode/
.github/**
.eslintrc.json
44 changes: 28 additions & 16 deletions lib/Git.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,9 @@ class Git {

constructor ({ command = null, gitDir = null, workTree = null, indexFile = null } = {}) {
this.command = command || this.command;

if (gitDir) {
this.gitDir = gitDir;
}

if (workTree) {
this.workTree = workTree;
}

if (indexFile) {
this.indexFile = indexFile;
}

this.version = null;
}

Expand All @@ -49,9 +39,12 @@ class Git {
* Gets complete path to working tree
*/
static async getWorkTreeFromEnvironment () {
try {
const workTree = await Git.prototype.exec('rev-parse', { 'show-toplevel': true });

return await workTree ? fs.realpath(workTree) : Promise.resolve(null);
return workTree ? await fs.realpath(workTree) : null;
} catch (err) {
return null;
}
};


Expand Down Expand Up @@ -361,6 +354,18 @@ class Git {
delete arg.$spawn;
}

if ('$onStdout' in arg) {
execOptions.onStdout = arg.$onStdout;
execOptions.spawn = true;
delete arg.$onStdout;
}

if ('$onStderr' in arg) {
execOptions.onStderr = arg.$onStderr;
execOptions.spawn = true;
delete arg.$onStderr;
}

if ('$shell' in arg) {
execOptions.shell = arg.$shell;
delete arg.$shell;
Expand Down Expand Up @@ -447,8 +452,15 @@ class Git {
const process = child_process.spawn(this.command, commandArgs, execOptions);

if (execOptions.passthrough) {
process.stdout.on('data', data => data.toString().trim().split(/\n/).forEach(line => logger.info(line)));
process.stderr.on('data', data => data.toString().trim().split(/\n/).forEach(line => logger.error(line)));
process.stdout.on('data', data => data.toString().split(/\n/).forEach(line => logger.info(line.trimEnd())));
process.stderr.on('data', data => data.toString().split(/\n/).forEach(line => logger.error(line.trimEnd())));
} else {
if (execOptions.onStdout) {
process.stdout.on('data', data => data.toString().split(/\n/).forEach(line => execOptions.onStdout(line.trimEnd())));
}
if (execOptions.onStderr) {
process.stderr.on('data', data => data.toString().split(/\n/).forEach(line => execOptions.onStderr(line.trimEnd())));
}
}

if (execOptions.wait) {
Expand Down Expand Up @@ -516,7 +528,7 @@ class Git {
}
}

resolve(stdout.trim());
resolve(stdout.trimEnd());
});
});
} else {
Expand All @@ -531,7 +543,7 @@ class Git {
}
}

resolve(stdout.trim());
resolve(stdout.trimEnd());
});
});
}
Expand Down
Loading
Loading