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

Publication pipeline #106

Merged
merged 27 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7283aac
WIP: workin on ci - canoot be tested with act locally since win x12
9and3 Sep 19, 2024
f159d7f
WIP: workin on ci - canoot be tested with act locally since win x13
9and3 Sep 19, 2024
5dc195b
WIP: workin on ci - canoot be tested with act locally since win x14
9and3 Sep 19, 2024
ff6479d
WIP: workin on ci - canoot be tested with act locally since win x15
9and3 Sep 19, 2024
d86f3a4
WIP: workin on ci - canoot be tested with act locally since win x16
9and3 Sep 19, 2024
b170596
WIP: workin on ci - canoot be tested with act locally since win x17
9and3 Sep 19, 2024
a8f86ff
WIP: workin on ci - canoot be tested with act locally since win x18
9and3 Sep 19, 2024
7f46083
WIP: workin on ci - canoot be tested with act locally since win x19
9and3 Sep 19, 2024
2d81a3e
WIP: workin on ci - canoot be tested with act locally since win x20
9and3 Sep 19, 2024
259e3c9
WIP: workin on ci - canoot be tested with act locally since win x21
9and3 Sep 19, 2024
c0134f0
WIP: workin on ci - canoot be tested with act locally since win x22
9and3 Sep 19, 2024
48ff3da
WIP: workin on ci - canoot be tested with act locally since win x23
9and3 Sep 19, 2024
4f4547d
WIP: workin on ci - canoot be tested with act locally since win x24
9and3 Sep 19, 2024
353314d
WIP: workin on ci - canoot be tested with act locally since win x25
9and3 Sep 19, 2024
ecadd69
WIP: workin on ci - canoot be tested with act locally since win x26
9and3 Sep 19, 2024
5bd5cf5
CAP: yakerize ci and publishing working
9and3 Sep 19, 2024
91e3185
WIP: workin on ci - canoot be tested with act locally since win x27
9and3 Sep 19, 2024
713c72b
WIP: workin on ci - canoot be tested with act locally since win x28
9and3 Sep 19, 2024
ef83604
WIP: workin on ci - canoot be tested with act locally since win x29
9and3 Sep 19, 2024
5b49a48
WIP: workin on ci - canoot be tested with act locally since win x30
9and3 Sep 19, 2024
af1cb35
WIP: workin on ci - canoot be tested with act locally since win x31
9and3 Sep 19, 2024
243dc7a
WIP: workin on ci - canoot be tested with act locally since win x32
9and3 Sep 19, 2024
badf634
WIP: workin on ci - canoot be tested with act locally since win x33
9and3 Sep 19, 2024
c15ad8f
CAP: working version of pypi test and release
9and3 Sep 19, 2024
d89dbf5
WIP: workin on ci - canoot be tested with act locally since win x34
9and3 Sep 19, 2024
ac1e7d3
WIP: workin on ci - canoot be tested with act locally since win x35
9and3 Sep 19, 2024
cc37b50
MILESTONE: release publish ci ready
9and3 Sep 19, 2024
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
9 changes: 5 additions & 4 deletions .github/workflows/gh-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ jobs:
source: src/gh/components
target: build

- uses: actions/upload-artifact@v4
with:
name: ghuser-components
path: build
## for debug only
# - uses: actions/upload-artifact@v4
# with:
# name: ghuser-components
# path: build
350 changes: 350 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,350 @@
name: publish-release

on:
release:
types: [published]
workflow_dispatch:

jobs:
################################################################################
## Building
################################################################################
sync-version:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2

- name: Install Python and pythonnet
uses: actions/setup-python@v2
with:
python-version: '3.9.10'

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install invoke

- name: Update the version across the project and commit the changes
run: invoke versionize

- name: Install GitHub CLI
run: |
choco install gh
- name: Authenticate GitHub CLI
run: |
echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token

