Update README.md #341
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: CI | |
on: [push] | |
jobs: | |
build: | |
name: Built and test | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js 16.x | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 16.x | |
- name: Restore global node modules cache | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
uses: actions/cache@v1 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Install esy | |
run: npm install -g [email protected] | |
- name: Restore esy source cache | |
id: esy-cache | |
uses: actions/cache@v2 | |
with: | |
path: ~/.esy/source | |
key: source-${{ matrix.os }}-${{ hashFiles('**/index.json') }} | |
- name: Install | |
run: esy install | |
- name: Print esy cache | |
id: print_esy_cache | |
run: node scripts/print-esy-cache.js | |
- name: Try to restore dependencies cache | |
id: deps-cache | |
uses: actions/cache@v2 | |
with: | |
path: ${{ steps.print_esy_cache.outputs.esy_cache }} | |
key: deps-${{ matrix.os }}-${{ hashFiles('**/index.json') }} | |
restore-keys: deps-${{ matrix.os }}- | |
- name: Build dependencies | |
if: steps.deps-cache.outputs.cache-hit != 'true' | |
run: esy build-dependencies | |
- name: Build | |
run: esy build | |
- name: Test | |
if: ${{ matrix.os != 'windows-latest' }} | |
run: | | |
rm test/__snapshots__/.gitkeep | |
esy dune runtest --instrument-with bisect_ppx --force | |
esy bisect-ppx-report send-to Coveralls | |
env: | |
BISECT_SILENT: "ERR" | |
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} | |
PULL_REQUEST_NUMBER: ${{ github.event.number }} | |
- name: Web build | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
run: | | |
esy b dune build | |
cd website | |
npm ci | |
npm run build-production | |
- name: Deploy to prod | |
if: ${{ matrix.os == 'ubuntu-latest' && github.event_name != 'pull_request' }} | |
working-directory: ./website | |
env: | |
SITE_ID: ${{ secrets.SITE_ID }} | |
AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
run: | |
npx netlify deploy --site $SITE_ID --auth $AUTH_TOKEN --prod --dir=build | |
- name: Deploy preview | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
working-directory: ./website | |
env: | |
SITE_ID: ${{ secrets.SITE_ID }} | |
AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
run: | |
npx netlify deploy --site $SITE_ID --auth $AUTH_TOKEN --dir=build | |
- name: Upload artifacts for ${{ matrix.os }} | |
uses: actions/upload-artifact@master | |
with: | |
name: ${{ matrix.os }}-artifact | |
path: _build/default/bin/Bin.exe | |
- name: Upload JavaScript artifacts for NPM | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
uses: actions/upload-artifact@master | |
with: | |
name: bundled | |
path: _build/default/js/Js.bc.js | |
# Cleanup build cache if dependencies have changed | |
- name: Clean build cache | |
if: steps.deps-cache.outputs.cache-hit != 'true' | |
run: esy cleanup . | |
publish: | |
needs: build | |
name: Publish | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js 12.x | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 12.x | |
- name: Generate NPM package and release | |
run: node scripts/make-npm-release.js | |
- name: Download JavaScript artifact | |
if: ${{ success() }} | |
uses: actions/download-artifact@master | |
with: | |
name: bundled | |
path: _release/bundled | |
- name: Download linux artifacts | |
if: ${{ success() }} | |
uses: actions/download-artifact@master | |
with: | |
name: ubuntu-latest-artifact | |
path: _release/platform-linux-x64 | |
- name: Download macOS artifacts | |
if: ${{ success() }} | |
uses: actions/download-artifact@master | |
with: | |
name: macos-latest-artifact | |
path: _release/platform-darwin-x64 | |
- name: Download windows artifacts | |
uses: actions/download-artifact@master | |
with: | |
name: windows-latest-artifact | |
path: _release/platform-windows-x64 | |
- name: Publish query-json from linux artifcats | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
run: | | |
cp _release/platform-linux-x64/Bin.exe ./query-json | |
chmod +x query-json | |
- name: Create archives for Github release | |
run: | | |
cd _release/platform-darwin-x64 | |
mv Bin.exe query-json | |
zip -r ../../query-json-darwin-x64.zip . | |
cd ../.. | |
cd _release/platform-linux-x64 | |
mv Bin.exe query-json | |
zip -r ../../query-json-linux-x64.zip . | |
cd ../.. | |
cd _release/platform-windows-x64 | |
mv Bin.exe query-json | |
zip -r ../../query-json-windows-x64.zip . | |
cd ../.. | |
- name: End to end Test (Linux) | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
run: npx bats ./e2e/test.sh | |
env: | |
IS_CI: true | |
- name: End to end Test (Windows) | |
if: ${{ matrix.os == 'windows-latest' }} | |
run: sh -c 'npx bats ./e2e/test.sh' \"$(pwd)/node_modules/bats/bin/bats\" | |
env: | |
IS_CI: true | |
- name: Check if should be published | |
if: ${{ success() && github.event_name != 'pull_request' }} | |
id: newVersion | |
run: | | |
REMOTE=$(npm view @davesnx/query-json version); | |
CURRENT=$(jq -r '.version' esy.json); | |
if [ "$REMOTE" != "$CURRENT" ] | |
then | |
echo "::set-output name=shouldPublish::true"; | |
else | |
echo "::set-output name=shouldPublish::false"; | |
fi | |
- name: Publish | |
if: ${{ success() && github.event_name != 'pull_request' && steps.newVersion.outputs.shouldPublish == 'true' }} | |
run: | | |
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN | |
npm config set scope "@davesnx" | |
npm publish --access public | |
working-directory: ./_release | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} | |
- name: Print short SHA | |
id: sha | |
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | |
- name: Publish Prerelease | |
if: ${{ github.event_name == 'pull_request' }} | |
run: | | |
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN | |
npm config set scope "@davesnx" | |
npm version prerelease -preid ${{ steps.sha.outputs.sha_short }} -no-git-tag-version | |
npm publish --tag=dev --access public | |
working-directory: ./_release | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} | |
- name: Create Github release | |
if: ${{ success() && steps.newVersion.outputs.shouldPublish == 'true' }} | |
id: create_release | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.sha.outputs.sha_short }} | |
release_name: Release ${{ steps.sha.outputs.sha_short }} | |
draft: false | |
prerelease: true | |
- name: Upload query-json-darwin-x64.zip to Github release | |
if: ${{ success() && steps.newVersion.outputs.shouldPublish == 'true' }} | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: query-json-darwin-x64.zip | |
asset_name: query-json-darwin-x64.zip | |
asset_content_type: application/gzip | |
- name: Upload query-json-linux-x64.zip to Github release | |
if: ${{ success() && steps.newVersion.outputs.shouldPublish == 'true' }} | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: query-json-linux-x64.zip | |
asset_name: query-json-linux-x64.zip | |
asset_content_type: application/gzip | |
- name: Upload query-json-windows-x64.zip to Github release | |
if: ${{ success() && steps.newVersion.outputs.shouldPublish == 'true' }} | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: query-json-windows-x64.zip | |
asset_name: query-json-windows-x64.zip | |
asset_content_type: application/gzip |