From 06484e31a00035ba8feb9495f6360515adb9c57f Mon Sep 17 00:00:00 2001 From: Michael O'Keefe Date: Wed, 2 Oct 2024 15:52:17 -0600 Subject: [PATCH 01/11] Add test to upload files to testpypi --- .github/workflows/release.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3c9f6c3c..c13057e5 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -128,7 +128,13 @@ jobs: - run: twine check ./artifact/* - - name: upload files + - name: Publish distribution to Test PyPI + run: twine upload -r testpypi ./artifact/* + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.test_pypi_password}} + + - name: Upload files to PyPI run: twine upload ./artifact/* env: TWINE_USERNAME: __token__ From 385b4dff92b1d27c565535aa0131d031f25358e0 Mon Sep 17 00:00:00 2001 From: Michael O'Keefe Date: Wed, 9 Oct 2024 11:33:24 -0600 Subject: [PATCH 02/11] Update testpypi secret to match name in Github Actions secrets section --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c13057e5..0aee5280 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -132,7 +132,7 @@ jobs: run: twine upload -r testpypi ./artifact/* env: TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.test_pypi_password}} + TWINE_PASSWORD: ${{ secrets.FASTSIM_TEST_PYPI_TOKEN }} - name: Upload files to PyPI run: twine upload ./artifact/* From 1556e5ad90e899ed7c7a8f79904eac9de8d547ec Mon Sep 17 00:00:00 2001 From: Michael O'Keefe Date: Wed, 16 Oct 2024 14:34:36 -0600 Subject: [PATCH 03/11] Temporarily diable production PyPI to test Test PyPI --- .github/workflows/release.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 0aee5280..faa71b73 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -134,8 +134,9 @@ jobs: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.FASTSIM_TEST_PYPI_TOKEN }} - - name: Upload files to PyPI - run: twine upload ./artifact/* - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.fastsim_pypi_token }} + # NOTE: temporarily disabling production PyPI to test Test PyPI + #- name: Upload files to PyPI + # run: twine upload ./artifact/* + # env: + # TWINE_USERNAME: __token__ + # TWINE_PASSWORD: ${{ secrets.fastsim_pypi_token }} From 53ca6e92e1c879797b10ce7f7f5e088e3d3b9afa Mon Sep 17 00:00:00 2001 From: Michael O'Keefe Date: Wed, 16 Oct 2024 14:57:54 -0600 Subject: [PATCH 04/11] Add critical CIBW flag for Mac OS builds --- .github/workflows/release.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index faa71b73..6e318aa2 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -87,7 +87,8 @@ jobs: pip install -U setuptools-rust && curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=nightly --profile=minimal -y && rustup show - + CIBW_BEFORE_BUILD_MACOS: > + rustup target add x86_64-apple-darwin # - name: build windows 32bit binaries # if: matrix.os == 'windows' # run: cibuildwheel --output-dir dist From b3089c661bcccb7a3a4858abee657b428e68ba78 Mon Sep 17 00:00:00 2001 From: Michael O'Keefe Date: Wed, 16 Oct 2024 14:59:01 -0600 Subject: [PATCH 05/11] Also add critical Mac OS CI build fix for wheels.yml --- .github/workflows/wheels.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yaml b/.github/workflows/wheels.yaml index 5640579b..bbc27ea9 100644 --- a/.github/workflows/wheels.yaml +++ b/.github/workflows/wheels.yaml @@ -89,7 +89,8 @@ jobs: pip install -U setuptools-rust && curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=nightly --profile=minimal -y && rustup show - + CIBW_BEFORE_BUILD_MACOS: > + rustup target add x86_64-apple-darwin # - name: build windows 32bit binaries # if: matrix.os == 'windows' # run: cibuildwheel --output-dir dist From 530ae244130699c3f0b3193a44b7e8c9c98adf65 Mon Sep 17 00:00:00 2001 From: Michael O'Keefe Date: Thu, 17 Oct 2024 07:54:56 -0600 Subject: [PATCH 06/11] Fix GitHub actions error in release.yaml Got a deprecation error for using v2.* of download-artifact. Changed both upload and download to use v4. More details and the actual error appear below: Error: This request has been automatically failed because it uses a deprecated version of `actions/download-artifact: v2.1.1`. Learn more: https://github.blog/changelog/2024-02-13-deprecation-notice-v1-and-v2-of-the-artifact-actions/ --- .github/workflows/release.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6e318aa2..d2cd88a6 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -108,7 +108,7 @@ jobs: - name: list dist files run: ${{ matrix.ls || 'ls -lh' }} dist/ - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: path: ./dist/* @@ -118,7 +118,7 @@ jobs: runs-on: ubuntu-latest steps: - name: download files - uses: actions/download-artifact@v2.1.1 + uses: actions/download-artifact@4 - name: set up Python 3.10 uses: actions/setup-python@v4 From 150216faf0c8541eb8e35e4b430bbe1f628842e7 Mon Sep 17 00:00:00 2001 From: Michael O'Keefe Date: Thu, 17 Oct 2024 11:21:07 -0600 Subject: [PATCH 07/11] Fixed typo on download-artifact version. It needs to be "@v4" instead of "@4" --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d2cd88a6..2cb2fe36 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -118,7 +118,7 @@ jobs: runs-on: ubuntu-latest steps: - name: download files - uses: actions/download-artifact@4 + uses: actions/download-artifact@v4 - name: set up Python 3.10 uses: actions/setup-python@v4 From eb6ae93813c30bf091b6e2cd82126c7aea977f17 Mon Sep 17 00:00:00 2001 From: Michael O'Keefe Date: Fri, 18 Oct 2024 07:54:57 -0600 Subject: [PATCH 08/11] Add example workflow f/ Python Packaging Guide See: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ for details. --- .github/workflows/publish-to-pypi.yml | 146 ++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 .github/workflows/publish-to-pypi.yml diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml new file mode 100644 index 00000000..2aaa81e2 --- /dev/null +++ b/.github/workflows/publish-to-pypi.yml @@ -0,0 +1,146 @@ +name: Publish Python Distribution to PyPI and Test PyPI +on: push +jobs: + build: + name: build py3.${{ matrix.python-version }} on ${{ matrix.platform || matrix.os }} + strategy: + fail-fast: true + matrix: + os: + - ubuntu + - macos + - windows + python-version: + - "8" + - "9" + - "10" + include: + - os: ubuntu + platform: linux + - os: windows + ls: dir + + runs-on: ${{ format('{0}-latest', matrix.os) }} + steps: + - uses: actions/checkout@v3 + + - name: set up rust + if: matrix.os != 'ubuntu' + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - run: rustup target add aarch64-apple-darwin + if: matrix.os == 'macos' + + - name: run cargo tests + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - run: cd rust/ && cargo test + + - name: set up python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - name: install Python dependencies + run: pip install -U setuptools wheel twine cibuildwheel pytest + + - name: build source distribution + if: matrix.os == 'ubuntu' && matrix.python-version == '10' + run: | + pip install -U setuptools-rust + python -c "import setuptools; setuptools.setup()" sdist + + - name: build ${{ matrix.platform || matrix.os }} binaries + run: cibuildwheel --output-dir dist + env: + CIBW_BUILD: "cp3${{ matrix.python-version }}-*" + CIBW_SKIP: "*-win32 *-musllinux* *i686 *ppc64le *s390x *aarch64" + CIBW_PLATFORM: ${{ matrix.platform || matrix.os }} + # TODO: why doesn't pytest work with cibuildwheel? + # CIBW_TEST_COMMAND: "pytest -v {project}/python/fastsim/tests" + CIBW_TEST_COMMAND: "python -m unittest discover {project}/python/fastsim/tests" + CIBW_ARCHS_MACOS: "universal2" + # see https://cibuildwheel.readthedocs.io/en/stable/faq/#universal2 + CIBW_TEST_SKIP: "*_universal2:arm64" + CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH"' + CIBW_ENVIRONMENT_WINDOWS: 'PATH="$UserProfile\.cargo\bin;$PATH"' + CIBW_MANYLINUX_X86_64_IMAGE: "manylinux2014" + CIBW_MANYLINUX_I686_IMAGE: "manylinux2014" + CIBW_BEFORE_BUILD: > + pip install -U setuptools-rust && + rustup default stable && + rustup show + CIBW_BEFORE_BUILD_LINUX: > + yum -y install openssl openssl-devel && + pip install -U setuptools-rust && + curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=nightly --profile=minimal -y && + rustup show + CIBW_BEFORE_BUILD_MACOS: > + rustup target add x86_64-apple-darwin + # - name: build windows 32bit binaries + # if: matrix.os == 'windows' + # run: cibuildwheel --output-dir dist + # env: + # CIBW_BUILD: 'cp3${{ matrix.python-version }}-win32' + # CIBW_PLATFORM: windows + # CIBW_TEST_REQUIRES: 'pytest' + # CIBW_TEST_COMMAND: 'pytest {project}/tests -s' + # CIBW_ENVIRONMENT: 'PATH="$UserProfile\.cargo\bin;$PATH"' + # CIBW_BEFORE_BUILD: > + # pip install -U setuptools-rust && + # rustup toolchain install nightly-i686-pc-windows-msvc && + # rustup default nightly-i686-pc-windows-msvc && + # rustup override set nightly-i686-pc-windows-msvc && + # rustup show + + - name: list dist files + run: ${{ matrix.ls || 'ls -lh' }} dist/ + + - uses: actions/upload-artifact@v4 + with: + path: ./dist/* + + publish-to-test-pypi: + name: Publish Python Distribution to Test PyPI + needs: + - build + runs-on: ubuntu-latest + environment: + name: testpypi + url: https://test.pypi.org/p/fastsim + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + steps: + - name: Download all artifacts + uses: actions/download-artifact@v4 + - name: Publish Distribution to Test PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + packages-dir: artifact/ + + publish-to-pypi: + name: Publish Python Distribution to PyPI + if: startsWith(github.ref, 'refs/tags') # only publish to PyPI on tag pushes + needs: + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/fastsim + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + steps: + - name: Download all artifacts + uses: actions/download-artifact@v4 + - name: Publish Distribution to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + packages-dir: artifact/ From f0d19e6758e94fa5485c592bee2cb2a72f10573f Mon Sep 17 00:00:00 2001 From: Michael O'Keefe Date: Fri, 18 Oct 2024 13:39:08 -0600 Subject: [PATCH 09/11] Temporarily rename project to testfastsim to test Test PyPI upload --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 81260ac9..e6dba710 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["maturin>=0.15,<0.16"] build-backend = "maturin" [project] -name = "fastsim" +name = "testfastsim" version = "2.1.2" authors = [{ name = "NREL/MTES/CIMS/MBAP Group", email = "fastsim@nrel.gov" }] description = "Tool for modeling vehicle powertrains" From ad8b324aa46cb8357202bfc1d905d59cbc0bf328 Mon Sep 17 00:00:00 2001 From: Michael O'Keefe Date: Fri, 18 Oct 2024 13:46:21 -0600 Subject: [PATCH 10/11] Restore name --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e6dba710..81260ac9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["maturin>=0.15,<0.16"] build-backend = "maturin" [project] -name = "testfastsim" +name = "fastsim" version = "2.1.2" authors = [{ name = "NREL/MTES/CIMS/MBAP Group", email = "fastsim@nrel.gov" }] description = "Tool for modeling vehicle powertrains" From f9771fb66f4a66f6aa36a4e575b27084fff1c300 Mon Sep 17 00:00:00 2001 From: Michael O'Keefe Date: Mon, 28 Oct 2024 10:57:57 -0600 Subject: [PATCH 11/11] Restore publishing to production PyPI --- .github/workflows/publish-to-pypi.yml | 146 -------------------------- .github/workflows/release.yaml | 11 +- 2 files changed, 5 insertions(+), 152 deletions(-) delete mode 100644 .github/workflows/publish-to-pypi.yml diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml deleted file mode 100644 index 2aaa81e2..00000000 --- a/.github/workflows/publish-to-pypi.yml +++ /dev/null @@ -1,146 +0,0 @@ -name: Publish Python Distribution to PyPI and Test PyPI -on: push -jobs: - build: - name: build py3.${{ matrix.python-version }} on ${{ matrix.platform || matrix.os }} - strategy: - fail-fast: true - matrix: - os: - - ubuntu - - macos - - windows - python-version: - - "8" - - "9" - - "10" - include: - - os: ubuntu - platform: linux - - os: windows - ls: dir - - runs-on: ${{ format('{0}-latest', matrix.os) }} - steps: - - uses: actions/checkout@v3 - - - name: set up rust - if: matrix.os != 'ubuntu' - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - - run: rustup target add aarch64-apple-darwin - if: matrix.os == 'macos' - - - name: run cargo tests - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - run: cd rust/ && cargo test - - - name: set up python - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - - name: install Python dependencies - run: pip install -U setuptools wheel twine cibuildwheel pytest - - - name: build source distribution - if: matrix.os == 'ubuntu' && matrix.python-version == '10' - run: | - pip install -U setuptools-rust - python -c "import setuptools; setuptools.setup()" sdist - - - name: build ${{ matrix.platform || matrix.os }} binaries - run: cibuildwheel --output-dir dist - env: - CIBW_BUILD: "cp3${{ matrix.python-version }}-*" - CIBW_SKIP: "*-win32 *-musllinux* *i686 *ppc64le *s390x *aarch64" - CIBW_PLATFORM: ${{ matrix.platform || matrix.os }} - # TODO: why doesn't pytest work with cibuildwheel? - # CIBW_TEST_COMMAND: "pytest -v {project}/python/fastsim/tests" - CIBW_TEST_COMMAND: "python -m unittest discover {project}/python/fastsim/tests" - CIBW_ARCHS_MACOS: "universal2" - # see https://cibuildwheel.readthedocs.io/en/stable/faq/#universal2 - CIBW_TEST_SKIP: "*_universal2:arm64" - CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH"' - CIBW_ENVIRONMENT_WINDOWS: 'PATH="$UserProfile\.cargo\bin;$PATH"' - CIBW_MANYLINUX_X86_64_IMAGE: "manylinux2014" - CIBW_MANYLINUX_I686_IMAGE: "manylinux2014" - CIBW_BEFORE_BUILD: > - pip install -U setuptools-rust && - rustup default stable && - rustup show - CIBW_BEFORE_BUILD_LINUX: > - yum -y install openssl openssl-devel && - pip install -U setuptools-rust && - curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=nightly --profile=minimal -y && - rustup show - CIBW_BEFORE_BUILD_MACOS: > - rustup target add x86_64-apple-darwin - # - name: build windows 32bit binaries - # if: matrix.os == 'windows' - # run: cibuildwheel --output-dir dist - # env: - # CIBW_BUILD: 'cp3${{ matrix.python-version }}-win32' - # CIBW_PLATFORM: windows - # CIBW_TEST_REQUIRES: 'pytest' - # CIBW_TEST_COMMAND: 'pytest {project}/tests -s' - # CIBW_ENVIRONMENT: 'PATH="$UserProfile\.cargo\bin;$PATH"' - # CIBW_BEFORE_BUILD: > - # pip install -U setuptools-rust && - # rustup toolchain install nightly-i686-pc-windows-msvc && - # rustup default nightly-i686-pc-windows-msvc && - # rustup override set nightly-i686-pc-windows-msvc && - # rustup show - - - name: list dist files - run: ${{ matrix.ls || 'ls -lh' }} dist/ - - - uses: actions/upload-artifact@v4 - with: - path: ./dist/* - - publish-to-test-pypi: - name: Publish Python Distribution to Test PyPI - needs: - - build - runs-on: ubuntu-latest - environment: - name: testpypi - url: https://test.pypi.org/p/fastsim - permissions: - id-token: write # IMPORTANT: mandatory for trusted publishing - steps: - - name: Download all artifacts - uses: actions/download-artifact@v4 - - name: Publish Distribution to Test PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - repository-url: https://test.pypi.org/legacy/ - packages-dir: artifact/ - - publish-to-pypi: - name: Publish Python Distribution to PyPI - if: startsWith(github.ref, 'refs/tags') # only publish to PyPI on tag pushes - needs: - - build - runs-on: ubuntu-latest - environment: - name: pypi - url: https://pypi.org/p/fastsim - permissions: - id-token: write # IMPORTANT: mandatory for trusted publishing - steps: - - name: Download all artifacts - uses: actions/download-artifact@v4 - - name: Publish Distribution to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - packages-dir: artifact/ diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2cb2fe36..3a8e2d12 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -135,9 +135,8 @@ jobs: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.FASTSIM_TEST_PYPI_TOKEN }} - # NOTE: temporarily disabling production PyPI to test Test PyPI - #- name: Upload files to PyPI - # run: twine upload ./artifact/* - # env: - # TWINE_USERNAME: __token__ - # TWINE_PASSWORD: ${{ secrets.fastsim_pypi_token }} + - name: Upload files to PyPI + run: twine upload ./artifact/* + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.fastsim_pypi_token }}