swc/.github/workflows/publish.yml

158 lines
4.0 KiB
YAML
Raw Normal View History

2020-08-30 09:29:42 +03:00
name: Publish
on:
create:
tags:
- v*
env:
CARGO_INCREMENTAL: 0
2020-09-13 18:25:22 +03:00
CI: '1'
DEBUG: 'napi:*'
2020-08-30 09:29:42 +03:00
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
2020-09-05 11:48:22 +03:00
run: npm i
2020-08-30 09:29:42 +03:00
- name: Build
if: matrix.os != 'macos-latest'
2020-08-30 09:29:42 +03:00
shell: bash
2020-09-05 11:48:22 +03:00
run: npm run build
2020-08-30 09:29:42 +03:00
- name: Build
if: matrix.os == 'macos-latest'
shell: bash
run: npm run build
env:
2020-09-13 18:25:22 +03:00
MACOSX_DEPLOYMENT_TARGET: '10.13'
2020-08-30 09:29:42 +03:00
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: bindings
2020-09-05 11:48:22 +03:00
path: swc.${{ env.PLATFORM_NAME }}.node
2020-08-30 09:29:42 +03:00
- name: List packages
run: ls -R ./scripts/npm/
shell: bash
- name: Test bindings
2020-09-05 11:48:22 +03:00
run: npm test
2020-08-30 09:29:42 +03:00
2020-09-13 12:27:26 +03:00
build_musl:
name: stable - linux-musl - node@12
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Login to registry
run: |
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD $DOCKER_REGISTRY_URL
env:
DOCKER_REGISTRY_URL: docker.pkg.github.com
DOCKER_USERNAME: ${{ github.actor }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
- name: Pull docker image
run: |
docker pull docker.pkg.github.com/napi-rs/napi-rs/rust-nodejs-alpine:lts
docker tag docker.pkg.github.com/napi-rs/napi-rs/rust-nodejs-alpine:lts builder
2020-09-13 18:25:22 +03:00
- name: 'Install dependencies'
2020-09-13 12:27:26 +03:00
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org
2020-09-13 18:25:22 +03:00
- name: 'Build'
2020-09-13 12:27:26 +03:00
run: |
docker run --rm -v $(pwd)/.cargo:/root/.cargo -v $(pwd):/node-rs -w /node-rs builder sh -c "cargo build -p node --release"
docker run --rm -v $(pwd)/.cargo:/root/.cargo -v $(pwd):/node-rs -w /node-rs builder sh -c "./node_modules/.bin/napi build --platform --cargo-name node --musl --release -c ./package.json ./scripts/npm"
- name: List packages
run: ls -R ./scripts/npm/
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: bindings
path: scripts/npm/swc.linux-musl.node
2020-08-30 09:29:42 +03:00
publish:
name: npm
runs-on: ubuntu-latest
needs:
- build
2020-09-13 12:27:26 +03:00
- build_musl
2020-08-30 09:29:42 +03:00
steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: 12
2020-09-13 18:25:22 +03:00
- name: Set release name
run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF#refs/*/}
2020-08-30 09:29:42 +03:00
# 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:
2020-09-05 11:48:22 +03:00
path: artifacts
2020-08-30 09:29:42 +03:00
- name: List binaries
2020-09-05 11:48:22 +03:00
run: ls -R artifacts
2020-08-30 09:29:42 +03:00
shell: bash
- name: Move binaries
shell: bash
2020-09-05 11:48:22 +03:00
run: npm run artifacts
2020-08-30 09:29:42 +03:00
- name: Publish
run: |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish
env:
2020-09-05 11:48:22 +03:00
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}