Skip to content

Commit

Permalink
chore: Automate npm publish
Browse files Browse the repository at this point in the history
  • Loading branch information
bergundy committed Nov 19, 2021
1 parent 2ff388c commit 4208b74
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 44 deletions.
48 changes: 4 additions & 44 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,51 +67,11 @@ jobs:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}

# Compile native bridge code and isolate extension for Windows, Mac and Linux.
# Uploads the packages as a build artifact to be tested later.
compile-binaries:
strategy:
fail-fast: true
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
# TODO: this compliation target fails
# https://github.com/temporalio/sdk-typescript/runs/4241087289?check_suite_focus=true#step:8:119
# - os: ubuntu-latest
# target: aarch64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions/setup-node@v1
with:
node-version: 16
- name: Add ${{ matrix.target }} rust target
run: rustup target add ${{ matrix.target }}
- run: npm ci
- run: npm run build
- name: Cross compile rust code
run: npx lerna run --stream build-rust -- -- --target ${{ matrix.target }}
# Restore the CLI JS only on Windows because Windows build changes the
# file attributes causing publish to think the change is uncommitted
- run: git restore packages/create-project/cli.js
if: ${{ matrix.os == 'windows-latest' }}
- run: node scripts/publish-to-verdaccio.js --registry-dir /tmp/registry
- uses: actions/upload-artifact@v2
with:
name: packages-${{ matrix.target }}
path: /tmp/registry/storage
# TODO: main
uses: temporalio/sdk-typescript/.github/workflows/compile-binaries.yml@auto-publish
with:
publishType: packages
# Tests that npm init @temporalio results in a working worker and client
# Note that the instances used here don't have the Rust toolchain installed which ensures use of prebuilt libs.
test-npm-init:
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/compile-binaries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Compile binaries
on:
workflow_call:
inputs:
publishType:
description: 'Publish either packages or only compiled Rust Core bridge'
required: true
jobs:
# Compile native bridge code for Windows, Mac and Linux.
# Uploads the packages as a build artifact to be tested later.
compile-binaries:
strategy:
fail-fast: true
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
# TODO: this compliation target fails
# https://github.com/temporalio/sdk-typescript/runs/4241087289?check_suite_focus=true#step:8:119
# - os: ubuntu-latest
# target: aarch64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions/setup-node@v1
with:
node-version: 16
- name: Add ${{ matrix.target }} rust target
run: rustup target add ${{ matrix.target }}
- run: npm ci
- run: npm run build
- name: Cross compile rust code
run: npx lerna run --stream build-rust -- -- --target ${{ matrix.target }}
# Restore the CLI JS only on Windows because Windows build changes the
# file attributes causing publish to think the change is uncommitted
- run: git restore packages/create-project/cli.js
if: ${{ matrix.os == 'windows-latest' }}
- run: node scripts/publish-to-verdaccio.js --registry-dir /tmp/registry
if: ${{ inputs.publishType == 'packages' }}
- uses: actions/upload-artifact@v2
with:
name: packages-${{ matrix.target }}
path: /tmp/registry/storage
if: ${{ input.publishType == 'packages' }}
- uses: actions/upload-artifact@v2
with:
name: compiled-bridge-${{ matrix.target }}
path: ${{ github.workspace }}/packages/core-bridge/releases/${{ matrix.target }}
34 changes: 34 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish to npm
on: workflow_dispatch
inputs:
npmTag:
description: 'npm tag to publishing to (Use either `latest` or `next`)'
required: false
default: 'next'
npmVersion:
description: 'package version to publish to npm'
required: false
default: 'prerelease'

jobs:
compile-binaries:
# TODO: main
uses: temporalio/sdk-typescript/.github/workflows/compile-binaries.yml@auto-publish
with:
publishType: core-bridge

publish:
runs-on: ubuntu-latest
needs: compile-binaries
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: actions/setup-node@v1
with:
node-version: 16
- uses: actions/download-artifact@v2
with:
path: ${{ github.workspace }}/packages/core-bridge/releases

- run: ls -l ./packages/core-bridge/releases

0 comments on commit 4208b74

Please sign in to comment.