swc/.github/workflows/publish.yml
2020-09-07 12:45:11 +09:00

116 lines
2.5 KiB
YAML

name: Publish
on:
create:
tags:
- v*
# on: [push, pull_request]
env:
CARGO_INCREMENTAL: 0
CI: '1'
DEBUG: 'napi:*'
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
name: Build - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: 12
- name: Cache
uses: actions/cache@v2
with:
path: |
~/.cargo/
**/target/
key: ${{ runner.os }}-publish-integration
- name: Set platform name
run: |
export NODE_PLATFORM_NAME=$(node -e "console.log(require('os').platform())")
echo "::set-env name=PLATFORM_NAME::$NODE_PLATFORM_NAME"
shell: bash
- name: Install llvm
if: matrix.os == 'windows-latest'
run: choco install -y llvm
- name: Set llvm path
if: matrix.os == 'windows-latest'
uses: allenevans/set-env@v1.0.0
with:
LIBCLANG_PATH: 'C:\\Program Files\\LLVM\\bin'
- name: Install node dependencies
run: npm i
- name: Build
if: matrix.os != 'macos-latest'
shell: bash
run: npm run build
- name: Build
if: matrix.os == 'macos-latest'
shell: bash
run: npm run build
env:
MACOSX_DEPLOYMENT_TARGET: '10.13'
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: bindings
path: swc.${{ env.PLATFORM_NAME }}.node
- name: List packages
run: ls -R ./scripts/npm/
shell: bash
- name: Test bindings
run: npm test
publish:
name: npm
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: 12
# Do not cache node_modules, or yarn workspace links broken
- name: Install dependencies
run: npm i
- name: Download all artifacts
uses: actions/download-artifact@v2
with:
path: artifacts
- name: List binaries
run: ls -R artifacts
shell: bash
- name: Move binaries
shell: bash
run: npm run artifacts
- uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}