Expose reader positions (#465) #112
Workflow file for this run
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: package and publish to pypi and npm | |
on: | |
push: | |
tags: | |
- '*' | |
jobs: | |
github-release: | |
name: Create Github release page | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.release.tag_name }} | |
- name: Set release version | |
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | |
- name: Create Github release page | |
# Create the release page first or the nodejs artifacts upload will fail | |
run: gh release create ${{ env.RELEASE_VERSION }} --draft --notes "Auto created by tagPublish workflow." | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
nodejs-npm: | |
name: nodejs-npm | |
runs-on: ubuntu-latest | |
# Prevent a situation where native build fails and a npm package is uploaded. | |
needs: [nodejs-github-native] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.release.tag_name }} | |
- name: Set release version | |
# Set release version env in all three os, the commented command only works in linux and mac. | |
run: python3 -c "import os; tag = os.environ['GITHUB_REF'].split('/')[-1]; f = open(os.environ['GITHUB_ENV'], 'a'); f.write('RELEASE_VERSION='+tag); f.close();" | |
# run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: '16' | |
# Url is important! This makes NODE_AUTH_TOKEN accessible to npm publish. | |
registry-url: 'https://registry.npmjs.org' | |
- name: Install modules | |
working-directory: ./nodejs | |
run: npm i | |
- name: Tweak package.json | |
working-directory: ./nodejs | |
# This will update the package version to tag version and | |
# add an install script in package.json so users who `npm i` this package | |
# will trigger the node-pre-gyp to pull the os and arch specific binary. | |
run: python3 -c "import os; import json; p = json.load(open('package.json')); p['scripts']['install'] = 'node-pre-gyp install'; p['version'] = os.environ['RELEASE_VERSION']; json.dump(p, open('package.json', 'w'), indent=2, ensure_ascii=False);" | |
- name: Compile for esm and commonjs | |
working-directory: ./nodejs | |
run: npm run release-js | |
- name: Publish to npm | |
working-directory: ./nodejs | |
# `--access public` is used to publish to my account's scope. | |
run: npm publish --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
nodejs-github-native: | |
name: nodejs-${{ matrix.node_version }}-${{ matrix.system.target }}-${{ matrix.system.os }} | |
runs-on: ${{ matrix.system.os }} | |
# Prevent a situation where artifacts are uploaded to a non-existing release. | |
needs: [github-release] | |
strategy: | |
fail-fast: false | |
matrix: | |
node_version: | |
- 16 | |
- 18 | |
- 20 | |
system: | |
- os: macos-11 | |
target: x86_64-apple-darwin | |
- os: ubuntu-20.04 | |
target: x86_64-unknown-linux-gnu | |
- os: windows-2022 | |
target: x86_64-pc-windows-msvc | |
# Would like to have aarch64 support, but actions does not provide these yet. | |
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.release.tag_name }} | |
- name: Set release version | |
# Set release version env in all three os, the commented command only works in linux and mac. | |
run: python3 -c "import os; tag = os.environ['GITHUB_REF'].split('/')[-1]; f = open(os.environ['GITHUB_ENV'], 'a'); f.write('RELEASE_VERSION='+tag); f.close();" | |
# run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: ${{ matrix.node_version }} | |
registry-url: 'https://registry.npmjs.org' | |
- name: Install modules | |
working-directory: ./nodejs | |
run: npm i | |
- name: Tweak package.json | |
working-directory: ./nodejs | |
# This will update the package version to tag version. So artifacts uploaded to Github release will be named correctly. | |
run: python3 -c "import os; import json; p = json.load(open('package.json')); p['version'] = os.environ['RELEASE_VERSION']; json.dump(p, open('package.json', 'w'), indent=2, ensure_ascii=False);" | |
- name: Cache toolchain | |
uses: actions/cache@v1 | |
with: | |
path: /usr/share/rust/.cargo | |
key: ${{ runner.os }}-rustup | |
- name: Cache cargo registry | |
uses: actions/cache@v1 | |
with: | |
path: ~/.cargo/registry | |
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }} | |
- name: Cache cargo index | |
uses: actions/cache@v1 | |
with: | |
path: ~/.cargo/git | |
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.toml') }} | |
- name: Cache cargo build | |
uses: actions/cache@v1 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.toml') }} | |
- uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
target: ${{ matrix.system.target }} | |
override: true | |
- name: Build native | |
working-directory: ./nodejs | |
run: npm run release-native | |
- name: Package the asset | |
working-directory: ./nodejs | |
# This will make a node-pre-gyp package. | |
run: npx node-pre-gyp package | |
- name: Upload to Github releases | |
working-directory: ./nodejs | |
# Use bash, even on Windows to make find available | |
shell: bash | |
# A release need to be created before upload | |
run: gh release upload ${{ env.RELEASE_VERSION }} "$(find ./build -name *.tar.gz)" --clobber | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |