Merge pull request #1624 from esy/prometheansacrifice/add-floss-funding #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- '**' | |
pull_request: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest, macos-13] | |
steps: | |
- uses: actions/setup-node@v4 | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1000 | |
fetch-tags: false # https://github.com/actions/checkout/issues/1467 | |
submodules: true | |
- run: git fetch --tags | |
name: Fetch tags manually as a workaround. See https://github.com/actions/checkout/issues/1467 | |
- run: sh ./esy-version/version.sh --reason > ./esy-version/EsyVersion.re | |
name: "Generate EsyVersion.re" | |
- uses: esy/github-action@v2-beta.8 | |
with: | |
setup-esy-npm-package: "esy" | |
setup-esy-version: "beta" | |
source-cache-key: 20240713-1 | |
cache-key: ${{ hashFiles('esy.lock/index.json') }}-20240713-1 | |
# TODO | |
# - run: node .ci/validate-release-postinstall.js | |
# name: "Validate release-postinstall.js" | |
- run: esy dune build @fmt | |
name: "Check code formatting" | |
if: ${{ runner.os == 'Darwin' }} | |
- run: esy dune runtest | |
name: "Dune runtest" | |
if: ${{ matrix.os != 'windows-latest' }} | |
- run: npm i | |
name: 'npm install for test:e2e' | |
- run: esy b dune runtest | |
name: "Dune runtest" | |
if: ${{ matrix.os == 'windows-latest' }} | |
- run: 'node ./node_modules/jest-cli/bin/jest.js' | |
name: 'test:e2e' | |
- uses: esy/github-action@v2-beta.8 | |
if: ${{ runner.os != 'Linux' }} | |
id: prepare-npm-artifacts | |
with: | |
source-cache-key: 20240713-1 | |
cache-key: ${{ hashFiles('esy.lock/index.json') }}-20240713-1 | |
prepare-npm-artifacts-mode: true | |
static-build: | |
runs-on: ubuntu-latest | |
services: | |
registry: | |
image: registry:2 | |
ports: | |
- 5000:5000 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1000 | |
fetch-tags: false # https://github.com/actions/checkout/issues/1467 | |
submodules: true | |
- run: git fetch --tags | |
name: Fetch tags manually as a workaround. See https://github.com/actions/checkout/issues/1467 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- run: sh ./esy-version/version.sh --reason > ./esy-version/EsyVersion.re | |
name: "Generate EsyVersion.re" | |
- name: Set environment variable ESY_VERSION | |
run: echo "ESY_VERSION=$(sh ./esy-version/version.sh)" >> $GITHUB_OUTPUT | |
id: esy-version | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
# network=host driver-opt needed to push to local registry | |
driver-opts: network=host | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
env: | |
DOCKER_BUILD_NO_SUMMARY: true # We disable this till the github action know to filter out `esy~esy~6ELZT5.dockerbuild` | |
with: | |
context: "." | |
file: ./dockerfiles/alpine.Dockerfile | |
load: true | |
push: true | |
tags: | | |
localhost:5000/esydev/esy:nightly-alpine-latest | |
localhost:5000/esydev/esy:nightly-alpine | |
localhost:5000/esydev/esy:${{ steps.esy-version.outputs.ESY_VERSION }} | |
- run: | | |
./scripts/docker.sh run-container --image localhost:5000/esydev/esy | |
./scripts/docker.sh cp --image localhost:5000/esydev/esy --host-release-path "_container_release" | |
name: "Copy esy artifacts from /usr/local/ in the container" | |
- run: | | |
tar czf npm-tarball.tgz _container_release | |
mv npm-tarball.tgz _container_release | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: esy-npm-release-linux-x64-static | |
path: _container_release/ | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
env: | |
DOCKER_BUILD_NO_SUMMARY: true # We disable this till the github action know to filter out `esy~esy~6ELZT5.dockerbuild` | |
with: | |
context: "." | |
file: ./dockerfiles/alpine.Dockerfile | |
load: true | |
push: true | |
tags: | | |
esydev/esy:nightly-alpine-latest | |
esydev/esy:nightly-alpine | |
esydev/esy:${{ steps.esy-version.outputs.ESY_VERSION }} | |
bundle: | |
permissions: | |
contents: write | |
needs: | |
- build | |
- static-build | |
runs-on: macos-latest | |
steps: | |
- uses: actions/setup-node@v4 | |
with: | |
registry-url: 'https://registry.npmjs.org' | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 100 | |
fetch-tags: false # https://github.com/actions/checkout/issues/1467 | |
submodules: true | |
- run: git fetch --tags | |
name: Fetch tags manually as a workaround. See https://github.com/actions/checkout/issues/1467 | |
- uses: esy/github-action@v2-beta.8 | |
with: | |
source-cache-key: 20240713-1 | |
cache-key: ${{ hashFiles('esy.lock/index.json') }}-20240713-1 | |
bundle-npm-artifacts-mode: true | |
postinstall-js: .ci/gha-release-postinstall.js | |
- name: Create tarball | |
run: tar cf npm-release.tgz ./_npm-release | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: npm-release.tgz | |
- name: Publish to NPM registry | |
working-directory: _npm-release | |
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') | |
run: npm publish --tag=dev --access=public . | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |