Skip to content

Commit 970576e

Browse files
authored
πŸš€ Add release action to GitHub CI (#519)
* πŸ“– Add python-specific readme * πŸš΄β€β™€οΈ Add release action * ✨ Python code formatting * πŸ”Ό Swap update command based on myst language env var * 🐍 Bump python version with changeset version bump
1 parent a138bb9 commit 970576e

File tree

9 files changed

+116
-27
lines changed

9 files changed

+116
-27
lines changed

β€Ž.github/workflows/release.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Release
2+
3+
on: workflow_dispatch
4+
5+
concurrency: ${{ github.workflow }}-${{ github.ref }}
6+
7+
jobs:
8+
release:
9+
name: Release
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout Repo
13+
uses: actions/checkout@v3
14+
with:
15+
fetch-depth: 2
16+
submodules: recursive
17+
- name: Install libxml
18+
run: |
19+
sudo apt-get update
20+
sudo apt-get install -y libxml2-utils
21+
- name: Setup Node.js 18.x
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: 18.x
25+
- name: Install node deps
26+
run: npm install
27+
- name: Run build
28+
run: npm run build
29+
- name: Run tests
30+
run: npm run test
31+
- name: Version bump and publish to npm
32+
id: changesets
33+
uses: changesets/action@v1
34+
with:
35+
version: npm run version
36+
publish: npm run publish
37+
commit: πŸš€ Release
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
41+
- name: Publish to PyPI
42+
if: steps.changesets.outputs.published == 'true'
43+
run: |
44+
cd packages/mystmd-py
45+
bash scripts/pypi-deploy.sh

β€Žpackage.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"test": "turbo run test",
1414
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
1515
"changeset": "changeset",
16-
"version": "changeset version && npm install",
16+
"version": "changeset version && npm install && cd packages/mystmd-py && bash scripts/bump-version.sh",
1717
"publish": "npm run clean && npm run build -- --force && changeset publish && git push --follow-tags"
1818
},
1919
"devDependencies": {

β€Žpackages/myst-cli/src/session/session.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import version from '../version.js';
1818

1919
const CONFIG_FILES = ['myst.yml'];
2020
const API_URL = 'https://api.mystmd.org';
21+
const NPM_COMMAND = 'npm i -g mystmd@latest';
22+
const PIP_COMMAND = 'pip install -U mystmd';
2123

2224
export function logUpdateAvailable({
2325
current,
@@ -81,7 +83,7 @@ export class Session implements ISession {
8183
logUpdateAvailable({
8284
current: version,
8385
latest: this._latestVersion,
84-
upgradeCommand: 'npm i -g mystmd@latest',
86+
upgradeCommand: process.env.MYST_LANG === 'PYTHON' ? PIP_COMMAND : NPM_COMMAND,
8587
twitter: 'MystMarkdown',
8688
}),
8789
);

β€Žpackages/mystmd-py/.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
src/version.ts
22
*.egg-info
33
dist
4-
mystmd_py/myst.cjs
5-
README.md
4+
mystmd_py/myst.cjs

β€Žpackages/mystmd-py/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# MyST Markdown Command Line Interface, `mystmd`
2+
3+
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/executablebooks/mystmd/blob/main/LICENSE)
4+
![CI](https://github.com/executablebooks/mystmd/workflows/CI/badge.svg)
5+
6+
`mystmd` is a set of open-source, community-driven tools designed for scientific communication, including a powerful authoring framework that supports blogs, online books, scientific papers, reports and journals articles.
7+
8+
> **Note**
9+
> The `mystmd` project is in **beta**. It is being used to explore a full MyST implementation and will change significantly and rapidly.
10+
> The project is being developed by a small team of people on the Executable Books Project, and may make rapid decisions without fully public/inclusive discussion.
11+
> We will continue to update this documentation as the project stabilizes.
12+
13+
## Overview
14+
15+
The `mystmd` project provides a command line tool (`mystmd`) for working with MyST Markdown projects.
16+
17+
- Provides functionality for cross-referencing, external structured links, and scientific citations
18+
- Translate and render MyST Markdown into:
19+
- HTML for static websites, and modern React for interactive websites (like this website!)
20+
- PDFs and LaTeX documents, with specific templates for over 400 journals
21+
- Microsoft Word export
22+
- Parse MyST into a standardized AST, that follows the MyST Markdown Spec
23+
24+
See the [documentation](https://mystmd.org/guide).
25+
26+
## Get Started
27+
28+
The MyST Markdown CLI is available through PyPI:
29+
30+
```bash
31+
pip install mystmd
32+
myst init
33+
myst build my-doc.md --tex
34+
```
35+
36+
and Conda:
37+
38+
```bash
39+
conda config --add channels conda-forge
40+
conda config --set channel_priority strict
41+
conda install mystmd
42+
myst init
43+
myst build my-doc.md --tex
44+
```

β€Žpackages/mystmd-py/mystmd_py/main.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,42 @@
1+
import os
12
import pathlib
23
import shutil
34
import subprocess
45
import sys
56

67

78
NODE_LOCATION = (
8-
shutil.which("node") or
9-
shutil.which("node.exe") or
10-
shutil.which("node.cmd")
11-
)
12-
PATH_TO_BIN_JS = str(
13-
(
14-
pathlib.Path(__file__).parent / 'myst.cjs'
15-
).resolve()
9+
shutil.which("node") or shutil.which("node.exe") or shutil.which("node.cmd")
1610
)
11+
PATH_TO_BIN_JS = str((pathlib.Path(__file__).parent / "myst.cjs").resolve())
1712

1813

1914
def main():
2015
if not NODE_LOCATION:
2116
sys.exit(
22-
'You must install node >=16 to run MyST\n\n'
23-
'We recommend installing the latest LTS release, using your preferred package manager\n'
24-
'or following instructions here: https://nodejs.org/en/download'
17+
"You must install node >=16 to run MyST\n\n"
18+
"We recommend installing the latest LTS release, using your preferred package manager\n"
19+
"or following instructions here: https://nodejs.org/en/download"
2520
)
2621
node = str(pathlib.Path(NODE_LOCATION).resolve())
2722
version_proc = subprocess.Popen(
28-
[node, '-v'],
29-
stdin=subprocess.PIPE, stdout=subprocess.PIPE
23+
[node, "-v"], stdin=subprocess.PIPE, stdout=subprocess.PIPE
3024
)
3125
version_proc.wait()
3226
version = version_proc.communicate()[0].decode()
3327
try:
34-
['16', '18', '20'].index(version[1:3])
28+
["16", "18", "20"].index(version[1:3])
3529
except:
3630
sys.exit(
37-
f'MyST requires node 16, 18, or 20; you are running node {version[1:3]}.\n\n'
38-
'Please update to the latest LTS release, using your preferred package manager\n'
39-
'or following instructions here: https://nodejs.org/en/download'
31+
f"MyST requires node 16, 18, or 20; you are running node {version[1:3]}.\n\n"
32+
"Please update to the latest LTS release, using your preferred package manager\n"
33+
"or following instructions here: https://nodejs.org/en/download"
4034
)
4135
myst_proc = subprocess.Popen(
4236
[node, PATH_TO_BIN_JS, *sys.argv[1:]],
43-
stdin=sys.stdin, stdout=sys.stdout
37+
stdin=sys.stdin,
38+
stdout=sys.stdout,
39+
env={**os.environ, "MYST_LANG": "PYTHON"},
4440
)
4541
sys.exit(myst_proc.wait())
4642

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
CURRENT=`awk -F'"' '/"version": ".+"/{ print $4; exit; }' ../mystmd/package.json`
3+
PREVIOUS=`awk -F' ' '/version = .+/{ print $3; exit; }' setup.cfg`
4+
echo "bumping mystmd-py: $PREVIOUS => $CURRENT"
5+
sed -i "" "s/$PREVIOUS/$CURRENT/" setup.cfg
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#!/bin/bash
2-
cp ../mystmd/README.md .
2+
bash ./scripts/bump-version.sh
33
cp ../mystmd/dist/myst.cjs mystmd_py
4-
CURRENT=`awk -F'"' '/"version": ".+"/{ print $4; exit; }' ../mystmd/package.json`
5-
PREVIOUS=`awk -F' ' '/version = .+/{ print $3; exit; }' setup.cfg`
6-
sed -i "" "s/$PREVIOUS/$CURRENT/" setup.cfg
74
rm -rf dist
85
python -m build
96
python -m twine upload dist/*

β€Žpackages/mystmd-py/setup.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[metadata]
22
name = mystmd
3-
version = 0.0.6
3+
version = 1.1.7
44
description = Command line tools for MyST Markdown
5+
long_description = file: README.md
56
author = Franklin Koch
67
url = https://github.com/executablebooks/mystmd
78
license = MIT

0 commit comments

Comments
Β (0)