Skip to content

ci: release postject to npm on ci #30

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,42 @@ commands:
- store_test_results:
path: .

publish:
steps:
- attach_workspace:
at: .

- run:
name: Remove unnecessary files
command: rm -rf emsdk

- run:
name: Update version if not on git tag
command: |
if ! git describe --exact-match HEAD 1>/dev/null 2>/dev/null
then
git describe --exact-match HEAD 1>/dev/null 2>/dev/null && exit
CURRENT_VERSION="$(node -p "require('./package.json').version")"
GIT_COMMIT_SHA="$(git rev-parse --short HEAD)"
npm version "$CURRENT_VERSION-$GIT_COMMIT_SHA"
fi

- run:
name: Login to npm
command: npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN

- run:
name: Publish to npm
command: |
if git describe --exact-match HEAD 1>/dev/null 2>/dev/null
then
# Publish to latest when a git tag is pushed.
npm publish --tag latest
else
# Publish to beta when not run on a git tag.
npm publish --tag beta
fi

## JOBS ##

jobs:
Expand Down Expand Up @@ -210,6 +246,14 @@ jobs:
os: << parameters.os >>
- test

publish:
parameters:
<<: *common_parameters
executor: { name: linux }
steps:
- checkout
- publish

## WORKFLOWS ##

matrix: &matrix
Expand All @@ -229,4 +273,9 @@ workflows:
- test:
<<: *matrix
requires: [ build-<< matrix.os >> ]
- publish:
matrix:
parameters:
os: [ linux ]
Comment on lines +277 to +279
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need a matrix here, or parameters for the publish command further up in this config? We're just using the linux executor so we should be able to just use that one explicitly.

requires: [ test-<< matrix.os >> ]

10 changes: 10 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
build/
.circleci/
CMakeLists.txt
CODEOWNERS
DEPENDENCIES
postject-api.h
scripts/
src/
test/
vendor/
6 changes: 6 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
Easily inject arbitrary read-only resources into executable formats
(Mach-O, PE, ELF) and use it at runtime.

## Install

```sh
npm i postject
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
npm i postject
npm i -g postject

There's a good chance users of the Postject CLI will be using it outside of a Node project, so I think installing it globally is the better option.

```

## Building

### Prerequisites
Expand Down