- name: Create a new branch and commit the version change
# Delete branch remotely version-sync-branch (if exists)
run: |
git fetch --prune
if git branch -r | grep -q 'origin/version-sync-branch'; then
git push origin --delete version-sync-branch
else
echo "Branch version-sync-branch does not exist."
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
# Create new branch and commit version change
- run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git checkout -b version-sync-branch
git commit -am "ACTION_BOT: Sync version for release"
git push --set-upstream origin version-sync-branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Close existing pull requests for version-sync-branch
- run: |
gh pr list --state open --head version-sync-branch --json number --jq '.[].number' | ForEach-Object { gh pr close $_ }
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: pwsh
# Create pull request
- run: |
gh pr create --title "ACTION_BOT: Sync version for release" --body "Sync version for release" --base main --head version-sync-branch --label ACTION_BOT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Merge pull request
- run: |
$pr = gh pr list --head version-sync-branch --json number --jq '.[0].number'
gh pr merge $pr --squash --delete-branch --admin
env:
GITHUB_TOKEN: ${{ secrets.DF_COBOT_PAT_TOKEN }}
shell: pwsh

build-ghusers:
runs-on: windows-latest
needs: sync-version

steps:
- uses: actions/checkout@v2
- uses: NuGet/[email protected]

- name: Install CPython and pythonnet package
run: |
choco install python --version=3.9.10
python -m pip install pythonnet==3.0.3
python -m pip install invoke

- name: create the build folder
run: mkdir build

- name: Flag the ghuser codes with the correct package version
run: invoke flagerize

- name: Invoke the componentizer
run: |
mkdir build/gh
invoke ghcomponentize

- uses: actions/upload-artifact@v4
with:
name: ghuser-components
path: build/gh

build-yak-package:
runs-on: windows-latest
needs: build-ghusers

steps:
- uses: actions/checkout@v2

- name: Install Python and pythonnet
uses: actions/setup-python@v2
with:
python-version: '3.9.10'

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install invoke
pip install pythonnet

- name: Download the ghuser components
uses: actions/download-artifact@v4
with:
name: ghuser-components
path: build/gh

- name: Build the yak package
run: invoke yakerize

