Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Add workflow for releases from GHA #1117

Merged
merged 18 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .github/workflows/make_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Make release

on:
push:
tags:
- 'v*'
pull_request:
paths:
- .github/workflows/make_release.yml

jobs:
build_wheels: # This job builds the wheels
runs-on: ubuntu-latest
permissions:
attestations: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: hynek/build-and-inspect-python-package@v2
with:
attest-build-provenance-github: 'true'

Comment on lines +18 to +24
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a step to set up Python.

The job is missing a step to set up the Python environment before using hynek/build-and-inspect-python-package@v2. This could lead to issues if the correct Python version is not available.

      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
+     - uses: actions/setup-python@v5
+       with:
+         python-version: "3.10"
      - uses: hynek/build-and-inspect-python-package@v2
        with:
          attest-build-provenance-github: 'true'
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: hynek/build-and-inspect-python-package@v2
with:
attest-build-provenance-github: 'true'
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- uses: hynek/build-and-inspect-python-package@v2
with:
attest-build-provenance-github: 'true'


build_pyinstaller_bundle:
name: Build PyInstaller bundle
strategy:
fail-fast: false
matrix:
os: ["ubuntu-20.04", "windows-2019", "macos-13", "macos-14"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- uses: tlambert03/setup-qt-libs@v1
- name: Install Windows OpenGL
if: runner.os == 'Windows'
run: |
git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git
powershell gl-ci-helpers/appveyor/install_opengl.ps1
if (Test-Path -Path "C:\Windows\system32\opengl32.dll" -PathType Leaf) {Exit 0} else {Exit 1}
shell: powershell
- name: Install PartSeg
run: python -m pip install -e .[pyinstaller] -c requirements/constraints_py3.10.txt
Copy link
Contributor

@coderabbitai coderabbitai bot Jul 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pin the versions of dependencies.

The pip install command does not pin the versions of dependencies. This could lead to issues with future updates.

      - name: Install PartSeg
        run: python -m pip install -e .[pyinstaller] -c requirements/constraints_py3.10.txt
+       run: python -m pip install -r requirements.txt

Committable suggestion was skipped due to low confidence.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it pin using constraints file

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Czaki, you are correct. The requirements/constraints_py3.10.txt file does pin the versions of the dependencies. Thank you for the clarification.

Analysis chain
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Display the contents of the constraints file to verify if it pins the versions of dependencies.
cat requirements/constraints_py3.10.txt

Length of output: 8043


Learnings added
Learnt from: Czaki
PR: 4DNucleome/PartSeg#1117
File: .github/workflows/make_release.yml:46-47
Timestamp: 2024-07-03T14:07:21.406Z
Learning: The `requirements/constraints_py3.10.txt` file is used to pin the versions of dependencies in the `pip install` command for the PartSeg project.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


- name: Build PartSeg bundle
run: python build_utils/create_and_pack_executable.py

- name: Publish PartSeg bundle
uses: actions/upload-artifact@v4
with:
name: PartSeg_bundle_${{ matrix.os }}
path: dist2

- name: Test PartSeg bundle
uses: aganders3/headless-gui@v2
with:
run: dist/PartSeg/PartSeg _test



create_release:
name: Create release
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
needs:
- build_wheels
- build_pyinstaller_bundle
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
patterns: 'PartSeg_bundle_*'
path: pyinstaller
merge-multiple: true
- uses: actions/download-artifact@v4
with:
name: Packages
path: dist

- name: Publish package distributions to PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
uses: pypa/gh-action-pypi-publish@release/v1
3 changes: 3 additions & 0 deletions build_utils/create_and_pack_executable.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def create_archive(working_dir, with_version=True):
file_name = f"PartSeg-{PartSeg.__version__}-{SYSTEM_NAME_DICT[platform.system()]}"
else:
file_name = f"PartSeg-{SYSTEM_NAME_DICT[platform.system()]}"
# if it is macos and arm64 the add arm64 to the name
if platform.system() == "Darwin" and os.uname().machine == "arm64":
file_name += "-arm64"
if platform.system() != "Darwin":
return zipfile.ZipFile(os.path.join(working_dir, "dist2", f"{file_name}.zip"), "w", zipfile.ZIP_DEFLATED)
arch_file = tarfile.open(os.path.join(working_dir, "dist2", f"{file_name}.tgz"), "w:gz")
Expand Down
Loading