Skip to content

Commit d602253

Browse files
committed
feat(ci): add GitHub Actions workflow for building and publishing packages
- Add `.github/workflows/build-and-publish.yaml` to automate build and publish on push to `16.0` branch - Update `README.md` with corrected repository URL - Add demo data for `project_phase` and `project_phase_estimate` modules - Enhance task script with `build` and `publish` commands for package management - Improve UI by adding sequence handle to phase tree view and fixing context in task form - Hide timesheet error group in inherited task form for cleaner UI - Refactor task script for better readability and maintainability
1 parent 6bc5418 commit d602253

10 files changed

Lines changed: 172 additions & 51 deletions

File tree

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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Odoo modules extending the `project` module.
77
Clone this repo into the Odoo addons directory.
88

99
```bash
10-
git clone [email protected]:Mint-System/Odoo-Apps-project.git ./addons/project
10+
git clone [email protected]:Mint-System/Odoo-Apps-Project.git ./addons/project
1111
```
1212

1313
## Available modules

project_phase/__manifest__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@
1919
"application": False,
2020
"auto_install": False,
2121
"images": ["images/screen.png"],
22+
"demo": ["demo/demo.xml"],
2223
}

project_phase/demo/demo.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo>
3+
<record id="project_task_phase_demo_1" model="project.task.phase">
4+
<field name="name">Implementation</field>
5+
</record>
6+
</odoo>

project_phase/views/project_phase.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<field name="model">project.task.phase</field>
77
<field name="arch" type="xml">
88
<tree>
9+
<field name="sequence" widget="handle" />
910
<field name="name" />
1011
<field name="project_id" />
1112
<field name="user_id" />

project_phase/views/project_task.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<field name="inherit_id" ref="project.view_task_form2" />
1919
<field name="arch" type="xml">
2020
<xpath expr="//field[@name='project_id']" position="after">
21-
<field name="phase_id" />
21+
<field name="phase_id" context="{'default_project_id': proejct_id}" />
2222
</xpath>
2323
</field>
2424
</record>

project_phase_estimate/__manifest__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@
2020
"application": False,
2121
"auto_install": False,
2222
"images": ["images/screen.png"],
23+
"demo": ["demo/demo.xml"],
2324
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo>
3+
<record id="project_estimate_demo_1" model="project.estimate">
4+
<field name="project_id" ref="project.project_project_1" />
5+
<field name="phase_id" ref="project_phase.project_task_phase_demo_1" />
6+
<field name="planned_hours">56</field>
7+
</record>
8+
9+
<record id="project.project_1_task_6" model="project.task">
10+
<field name="phase_id" ref="project_phase.project_task_phase_demo_1" />
11+
</record>
12+
13+
</odoo>

project_phase_estimate/views/project_task.xml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<odoo>
33

44
<record id="view_task_form" model="ir.ui.view">
5-
<field name="name">project.task.form</field>
5+
<field name="name">project_phase_estimate.view_task_form2</field>
66
<field name="model">project.task</field>
77
<field name="inherit_id" ref="project.view_task_form2" />
88
<field name="arch" type="xml">
@@ -16,4 +16,18 @@
1616
</field>
1717
</record>
1818

19+
<record id="view_task_form2_inherited" model="ir.ui.view">
20+
<field name="name">project_phase_estimate.view_task_form2_inherited</field>
21+
<field name="model">project.task</field>
22+
<field name="inherit_id" ref="hr_timesheet.view_task_form2_inherited" />
23+
<field name="arch" type="xml">
24+
<xpath
25+
expr="//group[@name='timesheet_error']/../group[1]"
26+
position="attributes"
27+
>
28+
<attribute name="invisible">1</attribute>
29+
</xpath>
30+
</field>
31+
</record>
32+
1933
</odoo>

task

Lines changed: 111 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,150 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
set -e
33

4-
if [[ -a ".env" ]]; then
4+
if [[ -a '.env' ]]; then
55
source .env
66
fi
77

