Skip to content

Commit 08b36b2

Browse files
committed
feat(setup): build and publish
1 parent d3ca4bc commit 08b36b2

File tree

3 files changed

+105
-2
lines changed

3 files changed

+105
-2
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
on:
2+
push:
3+
branches:
4+
- "18.0"
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Git checkout
11+
uses: actions/checkout@v4
12+
- name: Install uv
13+
uses: astral-sh/setup-uv@v6
14+
- name: Install
15+
run: ./task install
16+
- name: Build
17+
run: ./task build
18+
- name: Publish
19+
run: ./task publish
20+
env:
21+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}

setup/_metapackage/pyproject.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[project]
2+
name = "odoo-apps-server-tools"
3+
version = "18.0.20251017.0"
4+
dependencies = [
5+
"odoo-addon-auth_impersonate_user==18.0.*",
6+
"odoo-addon-auth_totp_ip_check==18.0.*",
7+
"odoo-addon-base_action_manager_access==18.0.*",
8+
"odoo-addon-base_db_anonymization==18.0.*",
9+
"odoo-addon-base_external_mssql==18.0.*",
10+
"odoo-addon-mail_format_with_parent==18.0.*",
11+
"odoo-addon-mail_server_filter==18.0.*",
12+
"odoo-addon-mail_service_users==18.0.*",
13+
"odoo-addon-prometheus_exporter==18.0.*",
14+
"odoo-addon-server_config_environment==18.0.*",
15+
]
16+
classifiers=[
17+
"Programming Language :: Python",
18+
"Framework :: Odoo",
19+
"Framework :: Odoo :: 18.0",
20+
]

task

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ function help-table() {
1616
printf "$COLUMN" "all" "" "Run all tasks."
1717
printf "$COLUMN" "install" "" "Setup the local environment."
1818
printf "$COLUMN" "lint" "" "Run pre-commit."
19+
printf "$COLUMN" "build" "" "Build python packages with whool."
20+
printf "$COLUMN" "publish" "" "Publish python packages to PyPi."
1921
printf "$COLUMN" "docs" "" "Update index.html."
2022
printf "$COLUMN" "source" "" "Source the Python virtual env."
2123
printf "$COLUMN" "version" "" "Show version of required tools."
@@ -40,10 +42,10 @@ function version() {
4042
}
4143

4244
function install() {
43-
echo "Setup venv and install python dependencies"
45+
echo "Setup venv and install OCA maintainer tools"
4446
uv venv env
4547
source env/bin/activate
46-
uv pip install pre-commit rst2html5
48+
uv pip install git+https://github.com/OCA/maintainer-tools
4749
}
4850

4951
function lint() {
@@ -53,6 +55,66 @@ function lint() {
5355
pre-commit run --all-files --show-diff-on-failure --color=always
5456
}
5557

58+
build() {
59+
source env/bin/activate
60+
61+
ROOT_DIR="$(pwd)"
62+
METAPACKAGE_DIR="$ROOT_DIR/setup/_metapackage"
63+
PUBLISH_DIR="$ROOT_DIR/dist"
64+
mkdir -p "$PUBLISH_DIR"
65+
rm -rf "$PUBLISH_DIR"/*
66+
67+
SERVER_NAME="$(basename "$ROOT_DIR")"
68+
METAPACKAGE_NAME="odoo-apps-$(echo "$SERVER_NAME" | sed 's/_/-/g')"
69+
oca-gen-metapackage "$METAPACKAGE_NAME"
70+
71+
ADDONS=()
72+
mapfile -t ADDONS < <(find . -maxdepth 2 -type f -name "pyproject.toml" | xargs dirname | sed 's|^\./||')
73+
for ADDON in "${ADDONS[@]}"; do
74+
cd "$ROOT_DIR/$ADDON"
75+
echo "Building $ADDON"
76+
uv build
77+
cp dist/*.whl "$PUBLISH_DIR/"
78+
cp dist/*.tar.gz "$PUBLISH_DIR/"
79+
cd "$ROOT_DIR"
80+
done
81+
82+
echo "Installing local wheels for metapackage resolution..."
83+
uv pip install "$PUBLISH_DIR"/*.whl 2>/dev/null || true
84+
85+
cd "$METAPACKAGE_DIR"
86+
echo "Building $METAPACKAGE_NAME"
87+
uv build
88+
cp dist/*.whl "$PUBLISH_DIR/"
89+
cp dist/*.tar.gz "$PUBLISH_DIR/"
90+
91+
ls "$PUBLISH_DIR/"
92+
}
93+
94+
publish() {
95+
source env/bin/activate
96+
ROOT_DIR="$(pwd)"
97+
PUBLISH_DIR="$ROOT_DIR/dist"
98+
99+
set +e
100+
echo "Publishing from $PUBLISH_DIR to PyPI..."
101+
102+
for WHEEL in "$PUBLISH_DIR"/*.whl; do
103+
if [ ! -f "$WHEEL" ]; then
104+
continue
105+
fi
106+
107+
echo "Publishing: $WHEEL"
108+
uv publish "$WHEEL" --username "__token__" --password "$PYPI_TOKEN"
109+
110+
if [ $? -ne 0 ]; then
111+
echo "Failed to publish $WHEEL."
112+
fi
113+
done
114+
115+
echo "All wheels published successfully."
116+
}
117+
56118
function docs() {
57119
source env/bin/activate
58120

0 commit comments

Comments
 (0)