Skip to content

Commit

Permalink
Starting the versioning CI (#8)
Browse files Browse the repository at this point in the history
* Enable format

* Enable Makefile versioning

* Init Release and Publish workflow
  • Loading branch information
charnley authored Apr 5, 2024
1 parent 84e83e3 commit 2289445
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 16 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Publish PyPI

on:
release:
branches:
- main

jobs:

deploy:
name: Publish Release
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v1
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install setuptools build twine
- name: Build package
run: make build python=python
- name: Publish package
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: make upload python=python
24 changes: 24 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Release Version

on:
push:
branches:
- main

jobs:

release:
name: Testing
runs-on: "ubuntu-latest"
defaults:
run:
shell: bash -l {0}
steps:
- name: Bump version
run: make something
- name: Commit version
run: make something
- name: Push to main
run: git push origin --tags
- name: Create release
run: no idea
11 changes: 3 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

name: Test Python package
name: Test

on:
push:
Expand All @@ -9,6 +8,7 @@ on:
branches: [ main ]

jobs:

test:
name: Testing
runs-on: "ubuntu-latest"
Expand All @@ -25,11 +25,6 @@ jobs:
activate-environment: dev
environment-file: ./environment_dev.yaml
python-version: ${{ matrix.python-version }}
- run: |
ls
pwd
which python
conda info
- run: pip install . -v
- run: make test python=python
# - run: make format python=python
- run: make format python=python
49 changes: 43 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,24 @@ pip=./env/bin/pip
pytest=pytest
j=1

version_file=src/qmllib/version.py

.PHONY: build

all: env setup
all: env

## Setup

env:
${mamba} env create -f ./environment_dev.yaml -p ./env --quiet
${python} -m pre_commit install
${python} -m pip install -e .

setup: ./.git/hooks/pre-commit

./.git/hooks/pre-commit:
${python} -m pre_commit install

## Development

format:
${python} -m pre_commit run --all-files

Expand All @@ -37,9 +41,42 @@ compile:

build:
${python} -m build --sdist --skip-dependency-check .
@# ${python} -m pip wheel --no-deps -v .
@# ${python} -m pip wheel -v .
@#ls *.whl

upload:
${python} -m twine upload ./dist/*.tar.gz

## Version

VERSION=$(shell cat ${version_file} | egrep -o "([0-9]{1,}\.)+[0-9]{1,}")
VERSION_PATCH=$(shell echo ${VERSION} | cut -d'.' -f3)
VERSION_MINOR=$(shell echo ${VERSION} | cut -d'.' -f2)
VERSION_MAJOR=$(shell echo ${VERSION} | cut -d'.' -f1)
GIT_COMMIT=$(shell git rev-parse --short HEAD)

bump-version-dev:
test ! -z "${VERSION}"
test ! -z "${GIT_COMMIT}"
exit 1
# Not Implemented

bump-version-patch:
test ! -z "${VERSION_PATCH}"
echo "__version__ = \"${VERSION_MAJOR}.${VERSION_MINOR}.$(shell awk 'BEGIN{print ${VERSION_PATCH}+1}')\"" > ${version_file}

bump-version-minor:
test ! -z "${VERSION_MINOR}"
echo "__version__ = \"${VERSION_MAJOR}.$(shell awk 'BEGIN{print ${VERSION_MINOR}+1}').0\"" > ${version_file}

bump-version-major:
test ! -z "${VERSION_MAJOR}"
echo "__version__ = \"$(shell awk 'BEGIN{print ${VERSION_MAJOR}+1}').0.0\"" > ${version_file}

commit-version-tag:
git tag --list | grep -qix "${VERSION}"
git commit -m "Release ${VERSION}" --no-verify ${version_file}
git tag 'v${VERSION}'

## Clean

clean:
find ./src/ -type f \
Expand Down
1 change: 1 addition & 0 deletions environment_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ dependencies:
- build
- meson
- ninja
# publish
- twine
2 changes: 1 addition & 1 deletion src/qmllib/representations/arad/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from .arad import *
from .arad import * # noqa: F403
2 changes: 1 addition & 1 deletion tests/test_fchl_acsf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from copy import deepcopy

import numpy as np
from conftest import ASSETS

from qmllib.representations import generate_fchl_acsf
from qmllib.utils.xyz_format import read_xyz
from tests.conftest import ASSETS

np.set_printoptions(linewidth=666, edgeitems=10)
REP_PARAMS = dict()
Expand Down
2 changes: 2 additions & 0 deletions tests/test_fchl_force.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# flake8: noqa

import ast
import csv
from copy import deepcopy
Expand Down

0 comments on commit 2289445

Please sign in to comment.