-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from aeturrell/build-book-action
GitHub Actions to test, build, and release versions of the book
- Loading branch information
Showing
9 changed files
with
272 additions
and
102 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
name: release | ||
|
||
permissions: | ||
contents: write | ||
pages: write | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
release: | ||
name: release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: install mamba | ||
uses: mamba-org/setup-micromamba@v2 | ||
with: | ||
environment-file: environment.yml | ||
init-shell: >- | ||
bash | ||
cache-environment: true | ||
post-cleanup: 'all' | ||
|
||
- name: set timezone | ||
run: | | ||
TZ="Europe/London" && | ||
sudo ln -snf /usr/share/zoneinfo/$TZ /etc/localtime | ||
- name: install linux deps | ||
run: | | ||
sudo apt-get -y install openssl graphviz nano texlive graphviz-dev unzip | ||
- name: install special fonts | ||
run: | | ||
mkdir -p /usr/share/fonts/truetype/ && | ||
wget https://www.wfonts.com/download/data/2015/10/08/varta/varta.zip && | ||
unzip varta.zip && | ||
install -m644 *.ttf /usr/share/fonts/truetype/ && | ||
rm *.ttf | ||
rm varta.zip | ||
- name: install text models | ||
run: | | ||
micromamba run -n codeforecon python3 -m spacy download en_core_web_sm && | ||
micromamba run -n codeforecon python3 -m nltk.downloader all | ||
- name: special fix for todoify | ||
run: | | ||
sed -i '90 s/^/#/' /home/runner/micromamba/envs/codeforecon/lib/python3.10/site-packages/mdit_py_plugins/tasklists/__init__.py | ||
# Issue with pymc needing np<2.0 and skimpy needing >2.0, so pip install of latter causes upgrade to np | ||
- name: special fix for numpy | ||
run: | | ||
micromamba run -n codeforecon pip install --force-reinstall -v "numpy==1.26" | ||
- name: Monkey patch for binsreg # sets np.math = math | ||
run: | | ||
sed -i '/^import\|^from.*import/ { :a; n; /^import\|^from.*import/! { x; s/.*//; x; ba; }; }; a\import math\nimport numpy as np\nnp.math = math' ~/micromamba/envs/codeforecon/lib/python3.10/site-packages/binsreg/funs.py | ||
- name: git config # Needed as git config --get user.name is used in one example | ||
run: | | ||
git config user.name "$(git log -n 1 --pretty=format:%an)" && | ||
git config user.email "$(git log -n 1 --pretty=format:%ae)" | ||
- name: build the book | ||
run: | | ||
micromamba run -n codeforecon jupyter-book build . --verbose | ||
- name: Check if there is a parent commit | ||
id: check-parent-commit | ||
run: | | ||
echo "::set-output name=sha::$(git rev-parse --verify --quiet HEAD^)" | ||
- name: Detect and tag new version | ||
id: check-version | ||
if: steps.check-parent-commit.outputs.sha | ||
uses: salsify/[email protected] | ||
with: | ||
version-command: | | ||
micromamba run -n codeforecon toml get --toml-path=pyproject.toml project.version | ||
- name: Bump version for developmental release | ||
if: "! steps.check-version.outputs.tag" | ||
run: | | ||
micromamba run -n codeforecon python version_bumper.py && | ||
version=$(micromamba run -n codeforecon toml get --toml-path=pyproject.toml project.version) && | ||
micromamba run -n codeforecon toml set --toml-path=pyproject.toml project.version $version.dev.$(date +%s) | ||
- name: Publish | ||
if: steps.check-version.outputs.tag | ||
run: ghp-import -n -p -f _build/html | ||
|
||
- name: Publish the release notes | ||
uses: release-drafter/[email protected] | ||
with: | ||
publish: ${{ steps.check-version.outputs.tag != '' }} | ||
tag: ${{ steps.check-version.outputs.tag }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Success | ||
if: steps.check-version.outputs.tag | ||
run: | | ||
echo "Success in releasing a new version of Coding for Economists!" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: tests | ||
|
||
on: | ||
- pull_request | ||
- push | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10.6' | ||
- uses: pre-commit/[email protected] | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: install mamba | ||
uses: mamba-org/setup-micromamba@v2 | ||
with: | ||
environment-file: environment.yml | ||
init-shell: >- | ||
bash | ||
cache-environment: true | ||
post-cleanup: 'all' | ||
|
||
- name: set timezone | ||
run: | | ||
TZ="Europe/London" && | ||
sudo ln -snf /usr/share/zoneinfo/$TZ /etc/localtime | ||
- name: install linux deps | ||
run: | | ||
sudo apt-get -y install openssl graphviz nano texlive graphviz-dev unzip | ||
- name: install special fonts | ||
run: | | ||
mkdir -p /usr/share/fonts/truetype/ && | ||
wget https://www.wfonts.com/download/data/2015/10/08/varta/varta.zip && | ||
unzip varta.zip && | ||
install -m644 *.ttf /usr/share/fonts/truetype/ && | ||
rm *.ttf | ||
rm varta.zip | ||
- name: install text models | ||
run: | | ||
micromamba run -n codeforecon python3 -m spacy download en_core_web_sm && | ||
micromamba run -n codeforecon python3 -m nltk.downloader all | ||
- name: special fix for todoify | ||
run: | | ||
sed -i '90 s/^/#/' /home/runner/micromamba/envs/codeforecon/lib/python3.10/site-packages/mdit_py_plugins/tasklists/__init__.py | ||
# Issue with pymc needing np<2.0 and skimpy needing >2.0, so pip install of latter causes upgrade to np | ||
- name: special fix for numpy | ||
run: | | ||
micromamba run -n codeforecon pip install --force-reinstall -v "numpy==1.26" | ||
- name: Monkey patch for binsreg # sets np.math = math | ||
run: | | ||
sed -i '/^import\|^from.*import/ { :a; n; /^import\|^from.*import/! { x; s/.*//; x; ba; }; }; a\import math\nimport numpy as np\nnp.math = math' ~/micromamba/envs/codeforecon/lib/python3.10/site-packages/binsreg/funs.py | ||
- name: git config # Needed as git config --get user.name is used in one example | ||
run: | | ||
git config user.name "$(git log -n 1 --pretty=format:%an)" && | ||
git config user.email "$(git log -n 1 --pretty=format:%ae)" | ||
- name: build the book | ||
run: | | ||
micromamba run -n codeforecon jupyter-book build . --verbose | ||
- name: success | ||
run: | | ||
echo "Success in building book without errors!" |
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
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
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
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
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
Oops, something went wrong.