Skip to content

Commit a5fe111

Browse files
authored
Move the docs to esy website
1 parent 7ef9016 commit a5fe111

File tree

1 file changed

+1
-201
lines changed

1 file changed

+1
-201
lines changed

README.md

Lines changed: 1 addition & 201 deletions
Original file line numberDiff line numberDiff line change
@@ -4,207 +4,7 @@ This action will setup [`esy`](https://esy.sh/) and cache any dependencies that
44
are built (hopefully saving you CI minutes). Additionally, it can help you
55
package your apps for multiple platforms into a single NPM tarball.
66

7-
For instance,
8-
9-
```
10-
npm i -g your-app
11-
```
12-
13-
Even if it's single command, the tarball can contain binaries for multiple
14-
target platforms - this action will create a postinstall script that will
15-
install the correct binaries.
16-
17-
Another benefit of this approach, is that, this action creates binary wrappers
18-
that make your apps self-sufficient in terms of runtime dependencies. For
19-
instance, if you need a runtime dependency (say, `zlib`), it can be tricky to
20-
make sure the user has the correct version installed via their system package
21-
manager. On Windows this is harder that one might expect. Read more about binary
22-
wrappers on [`esy` documentation](https://esy.sh/docs/concepts/#release)
23-
24-
## Example
25-
26-
```yml
27-
name: Build
28-
29-
on: [push]
30-
jobs:
31-
build:
32-
steps:
33-
- uses: esy/github-action@v2
34-
with:
35-
cache-key: ${{ hashFiles('esy.lock/index.json') }}
36-
```
37-
38-
## How does it work?
39-
40-
To create cross-platform builds without this action, you'll need to
41-
42-
1. Run `esy npm-release` on each `${{ matrix.os }}`
43-
2. Upload the `_release` folder as an artifact for a later job.
44-
3. In a job later, download the `_release` folder from each platform and place
45-
them together inside that NPM package that would be distributed. Now, the NPM
46-
package would contain binaries for multiple platforms.
47-
4. Make sure there's a postinstall script that would install the correct target
48-
platform's binaries (by inspect the environment)
49-
5. Run `esyInstallRelease.js` to set up the binary wrappers.
50-
51-
With this action, you wont need to do any of these. It will do all this for you
52-
and upload a `npm-release.tgz` for you to distribute later.
53-
54-
## Static linking
55-
56-
Statically linked binaries are desirable for many. To build such binaries for
57-
OCaml projects, you'll need `musl-libc` and the most portable way of gettting it
58-
is Docker.
59-
60-
This action doesn't provide a convenient way to produce statically linked
61-
binaries yet. You'll have to set up a separate job that uses Docker Actions,
62-
build the OCaml project with a `musl` enabled OCaml compiler inside a docker
63-
container and copy the artifacts out.
64-
65-
Here's an example `Dockerfile` to create such a container.
66-
67-
```dockerfile
68-
FROM esydev/esy:nightly-alpine-latest
69-
70-
COPY package.json package.json
71-
COPY esy.lock esy.lock
72-
RUN esy i
73-
RUN esy build-dependencies
74-
COPY hello.ml hello.ml
75-
RUN esy
76-
77-
ENTRYPOINT ["/entrypoint.sh"]
78-
```
79-
80-
Here's an example job on Github.
81-
82-
```yaml
83-
static-build:
84-
runs-on: ubuntu-latest
85-
steps:
86-
- name: Set up Docker Buildx
87-
uses: docker/setup-buildx-action@v3
88-
- name: Build and push
89-
uses: docker/build-push-action@v5
90-
with:
91-
file: ./docker/DevImage.Dockerfile
92-
push: false
93-
tags: user/app:latest
94-
- run: |
95-
docker container run --pull=never -itd --network=host --name "<CONTAINER_NAME>" "<IMAGE:TAG>"
96-
docker cp "<CONTAINER_NAME>:/usr/local/lib/esy" "<HOST_PATH>/lib/esy"
97-
docker cp "<CONTAINER_NAME>:/usr/local/bin/esy" "<HOST__PATH>/bin"
98-
docker cp "<CONTAINER_NAME>:/usr/local/bin/esyInstallRelease.js" "<HOST_PATH>/bin"
99-
name: "Copy artifacts from /usr/local/ in the container"
100-
- run: |
101-
tar czf npm-tarball.tgz _container_release
102-
mv npm-tarball.tgz _container_release
103-
```
104-
105-
For a complete working example, refer
106-
[how esy does this](https://github.com/esy/esy/blob/e124b61db298c9f917478c013d8ee700ce67a5ff/.github/workflows/release.yml#L42),
107-
but use the Dockerfile above instead.
108-
109-
## Inputs
110-
111-
### Required inputs
112-
113-
#### `cache-key`
114-
115-
The cache key. Typically `${{ hashFiles('esy.lock/index.json') }}`. You could
116-
also use a prefix additionally to bust cache when needed.
117-
118-
Example: `20240801-2-${{ hashFiles('esy.lock/index.json') }}`
119-
120-
#### `source-cache-key`
121-
122-
Typically a value similar to `cache-key` but used instead for caching the
123-
sources of the dependencies.
124-
125-
### Optional inputs
126-
127-
The following inputs are optional. When missing, the actions will fallback to
128-
use defaults are mentioned below.
129-
130-
#### `ocaml-compiler-version`
131-
132-
We need the compiler version to calculate the prefix path during preparation of
133-
NPM tarballs for different platforms and bundling into one tarball later. In the
134-
former stage, we need to rewrite prefixes and in the latter, to generate the
135-
postinstall.js script which would correctly rewrite the prefix again on the
136-
target machine. Mandatory only when in `prepare-npm-artifacts-mode` and
137-
`bundle-npm-artifacts-mode`. These modes are explained later below.
138-
139-
#### `esy-prefix`
140-
141-
Path where esy can setup the cache. Default: `$HOME/.esy`
142-
143-
#### `working-directory`
144-
145-
Working directory of the project. Useful for projects that place esy project
146-
under a folder. It's converted into an absolute path, if it already isn't.
147-
148-
Default: Action workspace root.
149-
150-
#### `manifest`
151-
152-
JSON or opam file to be used.
153-
154-
#### `prepare-npm-artifacts-mode`
155-
156-
Runs a step that prepare artifacts for releasing the app to NPM. Useful for CLI
157-
apps. These artifacts are later used by, `bundle-npm-tarball-mode`
158-
159-
#### `bundle-npm-artifacts-mode`
160-
161-
Runs a steps that bundle artifacts so that a single NPM tarball that contains
162-
binaries built for different platforms. This way, the app can be distributed on
163-
NPM under a single command, but will work on multiple platforms. `esy` itself
164-
uses this mode.
165-
166-
#### `postinstall-js`
167-
168-
Path to a custom `postinstall.js` file that could be placed in the final bundled
169-
NPM tarball.
170-
171-
#### `setup-esy`
172-
173-
Flag to control if esy itself should be installed by the action By default, it's
174-
true. You can disable it if you wish to install esy yourself
175-
176-
Example:
177-
178-
```
179-
steps:
180-
- run: npm i -g esy
181-
- uses: esy/github-action@v2
182-
with:
183-
source-cache-key: ${{ hashFiles('esy.lock/index.json') }}
184-
cache-key: ${{ hashFiles('esy.lock/index.json') }}
185-
setup-esy: false
186-
187-
```
188-
189-
#### `setup-esy-tarball`
190-
191-
URL to esy tarball. Must be provided together with shasum and version. Else, the
192-
action will default to latest from NPM
193-
Example: `https://registry.npmjs.org/esy/-/esy-0.7.2.tgz`
194-
195-
#### `setup-esy-shasum`
196-
197-
shasum of the tarball. Must be provided together with shasum and version. Else,
198-
the action will default to latest from NPM
199-
200-
#### `setup-esy-version`
201-
202-
version of the esy tool. Must be provided together with shasum and version.
203-
Else, the action will default to latest from NPM
204-
205-
#### `setup-esy-npm-package`
206-
207-
Alternative NPM package that contains esy. Example: `@diningphilosophers/esy`.
7+
For documentation, visit the [esy website](https://esy.sh/docs/github-actions)
2088

2099
## License
21010

0 commit comments

Comments
 (0)