- name: Save artifact the yak package as an artifact
uses: actions/upload-artifact@v4
with:
name: yak_package_artifact
path: build/yak/*.yak

#===============================================================================

pypi_build:
runs-on: windows-latest
needs: sync-version

steps:
- uses: actions/checkout@v4

- name: Setup conda environment
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: 3.9.1

- name: Create diff_check conda environment
run: conda env create -f environment.yml

- name: Activate diff_check conda environment
run: conda activate diff_check

- name: Cmake Configure
run: |
cmake -S . -B build -A x64 -DBUILD_PYTHON_MODULE=ON -DBUILD_TESTS=OFF -DRUN_TESTS=OFF
- name: CMake Build
run: cmake --build build --config Release

- name: Copying the dlls/pyd for python pypi package
run: |
copy ${{github.workspace}}/build/bin/Release/diffCheck.dll ${{github.workspace}}/src/gh/diffCheck/diffCheck/dlls
copy ${{github.workspace}}/build/bin/Release/Open3D.dll ${{github.workspace}}/src/gh/diffCheck/diffCheck/dlls
copy ${{github.workspace}}/build/Release/*.pyd ${{github.workspace}}/src/gh/diffCheck/diffCheck

- name: Build wheel
run: |
cd ${{github.workspace}}/src/gh/diffCheck/
python setup.py bdist_wheel
cd ${{github.workspace}}

- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: diffcheck_pypi_dist
path: ${{github.workspace}}/src/gh/diffCheck/dist/

################################################################################
## Publishing
################################################################################

publish_test_yak:
needs: build-yak-package
runs-on: windows-latest

steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Download artifact
uses: actions/download-artifact@v4
with:
name: yak_package_artifact
path: build/yak

- name: Publish to Yak test server
run: |
$YAK_FILE=$(ls *.yak)
echo "Yak file: $YAK_FILE"
..\..\invokes\yaker\exec\Yak.exe push --source https://test.yak.rhino3d.com $YAK_FILE
working-directory: build/yak
env:
YAK_TOKEN: ${{ secrets.YAK_DF_TOKEN }}
continue-on-error: true
- name: Verify the Yak test package
run: |
..\..\invokes\yaker\exec\Yak.exe search --source https://test.yak.rhino3d.com --all --prerelease script-sync
working-directory: build/yak
env:
YAK_TOKEN: ${{ secrets.YAK_DF_TOKEN }}

publish_to_yak:
needs: publish_test_yak
runs-on: windows-latest

steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Download artifact
uses: actions/download-artifact@v4
with:
name: yak_package_artifact
path: build/yak

- name: Publish to Yak server
run: |
$YAK_FILE=$(ls *.yak)
echo "Yak file: $YAK_FILE"
..\..\invokes\yaker\exec\Yak.exe push $YAK_FILE
working-directory: build/yak
env:
YAK_TOKEN: ${{ secrets.YAK_DF_TOKEN }}
# check the real release
- name: Verify the Yak test package
run: |
..\..\invokes\yaker\exec\Yak.exe search --all --prerelease script-sync
working-directory: build/yak
env:
YAK_TOKEN: ${{ secrets.YAK_DF_TOKEN }}

#===============================================================================

publish_test_pypi:
needs: pypi_build
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/diffCheck
permissions:
id-token: write

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: diffcheck_pypi_dist
path: dist/
- name: Publish distribution to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/

publish_to_pypi:
needs: publish_test_pypi
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/diffCheck
permissions:
id-token: write

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: diffcheck_pypi_dist
path: dist/

- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1


################################################################################
## Upload release artifacts
################################################################################
release_artifacts:
needs: [build-yak-package, pypi_build]
runs-on: ubuntu-latest
if: github.event_name == 'release'

steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Download yak artifact
uses: actions/download-artifact@v4
with:
name: yak_package_artifact
path: build/yak
- name: Download pypi dist artifact
uses: actions/download-artifact@v4
with:
name: diffcheck_pypi_dist

- name: Get YAK artifact path
id: get_yak_path
run: |
echo "::set-output name=yak_path::$(find build/yak -name '*.yak')"
shell: bash
- name: Get PyPI dist path
id: get_pypi_dist_path
run: |
echo "::set-output name=pypi_dist_path::$(find dist -name '*.whl')"
shell: bash
- name: Print YAK artifact path
run: |
echo ${{ steps.get_yak_path.outputs.yak_path }}
shell: bash
- name: Print PyPI dist path
run: |
echo ${{ steps.get_pypi_dist_path.outputs.pypi_dist_path }}
shell: bash

- name: Upload .yak artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ steps.get_yak_path.outputs.yak_path }}
asset_name: diffCheck.yak
asset_content_type: application/octet-stream
- name: Upload .whl artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ steps.get_pypi_dist_path.outputs.pypi_dist_path }}
asset_name: diffCheck-py-dist.whl
asset_content_type: application/octet-stream
17 changes: 11 additions & 6 deletions .github/workflows/pypi-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,21 @@ jobs:
- name: CMake Build
run: cmake --build build --config Release

#FIXME: here we are probably missing to copy the dlls and pyds before building the wheel
- name: Copying the dlls/pyd for python pypi package
run: |
copy ${{github.workspace}}/build/bin/Release/diffCheck.dll ${{github.workspace}}/src/gh/diffCheck/diffCheck/dlls
copy ${{github.workspace}}/build/bin/Release/Open3D.dll ${{github.workspace}}/src/gh/diffCheck/diffCheck/dlls
copy ${{github.workspace}}/build/Release/*.pyd ${{github.workspace}}/src/gh/diffCheck/diffCheck

- name: Build wheel
run: |
cd ${{github.workspace}}/src/gh/diffCheck/
python setup.py bdist_wheel
cd ${{github.workspace}}

- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: wheel
path: ${{github.workspace}}/src/gh/diffCheck/dist/
## for debug only
# - name: Upload wheel
# uses: actions/upload-artifact@v4
# with:
# name: wheel
# path: ${{github.workspace}}/src/gh/diffCheck/dist/
Loading
Loading