Skip to content

release

release #1301

name: release
on:
# push:
# branches:
# - beta
schedule:
- cron: "0 12 * * *"
jobs:
tests:
runs-on: ubuntu-22.04
name: test
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v2
with:
ref: beta
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
cache: "pip"
- name: install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install --no-cache-dir -r requirements/requirements.txt
pip install --no-cache-dir -r requirements/requirements-extra.txt
pip install --no-cache-dir -r requirements/requirements-dev.txt
pip install --no-cache-dir -r requirements/requirements-types.txt
pip install requests
- name: black linter
run: |
black . --check
- name: mypy checker
run: |
mypy tensorcircuit
- name: pylint checker
run: |
pylint tensorcircuit tests
- name: test scripts
run: |
pytest --cov=tensorcircuit --cov-report=xml -svv --benchmark-skip
- name: Generate nightly version number
id: version
run: |
BASE_VERSION=$(grep "__version__" tensorcircuit/__init__.py | sed -E 's/__version__ = "([^"]+)"/\1/')
DATE_VERSION=$(date +'%Y%m%d')
# Example: "1.3.0" becomes "1.3.0.dev20231027"
NIGHTLY_VERSION="${BASE_VERSION}.dev${DATE_VERSION}"
echo "Base version: $BASE_VERSION"
echo "Generated nightly version: $NIGHTLY_VERSION"
echo "nightly_version=$NIGHTLY_VERSION" >> $GITHUB_OUTPUT
- name: Update version in source
run: |
# Use sed to replace the version in __init__.py
sed -i "s/__version__ = .*/__version__ = \"${{ steps.version.outputs.nightly_version }}\"/" tensorcircuit/__init__.py
echo "Updated __init__.py to version ${{ steps.version.outputs.nightly_version }}"
head tensorcircuit/__init__.py
- name: Modify pyproject.toml for nightly build
run: |
# Replace the package name
sed -i 's/name = "tensorcircuit-ng"/name = "tensorcircuit-nightly"/' pyproject.toml
- name: setup build
run: |
python3 -m build
- name: upload to pypi
# if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
# skip_existing: true