Skip to content

Commit

Permalink
NPM Publish (Chia-Network#335)
Browse files Browse the repository at this point in the history
* Use native job cancellation

* Add start to js bindings workflow

* Get the version info for a tag and replace in package.json

* Add/update setup-emsdk action

* Update artifact dir

* Set NPM TOKEN in the publish step

* Remove upload artifacts

* Fix dir

* publish packages as public

* Actually use npm token

* Fix cleanup file location
  • Loading branch information
cmmarslender authored and ogabrielides committed Sep 5, 2022
1 parent 1beb1f1 commit 9c1d0f3
Show file tree
Hide file tree
Showing 6 changed files with 180 additions and 7 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/build-aarch64.yml
Expand Up @@ -2,6 +2,11 @@ name: Build ARM64 wheel

on: [push, pull_request]

concurrency:
# SHA is added to the end if on `main` to let all main workflows run
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main') && github.sha || '' }}
cancel-in-progress: true

jobs:
build_wheels:
name: Build wheel on ${{ matrix.os }}
Expand All @@ -19,7 +24,7 @@ jobs:
access_token: ${{ github.token }}

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/build-m1-wheel.yml
Expand Up @@ -2,6 +2,11 @@ name: Build M1 Wheels

on: [push, pull_request]

concurrency:
# SHA is added to the end if on `main` to let all main workflows run
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main') && github.sha || '' }}
cancel-in-progress: true

jobs:
build_wheels:
name: Build wheel on Mac M1
Expand All @@ -17,7 +22,7 @@ jobs:
access_token: ${{ github.token }}

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/build-test.yaml
Expand Up @@ -2,6 +2,11 @@ name: Build and Test C++, Javascript, and Python

on: [push, pull_request]

concurrency:
# SHA is added to the end if on `main` to let all main workflows run
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main') && github.sha || '' }}
cancel-in-progress: true

jobs:
build_wheels:
name: Build and Test on ${{ matrix.os }} CPython ${{ matrix.python }}
Expand All @@ -20,7 +25,7 @@ jobs:
access_token: ${{ github.token }}

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- uses: actions/setup-python@v2
name: Install Python
Expand Down Expand Up @@ -62,7 +67,7 @@ jobs:
python python-impl/impl-test.py
- name: Install emsdk
uses: mymindstorm/setup-emsdk@v9
uses: mymindstorm/setup-emsdk@v11

- name: Test javascript bindings
run: |
Expand Down
95 changes: 94 additions & 1 deletion .github/workflows/build-wheels.yml
Expand Up @@ -9,7 +9,99 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
os:
- name: macOS
matrix: macos
runs-on:
arm: [macOS, ARM64]
intel: [macos-latest]
cibw-archs-macos:
arm: arm64
intel: x86_64
- name: Ubuntu
matrix: ubuntu
runs-on:
arm: [Linux, ARM64]
intel: [ubuntu-latest]
- name: Windows
matrix: windows
runs-on:
intel: [windows-latest]
python:
- major-dot-minor: '3.7'
cibw-build: 'cp37-*'
manylinux:
arch: manylinux2014
intel: manylinux2010
matrix: '3.7'
- major-dot-minor: '3.8'
cibw-build: 'cp38-*'
manylinux:
arch: manylinux2014
intel: manylinux2010
matrix: '3.8'
- major-dot-minor: '3.9'
cibw-build: 'cp39-*'
manylinux:
arch: manylinux2014
intel: manylinux2010
matrix: '3.9'
- major-dot-minor: '3.10'
cibw-build: 'cp310-*'
manylinux:
arch: manylinux2014
intel: manylinux2010
matrix: '3.10'
- major-dot-minor: '3.11'
cibw-build: 'cp311-*'
manylinux:
arch: manylinux2014
intel: manylinux2014
matrix: '3.11'
arch:
- name: ARM
matrix: arm
- name: Intel
matrix: intel
exclude:
# Only partial entries are required here by GitHub Actions so generally I
# only specify the `matrix:` entry. The super linter complains so for now
# all entries are included to avoid that. Reported at
# https://github.com/github/super-linter/issues/3016
- os:
name: Windows
matrix: windows
runs-on:
intel: [windows-latest]
arch:
name: ARM
matrix: arm
- os:
name: macOS
matrix: macos
runs-on:
arm: [macOS, ARM64]
intel: [macos-latest]
python:
major-dot-minor: '3.7'
cibw-build: 'cp37-*'
matrix: '3.7'
arch:
name: ARM
matrix: arm
- os:
name: macOS
matrix: macos
runs-on:
arm: [macOS, ARM64]
intel: [macos-latest]
python:
major-dot-minor: '3.8'
cibw-build: 'cp38-*'
matrix: '3.8'
arch:
name: ARM
matrix: arm

steps:
- name: Cancel previous runs on the same branch
Expand Down Expand Up @@ -50,6 +142,7 @@ jobs:
with:
output-dir: dist
env:
CIBW_PRERELEASE_PYTHONS: True
CIBW_BUILD_VERBOSITY_MACOS: 0
CIBW_BUILD_VERBOSITY_LINUX: 0
CIBW_BUILD_VERBOSITY_WINDOWS: 0
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/js-bindings.yml
@@ -0,0 +1,60 @@
name: Build & Publish JS Bindings

on:
push:
branches:
- main
tags:
- '**'
pull_request:
branches:
- '**'

concurrency:
# SHA is added to the end if on `main` to let all main workflows run
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main') && github.sha || '' }}
cancel-in-progress: true

jobs:
js_bindings:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-node@v3
with:
node-version: 16

- name: Install emsdk
uses: mymindstorm/setup-emsdk@v11

- name: Get the version
id: version_info
run: echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}

- name: Update version in package.json
if: startsWith(github.ref, 'refs/tags/')
working-directory: ${{ github.workspace }}/js-bindings
env:
SOURCE_TAG: ${{ steps.version_info.outputs.SOURCE_TAG }}
run: |
jq --arg VER "$SOURCE_TAG" '.version=$VER' package.json > temp.json && mv temp.json package.json
- name: Build JS
run: ./js_build.sh

- name: Publish
if: startsWith(github.ref, 'refs/tags/')
working-directory: ${{ github.workspace }}/js_build/js-bindings
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
npm publish --access public
- name: Cleanup
if: always()
run:
rm ${{ github.workspace }}/js_build/js-bindings/.npmrc || true
9 changes: 7 additions & 2 deletions .github/workflows/relic-nightly.yml
Expand Up @@ -5,6 +5,11 @@ on:
- cron: "0 11 * * *"
workflow_dispatch:

concurrency:
# SHA is added to the end if on `main` to let all main workflows run
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main') && github.sha || '' }}
cancel-in-progress: true

jobs:
build_wheels:
name: Build and Test with Relic Nightly
Expand All @@ -22,7 +27,7 @@ jobs:
access_token: ${{ github.token }}

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Ubuntu build C++ and test Relic at origin/main
if: startsWith(matrix.os, 'ubuntu')
Expand Down Expand Up @@ -69,7 +74,7 @@ jobs:
python python-impl/impl-test.py
- name: Install emsdk
uses: mymindstorm/setup-emsdk@v9
uses: mymindstorm/setup-emsdk@v11

- name: Test javascript bindings
run: |
Expand Down

0 comments on commit 9c1d0f3

Please sign in to comment.