8-
function help-table() {
9-
CMD_WIDTH=10
10-
OPT_WIDTH=6
11-
DESC_WIDTH=40
12-
COLUMN="| %-${CMD_WIDTH}s | %-${OPT_WIDTH}s | %-${DESC_WIDTH}s |\n"
13-
14-
printf "$COLUMN" "Command" "Option" "Description"
15-
echo "|$(printf '%*s' $((CMD_WIDTH + 2)) '' | tr ' ' '-')|$(printf '%*s' $((OPT_WIDTH + 2)) '' | tr ' ' '-')|$(printf '%*s' $((DESC_WIDTH + 2)) '' | tr ' ' '-')|"
16-
printf "$COLUMN" "all" "" "Run all tasks."
17-
printf "$COLUMN" "install" "" "Setup the local environment."
18-
printf "$COLUMN" "lint" "" "Run pre-commit."
19-
printf "$COLUMN" "docs" "" "Update index.html."
8+
help-table() {
9+
local cmd_width=10
10+
local opt_width=6
11+
local desc_width=40
12+
local column="| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n"
13+
14+
printf "$column" 'Command' 'Option' 'Description'
15+
echo "|$(printf '%*s' $((cmd_width + 2)) '' | tr ' ' '-')|$(printf '%*s' $((opt_width + 2)) '' | tr ' ' '-')|$(printf '%*s' $((desc_width + 2)) '' | tr ' ' '-')|"
16+
printf "$column" 'all' '' 'Run all tasks.'
17+
printf "$column" 'install' '' 'Setup the local environment.'
18+
printf "$column" 'lint' '' 'Run pre-commit.'
19+
printf "$column" 'build' '' 'Build python packages with whool.'
20+
printf "$column" 'publish' '' 'Publish python packages to PyPi.'
21+
printf "$column" 'docs' '' 'Update index.html.'
2022
}
2123

22-
function help() {
24+
help() {
2325
echo
24-
if [ -n "$1" ]; then
26+
if [[ -n "$1" ]]; then
2527
help-table | grep -i "$1" | column -t -s'|'
2628
else
27-
echo "task <command> [options]"
29+
echo 'task <command> [options]'
2830
echo
29-
echo "commands:"
31+
echo 'commands:'
3032
echo
3133
help-table
3234
fi
3335
echo
3436
}
3537

36-
if [ -d "$HOME/taskfile.build/bin" ]; then
38+
if [[ -d "$HOME/taskfile.build/bin" ]]; then
3739
for file in "$HOME/taskfile.build/bin/"*; do
38-
if [ -f "$file" ]; then
40+
if [[ -f "$file" ]]; then
3941
source "$file"
4042
fi
4143
done
4244
fi
4345

44-
function install() {
45-
echo "Setup venv and install python dependencies"
46-
uv venv env
47-
source env/bin/activate
46+
install() {
47+
echo 'Setup .venv and install python dependencies'
48+
uv venv --clear
49+
source .venv/bin/activate
4850
uv pip install pre-commit git+https://github.com/OCA/maintainer-tools
4951
}
5052

51-
function lint() {
52-
source env/bin/activate
53+
lint() {
54+
source .venv/bin/activate
5355

54-
echo "Run pre-commit"
56+
echo 'Run pre-commit'
5557
pre-commit run --all-files --show-diff-on-failure --color=always
5658
}
5759

58-
function docs() {
59-
source env/bin/activate
60+
build() {
61+
source .venv/bin/activate
62+
63+
local root_dir="$(pwd)"
64+
local metapackage_dir="$root_dir/setup/_metapackage"
65+
local publish_dir="$root_dir/dist"
66+
mkdir -p "$publish_dir"
67+
rm -rf "$publish_dir"/*
68+
69+
local server_name="$(basename "$root_dir")"
70+
local metapackage_name="odoo-apps-$(echo "$server_name" | sed 's/_/-/g')"
71+
oca-gen-metapackage "$metapackage_name"
72+
73+
local addons=()
74+
mapfile -t addons < <(find . -maxdepth 2 -type f -name 'pyproject.toml' | xargs dirname | sed 's|^\./||')
75+
for addon in "${addons[@]}"; do
76+
cd "$root_dir/$addon"
77+
echo "Building $addon"
78+
uv build
79+
cp dist/*.whl "$publish_dir/"
80+
cp dist/*.tar.gz "$publish_dir/"
81+
cd "$root_dir"
82+
done
83+
84+
echo 'Installing local wheels for metapackage resolution...'
85+
uv pip install "$publish_dir"/*.whl 2>/dev/null || true
86+
87+
cd "$metapackage_dir"
88+
echo "Building $metapackage_name"
89+
uv build
90+
cp dist/*.whl "$publish_dir/"
91+
cp dist/*.tar.gz "$publish_dir/"
92+
93+
ls "$publish_dir/"
94+
}
95+
96+
publish() {
97+
source .venv/bin/activate
98+
local root_dir="$(pwd)"
99+
local publish_dir="$root_dir/dist"
100+
101+
set +e
102+
echo "Publishing from $publish_dir to PyPI..."
60103

61-
echo "Update index.html for all modules"
62-
for MODULE in ./*; do
63-
if [ -f "$MODULE/README.rst" ]; then
64-
cd "$MODULE" || exit
104+
for wheel in "$publish_dir"/*.whl; do
105+
if [[ ! -f "$wheel" ]]; then
106+
continue
107+
fi
108+
109+
echo "Publishing: $wheel"
110+
uv publish "$wheel" --username '__token__' --password "$PYPI_TOKEN"
111+
112+
if (( $? != 0 )); then
113+
echo "Failed to publish $wheel."
114+
fi
115+
done
116+
117+
echo 'All wheels published successfully.'
118+
}
119+
120+
docs() {
121+
source .venv/bin/activate
122+
123+
echo 'Update index.html for all modules'
124+
for module in ./*; do
125+
if [[ -f "$module/README.rst" ]]; then
126+
cd "$module" || exit
65127
rst2html5 README.rst static/description/index.html
66128
cd .. || exit
67129
fi
68130
done
69131

70132
# Find marker in readme and clear content after
71-
echo "Clear modules table in README.md"
72-
MARKER="## Available modules"
73-
sed -i "/$MARKER/Q" "README.md"
74-
echo "$MARKER" >> "README.md"
75-
echo "" >> "README.md"
76-
echo "| Module | Summary |" >> "README.md"
77-
echo "| --- | --- |" >> "README.md"
78-
79-
MANIFEST_FILES="./*/__manifest__.py"
80-
for MANIFEST_FILE in $MANIFEST_FILES; do
81-
MODULE_DIR=$(dirname "$MANIFEST_FILE")
82-
MODULE_NAME=$(basename "$MODULE_DIR")
83-
echo "Add summary of $MODULE_NAME to readme file."
84-
SUMMARY=$(grep 'summary' "$MANIFEST_FILE" -A 1 | tail -1)
85-
echo "| [$MODULE_NAME]($MODULE_NAME) | $SUMMARY |" >> "README.md"
133+
echo 'Clear modules table in README.md'
134+
local marker='## Available modules'
135+
sed -i "/$marker/Q" 'README.md'
136+
echo "$marker" >> 'README.md'
137+
echo '' >> 'README.md'
138+
echo '| Module | Summary |' >> 'README.md'
139+
echo '| --- | --- |' >> 'README.md'
140+
141+
local manifest_files='./*/__manifest__.py'
142+
for manifest_file in $manifest_files; do
143+
local module_dir=$(dirname "$manifest_file")
144+
local module_name=$(basename "$module_dir")
145+
echo "Add summary of $module_name to readme file."
146+
local summary=$(grep 'summary' "$manifest_file" -A 1 | tail -1)
147+
echo "| [$module_name]($module_name) | $summary |" >> 'README.md'
86148
done
87149
}
88150

@@ -94,6 +156,7 @@ else
94156
install
95157
lint
96158
docs
159+
build
97160
;;
98161
*)
99162
echo "Unknown command: $1"

0 commit comments

Comments
 (0)