diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index 500a90f52..a00c0758b 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -9,16 +9,9 @@ name: release python on: workflow_dispatch: - inputs: - release-tag: - description: 'GitHub release tag to publish packages' - required: false - type: string - prerelease: - description: 'Flag to create a pre-release' - default: true - required: false - type: boolean + release: + types: [published] + jobs: build_wheels: @@ -34,32 +27,70 @@ jobs: - name: Checkout source code uses: actions/checkout@v3 - - name: Build wheels on Linux - if: runner.os == 'Linux' - uses: pypa/cibuildwheel@v2.13.1 - env: - # Linux cannot call "sh -c ./python/install-hyperonc.sh" because - # before-all command is also called with "sh -c" - CIBW_BEFORE_ALL: ./python/install-hyperonc.sh -u https://github.com/${{github.repository}}.git -r ${{github.ref}} - with: - package-dir: ./python + - run: | + echo "REF_NAME=${{github.ref_name}}" | tee -a $GITHUB_ENV + echo "EVENT_NAME=${{github.event_name}}" | tee -a $GITHUB_ENV + echo "PRERELEASE=${{github.event.release.prerelease}}" | tee -a $GITHUB_ENV + echo "TAG_NAME=${{github.event.release.tag_name}}" | tee -a $GITHUB_ENV + echo "COMMIT_HEAD=${{github.ref_name != '' && github.ref_name || env.GITHUB_SHA}}" | tee -a $GITHUB_ENV - - name: Build wheels on MacOSX - if: runner.os == 'macOS' + - name: Build wheels on ${{ matrix.os }} uses: pypa/cibuildwheel@v2.13.1 env: - # Mac OS X cannot call "./python/install-hyperonc.sh" probably because - # "/bin/sh" is not correct path for the shell there - CIBW_BEFORE_ALL: sh -c "./python/install-hyperonc.sh -u https://github.com/${{github.repository}}.git -r ${{github.ref}}" + CIBW_BEFORE_ALL: sh -c "./python/install-hyperonc.sh -u https://github.com/${{github.repository}}.git -r ${{env.COMMIT_HEAD}}" + CIBW_SKIP: "*musllinux*" with: package-dir: ./python - - name: Publish artifacts on GitHub + - name: Publish Artifacts on GitHub Release + if: github.event.action == 'published' uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: ./wheelhouse/*.whl - tag: ${{ inputs.release-tag }} - prerelease: ${{ inputs.prerelease }} + tag: ${{ github.ref }} + prerelease: ${{ github.event.release.prerelease }} overwrite: true file_glob: true + + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: python-wheels + path: ./wheelhouse/*.whl + + publish-test-pypi: + name: Publish to Test PyPI + permissions: + id-token: write + environment: + name: test + runs-on: ubuntu-latest + needs: [build_wheels] + if: github.event.action == 'published' + steps: + - uses: actions/download-artifact@v3 + with: + name: python-wheels + path: dist + - name: Publish package distributions to Test PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + + publish-pypi: + name: Publish to PyPI + permissions: + id-token: write + environment: + name: production + runs-on: ubuntu-latest + needs: [build_wheels] + if: github.event.action == 'published' + steps: + - uses: actions/download-artifact@v3 + with: + name: python-wheels + path: dist + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/python/README.md b/python/README.md new file mode 100644 index 000000000..db518b39f --- /dev/null +++ b/python/README.md @@ -0,0 +1,12 @@ +# Overview + +OpenCog Hyperon is a substantially revised, novel version of OpenCog - which is currently at an active +pre-alpha stage of development and experimentation. One of the focuses in the Hyperon design is a successor +to the OpenCog Classic Atomese language with clear semantics supporting meta-language features, +different types of inference, etc. What we have landed on is an "Atomese 2" language called MeTTa (Meta Type Talk). + +One can run MeTTa script from command line: + +``` +metta .metta +``` diff --git a/python/install-hyperonc.sh b/python/install-hyperonc.sh index 487c2cc91..6a3eedf28 100755 --- a/python/install-hyperonc.sh +++ b/python/install-hyperonc.sh @@ -38,7 +38,7 @@ mkdir -p ${HOME}/hyperonc cd ${HOME}/hyperonc git init git remote add origin $HYPERONC_URL -git fetch origin $HYPERONC_REV +git fetch --depth=1 origin $HYPERONC_REV git reset --hard FETCH_HEAD mkdir -p ${HOME}/hyperonc/c/build diff --git a/python/pyproject.toml b/python/pyproject.toml index 5cdbdc598..9e8d2bdff 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,11 +1,11 @@ [build-system] -requires = ["setuptools==65.6.3", "conan==1.60.2", "cmake==3.26.4"] +requires = ["setuptools==65.6.3", "conan==1.60.2", "cmake==3.26.4", "setuptools_scm[toml]>=6.2"] build-backend = "setuptools.build_meta" [project] name = "hyperon" -version = "0.1.6" description = "Hyperon API in Python" +readme = "README.md" requires-python = ">=3.7" keywords = ["metta", "hyperon", "opencog"] license = {text = "MIT License"} @@ -19,6 +19,7 @@ classifiers = [ dependencies = [ 'importlib-metadata==6.6.0; python_version<"3.8"', ] +dynamic = ["version"] [project.scripts] metta = "hyperon.metta:main" @@ -39,3 +40,8 @@ before-all = "sh -c ./python/install-hyperonc.sh" skip = "*-musllinux_i686" test-requires = ["pytest==7.3.2"] test-command = "pytest {project}/python/tests" + + +[tool.setuptools_scm] +root = '..' +