From 4afbbf285b1b76bea72e540f4f0f6c06fbc31ed0 Mon Sep 17 00:00:00 2001 From: Han Yang Date: Mon, 2 Dec 2024 21:49:54 +0800 Subject: [PATCH 01/18] Create python-publish.yml --- .github/workflows/python-publish.yml | 71 ++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .github/workflows/python-publish.yml diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 0000000..f6782d7 --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,71 @@ +# This workflow will upload a Python Package to PyPI when a release is created +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Upload Python Package + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + release-build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.x" + + - name: Build release distributions + run: | + # NOTE: put your own distribution build steps here. + python -m pip install build + python -m build + + - name: Upload distributions + uses: actions/upload-artifact@v4 + with: + name: release-dists + path: dist/ + + # pypi-publish: + # runs-on: ubuntu-latest + # needs: + # - release-build + # permissions: + # # IMPORTANT: this permission is mandatory for trusted publishing + # id-token: write + + # # Dedicated environments with protections for publishing are strongly recommended. + # # For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules + # environment: + # name: testpypi + # # OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status: + # # url: https://pypi.org/p/YOURPROJECT + # # + # # ALTERNATIVE: if your GitHub Release name is the PyPI project version string + # # ALTERNATIVE: exactly, uncomment the following line instead: + # # url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }} + # url: https://test.pypi.org/project/mattersim/${{ github.event.release.name }} + + # steps: + # - name: Retrieve release distributions + # uses: actions/download-artifact@v4 + # with: + # name: release-dists + # path: dist/ + + # - name: Publish release distributions to PyPI + # uses: pypa/gh-action-pypi-publish@release/v1 + # with: + # packages-dir: dist/ From 84c7fd026e2a22c5fbd9f2e43295f58c857e50f2 Mon Sep 17 00:00:00 2001 From: Han Yang Date: Mon, 2 Dec 2024 21:53:43 +0800 Subject: [PATCH 02/18] Update python-publish.yml Invoke the workflow when PR to main. Only for testing purpose! --- .github/workflows/python-publish.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index f6782d7..e211b41 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -12,6 +12,10 @@ on: release: types: [published] + pull_request: + branches: + - main + permissions: contents: read From 55cbd34d0bf1e8d803dd1edf44672b424d161e14 Mon Sep 17 00:00:00 2001 From: Han Yang Date: Mon, 2 Dec 2024 21:57:57 +0800 Subject: [PATCH 03/18] Update python-publish.yml --- .github/workflows/python-publish.yml | 48 ++++++++++++++-------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index e211b41..f8dc58c 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -42,32 +42,32 @@ jobs: name: release-dists path: dist/ - # pypi-publish: - # runs-on: ubuntu-latest - # needs: - # - release-build - # permissions: - # # IMPORTANT: this permission is mandatory for trusted publishing - # id-token: write + pypi-publish: + runs-on: ubuntu-latest + needs: + - release-build + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write - # # Dedicated environments with protections for publishing are strongly recommended. - # # For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules - # environment: - # name: testpypi - # # OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status: - # # url: https://pypi.org/p/YOURPROJECT - # # - # # ALTERNATIVE: if your GitHub Release name is the PyPI project version string - # # ALTERNATIVE: exactly, uncomment the following line instead: - # # url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }} - # url: https://test.pypi.org/project/mattersim/${{ github.event.release.name }} + # Dedicated environments with protections for publishing are strongly recommended. + # For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules + environment: + name: testpypi + # OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status: + # url: https://pypi.org/p/YOURPROJECT + # + # ALTERNATIVE: if your GitHub Release name is the PyPI project version string + # ALTERNATIVE: exactly, uncomment the following line instead: + # url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }} + url: https://test.pypi.org/project/mattersim/${{ github.event.release.name }} - # steps: - # - name: Retrieve release distributions - # uses: actions/download-artifact@v4 - # with: - # name: release-dists - # path: dist/ + steps: + - name: Retrieve release distributions + uses: actions/download-artifact@v4 + with: + name: release-dists + path: dist/ # - name: Publish release distributions to PyPI # uses: pypa/gh-action-pypi-publish@release/v1 From 3591c8c2d0e643a47cbe82279d549001ad4ff48b Mon Sep 17 00:00:00 2001 From: Han Yang Date: Mon, 2 Dec 2024 22:00:15 +0800 Subject: [PATCH 04/18] Update python-publish.yml --- .github/workflows/python-publish.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index f8dc58c..a6fd4a7 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -69,7 +69,7 @@ jobs: name: release-dists path: dist/ - # - name: Publish release distributions to PyPI - # uses: pypa/gh-action-pypi-publish@release/v1 - # with: - # packages-dir: dist/ + - name: Publish release distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + packages-dir: dist/ From 6db635780d019b77910cb82502da4e2fe6a6d02a Mon Sep 17 00:00:00 2001 From: Han Yang Date: Mon, 2 Dec 2024 22:08:38 +0800 Subject: [PATCH 05/18] Update python-publish.yml --- .github/workflows/python-publish.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index a6fd4a7..be4c6e7 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -60,7 +60,7 @@ jobs: # ALTERNATIVE: if your GitHub Release name is the PyPI project version string # ALTERNATIVE: exactly, uncomment the following line instead: # url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }} - url: https://test.pypi.org/project/mattersim/${{ github.event.release.name }} + # url: https://test.pypi.org/project/mattersim/${{ github.event.release.name }} steps: - name: Retrieve release distributions @@ -73,3 +73,4 @@ jobs: uses: pypa/gh-action-pypi-publish@release/v1 with: packages-dir: dist/ + repository_url: https://test.pypi.org/legacy/ From 2ea70883c647466ca845ce2978cba03901dfd11b Mon Sep 17 00:00:00 2001 From: Han Yang Date: Mon, 2 Dec 2024 22:16:07 +0800 Subject: [PATCH 06/18] Update python-publish.yml --- .github/workflows/python-publish.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index be4c6e7..e6e5f6c 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -74,3 +74,7 @@ jobs: with: packages-dir: dist/ repository_url: https://test.pypi.org/legacy/ + + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }} From 1809dc5e8671a8ddc4b5cc560b40fb050ea4566d Mon Sep 17 00:00:00 2001 From: Han Yang Date: Mon, 2 Dec 2024 22:25:51 +0800 Subject: [PATCH 07/18] Update python-publish.yml --- .github/workflows/python-publish.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index e6e5f6c..a4ffbab 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -73,8 +73,5 @@ jobs: uses: pypa/gh-action-pypi-publish@release/v1 with: packages-dir: dist/ - repository_url: https://test.pypi.org/legacy/ - - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }} + password: ${{ secrets.TEST_PYPI_TOKEN }} + repository-url: https://test.pypi.org/legacy/ From 46fead15a2042b1ddbb22158acbed0f8b5c056ea Mon Sep 17 00:00:00 2001 From: Han Yang Date: Mon, 2 Dec 2024 15:21:17 +0000 Subject: [PATCH 08/18] configure cibuildwheel --- pyproject.toml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 965ea67..1d6b6d8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,3 +74,11 @@ package-dir = {"" = "src"} [tool.setuptools.packages.find] where = ["src"] include = ["mattersim", "mattersim.*"] + +[tool.cibuildwheel] +# Limit the build to Python 3.9 +build = "cp39-*" +# Limit the build to manylinux +manylinux-x86_64-image = "manylinux2014" +# Include pure Python (none) wheels +skip = "pp*,cp3{6,7,8,10,11}-*,*win*,*macos*" From 81b8cb8f6be90f68a5a2937010e695041b435dcd Mon Sep 17 00:00:00 2001 From: Han Yang Date: Mon, 2 Dec 2024 15:23:18 +0000 Subject: [PATCH 09/18] change to cibuildwheel --- .github/workflows/python-publish.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index a4ffbab..bfbf230 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -33,8 +33,8 @@ jobs: - name: Build release distributions run: | # NOTE: put your own distribution build steps here. - python -m pip install build - python -m build + python -m pip install build cibuildwheel + cibuildwheel --output-dir dist/ - name: Upload distributions uses: actions/upload-artifact@v4 @@ -60,7 +60,7 @@ jobs: # ALTERNATIVE: if your GitHub Release name is the PyPI project version string # ALTERNATIVE: exactly, uncomment the following line instead: # url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }} - # url: https://test.pypi.org/project/mattersim/${{ github.event.release.name }} + url: https://test.pypi.org/project/mattersim/${{ github.event.release.name }} steps: - name: Retrieve release distributions From 6e262ec36c9923fecf6648812c4c827e4f55e6a7 Mon Sep 17 00:00:00 2001 From: Han Yang Date: Tue, 3 Dec 2024 00:11:34 +0800 Subject: [PATCH 10/18] Update python-publish.yml --- .github/workflows/python-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index bfbf230..e8aa7b7 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -60,7 +60,7 @@ jobs: # ALTERNATIVE: if your GitHub Release name is the PyPI project version string # ALTERNATIVE: exactly, uncomment the following line instead: # url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }} - url: https://test.pypi.org/project/mattersim/${{ github.event.release.name }} + url: https://test.pypi.org/project/mattersim/${{ github.event.release.name }}-rc steps: - name: Retrieve release distributions From 64292641848e6e616d353e3406aa02a0897e860a Mon Sep 17 00:00:00 2001 From: Han Yang Date: Tue, 3 Dec 2024 08:16:51 +0800 Subject: [PATCH 11/18] Update python-publish.yml --- .github/workflows/python-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index e8aa7b7..c8b052f 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -60,7 +60,7 @@ jobs: # ALTERNATIVE: if your GitHub Release name is the PyPI project version string # ALTERNATIVE: exactly, uncomment the following line instead: # url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }} - url: https://test.pypi.org/project/mattersim/${{ github.event.release.name }}-rc + url: https://test.pypi.org/project/mattersim-test/${{ github.event.release.name }}-rc steps: - name: Retrieve release distributions From fa78c824a5d94a73838260d3b8f33db91728f882 Mon Sep 17 00:00:00 2001 From: Han Yang Date: Tue, 3 Dec 2024 08:40:54 +0800 Subject: [PATCH 12/18] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 1d6b6d8..9287a82 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=45", "wheel", "Cython>=0.29.32", "numpy<2"] build-backend = "setuptools.build_meta" [project] -name = "mattersim" +name = "mattersim-test" version = "1.0.0" description = "MatterSim: A Deep Learning Atomistic Model Across Elements, Temperatures and Pressures." authors = [ From 45a6253b7a7446d526390f5124782dca4c37e2cb Mon Sep 17 00:00:00 2001 From: Han Yang Date: Tue, 3 Dec 2024 01:12:39 +0000 Subject: [PATCH 13/18] update pyproject to enable automatic versioning --- pyproject.toml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9287a82..7b5a21e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = ["setuptools>=45", "wheel", "Cython>=0.29.32", "numpy<2"] +requires = ["setuptools>=45", "wheel", "Cython>=0.29.32", "numpy<2", "setuptools_scm"] build-backend = "setuptools.build_meta" [project] -name = "mattersim-test" -version = "1.0.0" +name = "mattersim" +dynamic = ["version"] description = "MatterSim: A Deep Learning Atomistic Model Across Elements, Temperatures and Pressures." authors = [ {name = "Han Yang", email = "hanyang@microsoft.com"}, @@ -75,6 +75,10 @@ package-dir = {"" = "src"} where = ["src"] include = ["mattersim", "mattersim.*"] +[tool.setuptools_scm] +version_scheme = "guess-next-dev" +local_scheme = "dirty-tag" + [tool.cibuildwheel] # Limit the build to Python 3.9 build = "cp39-*" From 199b0afdd0ce555216db6fa0add84637237b8742 Mon Sep 17 00:00:00 2001 From: Han Yang Date: Tue, 3 Dec 2024 01:14:04 +0000 Subject: [PATCH 14/18] add fetch-depth to actions --- .github/workflows/python-publish.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index c8b052f..fa24061 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -25,6 +25,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - uses: actions/setup-python@v5 with: From 59c70295776d067bb7dd246063bb679f358df511 Mon Sep 17 00:00:00 2001 From: Han Yang Date: Tue, 3 Dec 2024 01:15:13 +0000 Subject: [PATCH 15/18] update url for testpypi --- .github/workflows/python-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index fa24061..f8587f3 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -62,7 +62,7 @@ jobs: # ALTERNATIVE: if your GitHub Release name is the PyPI project version string # ALTERNATIVE: exactly, uncomment the following line instead: # url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }} - url: https://test.pypi.org/project/mattersim-test/${{ github.event.release.name }}-rc + url: https://test.pypi.org/project/mattersim/${{ github.event.release.name }} steps: - name: Retrieve release distributions From 3a53ed996ace115357b062dffb32445d09e85eb8 Mon Sep 17 00:00:00 2001 From: Han Yang Date: Tue, 3 Dec 2024 01:53:17 +0000 Subject: [PATCH 16/18] diable pushing python package on pull request to main branch; now, only release does --- .github/workflows/python-publish.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index f8587f3..5616fa6 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -12,10 +12,6 @@ on: release: types: [published] - pull_request: - branches: - - main - permissions: contents: read From 32e5c139a7eb4dd6156047a3660b5959f945273a Mon Sep 17 00:00:00 2001 From: Han Yang Date: Tue, 3 Dec 2024 02:15:55 +0000 Subject: [PATCH 17/18] push to real pypi --- .github/workflows/python-publish.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 5616fa6..8ff15c4 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -51,14 +51,14 @@ jobs: # Dedicated environments with protections for publishing are strongly recommended. # For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules environment: - name: testpypi + name: pypi # OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status: # url: https://pypi.org/p/YOURPROJECT # # ALTERNATIVE: if your GitHub Release name is the PyPI project version string # ALTERNATIVE: exactly, uncomment the following line instead: # url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }} - url: https://test.pypi.org/project/mattersim/${{ github.event.release.name }} + url: https://pypi.org/project/mattersim/${{ github.event.release.name }} steps: - name: Retrieve release distributions @@ -71,5 +71,5 @@ jobs: uses: pypa/gh-action-pypi-publish@release/v1 with: packages-dir: dist/ - password: ${{ secrets.TEST_PYPI_TOKEN }} - repository-url: https://test.pypi.org/legacy/ + password: ${{ secrets.PYPI_TOKEN }} + repository-url: https://upload.pypi.org/legacy/ From 20ecb21345dbcdf20dc76d05c4b7b26fc96062ee Mon Sep 17 00:00:00 2001 From: Han Yang Date: Tue, 3 Dec 2024 02:16:51 +0000 Subject: [PATCH 18/18] standardize files suffices --- .github/workflows/{codeql.yml => codeql.yaml} | 0 .github/workflows/{python-publish.yml => python-publish.yaml} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{codeql.yml => codeql.yaml} (100%) rename .github/workflows/{python-publish.yml => python-publish.yaml} (100%) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yaml similarity index 100% rename from .github/workflows/codeql.yml rename to .github/workflows/codeql.yaml diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yaml similarity index 100% rename from .github/workflows/python-publish.yml rename to .github/workflows/python-publish.yaml