Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to support JLab 4 #61

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions .github/workflows/_build-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: build-package
on:
workflow_call:
inputs:
check-prerelease:
default: false
required: false
type: boolean
cache-package:
default: false
required: false
type: boolean
upload-package:
default: false
required: false
type: boolean

defaults:
run:
shell: bash -l {0}

jobs:
build:
name: Build mols2grid package
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get prerelease version tags
if: inputs.check-prerelease
id: prerelease-check
run: |
py_dirty_tag=$(awk '/__version__ = "[[:digit:]+]\.[[:digit:]+]\.[[:digit:]+]\-.+"/ {print $3}' ./mols2grid/_version.py)
py_is_pre=$(test -z "$py_dirty_tag" && echo "false" || echo "true")
js_version_string=$(grep '"version":' ./package.json)
js_dirty_tag=$(echo "$js_version_string" | cut -d- -f2)
js_is_pre=$(test "$js_version_string" == "$js_dirty_tag" && echo "false" || echo "true")
echo "py=$py_is_pre" >> $GITHUB_OUTPUT
echo "js=$js_is_pre" >> $GITHUB_OUTPUT

- name: Fail if prerelease is not correctly versioned
if: (inputs.check-prerelease) && !( steps.prerelease-check.outputs.py && steps.prerelease-check.outputs.js )
uses: actions/github-script@v3
with:
script: |
core.setFailed("Versions are not tagged as a prerelease")

- name: Install node
uses: actions/setup-node@v3
with:
node-version: "18.12.1"
registry-url: 'https://registry.npmjs.org/'
cache: "yarn"

- name: Install python with pip
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "pip"

- name: Install dependencies for packaging
run: |
pip install setuptools wheel build virtualenv

- name: Check python installation
run: |
which python
python --version
pip --version
pip list

- name: Build package
run: |
python -m build .

- name: List output
run: |
ls -lah dist/*

- name: Cache package
if: inputs.cache-package
uses: actions/cache/save@v3
with:
path: |
dist/mols2grid-*.whl
dist/mols2grid-*.tar.gz
key: mols2grid-${{ runner.os }}-${{ github.sha }}

- name: Expose package as artifact
if: inputs.upload-package
uses: actions/upload-artifact@v4
with:
name: mols2grid-package
path: |
dist/mols2grid-*.whl
dist/mols2grid-*.tar.gz
if-no-files-found: error
retention-days: 20
73 changes: 19 additions & 54 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,67 +12,32 @@ env:
IS_PRERELEASE: ${{ github.event_name == 'workflow_dispatch' }}

jobs:
build-n-publish:
name: Build and publish mols2grid
build:
name: Build package
uses: ./.github/workflows/_build-package.yml
with:
check-prerelease: ${{ env.IS_PRERELEASE }}

publish:
name: Publish to PyPI and NPM
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get prerelease version tags
if: env.IS_PRERELEASE == 'true'
run: |
py_dirty_tag=$(awk '/__version__ = "[[:digit:]+]\.[[:digit:]+]\.[[:digit:]+]\-.+"/ {print $3}' ./mols2grid/_version.py)
py_is_pre=$(test -z "$py_dirty_tag" && echo "false" || echo "true")
js_version_string=$(grep '"version":' ./package.json)
js_dirty_tag=$(echo "$js_version_string" | cut -d- -f2)
js_is_pre=$(test "$js_version_string" == "$js_dirty_tag" && echo "false" || echo "true")
echo "py_is_pre=$py_is_pre" >> $GITHUB_ENV
echo "js_is_pre=$js_is_pre" >> $GITHUB_ENV

- name: Fail if prerelease is not correctly versioned
if: (env.IS_PRERELEASE == 'true') && !( env.py_is_pre && env.js_is_pre )
uses: actions/github-script@v3
with:
script: |
core.setFailed("Versions are not tagged as a prerelease")

- name: Install node
uses: actions/setup-node@v3
- name: Retrieve cached package
uses: actions/cache/restore@v3
id: cache-mols2grid
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org/'
cache: "npm"
path: |
dist/mols2grid-*.whl
dist/mols2grid-*.tar.gz
key: mols2grid-${{ runner.os }}-${{ github.sha }}

- name: Install python with pip
uses: actions/setup-python@v4
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
python-version: 3.8
cache: "pip"

- name: Install dependencies for packaging
run: |
pip install setuptools wheel build virtualenv twine

- name: Check python installation
run: |
which python
python --version
pip --version
pip list

- name: Build package
run: |
python -m build .

- name: Publish the Python package
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: twine upload dist/mols2grid*.{tar.gz,whl}
password: ${{ secrets.PYPI_TOKEN }}

- name: Publish the NPM package
- name: Publish the package through NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
Loading
Loading