Skip to content

Commit 9247a78

Browse files
Fixes and improvements (#10)
1 parent dc657ec commit 9247a78

13 files changed

Lines changed: 155 additions & 95 deletions

File tree

.github/workflows/test_devcontainer.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ jobs:
1212

1313
steps:
1414
- uses: actions/checkout@v4
15+
- name: Install packaging tools
16+
run: |
17+
git clone https://github.com/EffectiveRange/packaging-tools.git /tmp/packaging-tools
18+
sudo bash /tmp/packaging-tools/python/install.sh
1519
- name: Set up test environment
1620
run: |
1721
cp -a test/. .
@@ -22,13 +26,14 @@ jobs:
2226
with:
2327
container-platform: 'linux/arm/v7'
2428
container-config: 'arm32v7'
25-
packaging-command: python3 setup.py sdist bdist_wheel
29+
debian-dist-type: 'fpm-deb'
2630

2731
- name: Assert packages have created
2832
run: |
2933
set -e
3034
ls -l dist
3135
ls dist/test_module-1.0.0-py3-none-any.whl
36+
ls dist/python3-test-module_1.0.0_all.deb
3237
3338
test-devcontainer-arm64v8:
3439
name: Test creating arm64v8 packages
@@ -37,6 +42,10 @@ jobs:
3742

3843
steps:
3944
- uses: actions/checkout@v4
45+
- name: Install packaging tools
46+
run: |
47+
git clone https://github.com/EffectiveRange/packaging-tools.git /tmp/packaging-tools
48+
sudo bash /tmp/packaging-tools/python/install.sh
4049
- name: Set up test environment
4150
run: |
4251
cp -a test/. .
@@ -47,13 +56,14 @@ jobs:
4756
with:
4857
container-platform: 'linux/arm64'
4958
container-config: 'arm64v8'
50-
packaging-command: python3 setup.py sdist bdist_wheel
59+
debian-dist-type: 'dh-virtualenv'
5160

5261
- name: Assert packages have created
5362
run: |
5463
set -e
5564
ls -l dist
5665
ls dist/test_module-1.0.0-py3-none-any.whl
66+
ls dist/test-module_1.0.0-1_all.deb
5767
5868
test-devcontainer-amd64:
5969
name: Test creating amd64 packages
@@ -62,6 +72,10 @@ jobs:
6272

6373
steps:
6474
- uses: actions/checkout@v4
75+
- name: Install packaging tools
76+
run: |
77+
git clone https://github.com/EffectiveRange/packaging-tools.git /tmp/packaging-tools
78+
sudo bash /tmp/packaging-tools/python/install.sh
6579
- name: Set up test environment
6680
run: |
6781
cp -a test/. .
@@ -70,10 +84,13 @@ jobs:
7084
- name: Create packages
7185
uses: ./devcontainer
7286
with:
73-
packaging-command: python3 setup.py sdist bdist_wheel
87+
add-wheel-dist: 'false'
88+
debian-dist-command: 'pack_python . --all'
7489

7590
- name: Assert packages have created
7691
run: |
7792
set -e
7893
ls -l dist
7994
ls dist/test_module-1.0.0-py3-none-any.whl
95+
ls dist/python3-test-module_1.0.0_all.deb
96+
ls dist/test-module_1.0.0-1_all.deb

.github/workflows/test_main.yml

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ on:
55
branches: [ "main" ]
66

77
jobs:
8-
test-main-fpm-deb:
9-
name: Test creating packages (fpm-deb)
8+
test-main-native-fpm-deb:
9+
name: Test creating native packages (fpm-deb)
1010

1111
runs-on: ubuntu-latest
1212

@@ -31,8 +31,8 @@ jobs:
3131
ls dist/test_module-1.1.0-py3-none-any.whl
3232
ls dist/python3-test-module_1.1.0_all.deb
3333
34-
test-main-dh-virtualenv:
35-
name: Test creating packages (dh-virtualenv)
34+
test-main-dh-native-virtualenv:
35+
name: Test creating native packages (dh-virtualenv)
3636

3737
runs-on: ubuntu-latest
3838

@@ -57,8 +57,8 @@ jobs:
5757
ls dist/test_module-1.1.0-py3-none-any.whl
5858
ls dist/test-module_1.1.0-1_all.deb
5959
60-
test-main-devcontainer:
61-
name: Test creating packages (devcontainer)
60+
test-main-devcontainer-fpm-deb:
61+
name: Test creating packages in devcontainer (fpm-deb)
6262

6363
runs-on: ubuntu-latest
6464

@@ -76,11 +76,39 @@ jobs:
7676
use-devcontainer: 'true'
7777
container-platform: 'linux/arm64'
7878
container-config: 'arm64v8'
79-
packaging-command: python3 setup.py sdist bdist_wheel
79+
debian-dist-type: 'fpm-deb'
8080

8181
- name: Assert packages have created
8282
run: |
8383
set -e
8484
ls -l dist
8585
ls dist/test-module-1.1.0.tar.gz
8686
ls dist/test_module-1.1.0-py3-none-any.whl
87+
ls dist/python3-test-module_1.1.0_all.deb
88+
89+
test-main-devcontainer-dh-virtualenv:
90+
name: Test creating packages in devcontainer (dh-virtualenv)
91+
92+
runs-on: ubuntu-latest
93+
94+
steps:
95+
- uses: actions/checkout@v4
96+
- name: Set up test environment
97+
run: |
98+
cp -a test/. .
99+
rm -rf dist
100+
101+
- name: Create packages
102+
uses: ./
103+
with:
104+
package-version: '1.1.0'
105+
use-devcontainer: 'true'
106+
debian-dist-type: 'dh-virtualenv'
107+
108+
- name: Assert packages have created
109+
run: |
110+
set -e
111+
ls -l dist
112+
ls dist/test-module-1.1.0.tar.gz
113+
ls dist/test_module-1.1.0-py3-none-any.whl
114+
ls dist/test-module_1.1.0-1_all.deb

.github/workflows/test_native.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Install packaging tools
1616
run: |
1717
git clone https://github.com/EffectiveRange/packaging-tools.git /tmp/packaging-tools
18-
echo "/tmp/packaging-tools/python" >> $GITHUB_PATH
18+
sudo bash /tmp/packaging-tools/python/install.sh
1919
- name: Set up test environment
2020
run: |
2121
cp -a test/. .
@@ -43,7 +43,7 @@ jobs:
4343
- name: Install packaging tools
4444
run: |
4545
git clone https://github.com/EffectiveRange/packaging-tools.git /tmp/packaging-tools
46-
echo "/tmp/packaging-tools/python" >> $GITHUB_PATH
46+
sudo bash /tmp/packaging-tools/python/install.sh
4747
- name: Set up test environment
4848
run: |
4949
cp -a test/. .
@@ -72,7 +72,7 @@ jobs:
7272
- name: Install packaging tools
7373
run: |
7474
git clone https://github.com/EffectiveRange/packaging-tools.git /tmp/packaging-tools
75-
echo "/tmp/packaging-tools/python" >> $GITHUB_PATH
75+
sudo bash /tmp/packaging-tools/python/install.sh
7676
- name: Set up test environment
7777
run: |
7878
cp -a test/. .
@@ -100,7 +100,7 @@ jobs:
100100
- name: Install packaging tools
101101
run: |
102102
git clone https://github.com/EffectiveRange/packaging-tools.git /tmp/packaging-tools
103-
echo "/tmp/packaging-tools/python" >> $GITHUB_PATH
103+
sudo bash /tmp/packaging-tools/python/install.sh
104104
- name: Set up test environment
105105
run: |
106106
cp -a test/. .
@@ -110,11 +110,11 @@ jobs:
110110
uses: ./native
111111
with:
112112
debian-dist-type: 'dh-virtualenv'
113-
debian-dist-command: 'dpkg-buildpackage -us -ui -uc -tc'
113+
debian-dist-command: 'pack_python . -s dh-virtualenv -o dist'
114114

115115
- name: Assert packages have created
116116
run: |
117117
set -e
118118
ls -l dist
119119
ls dist/test_module-1.0.0-py3-none-any.whl
120-
ls dist/test-module_1.0.0_amd64.deb
120+
ls dist/test-module_1.0.0-1_all.deb

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,20 @@ Create Python distribution packages: source, wheel and Debian packages
3434
- `python-version`: Python version to use for the package creation (default: `3.9`)
3535
- `add-wheel-dist`: Add wheel distribution to the package creation (default: `true`)
3636
- `debian-dist-type`: Type of the Debian package to create: `fpm-deb`/`dh-virtualenv`/`none` (default: `none`)
37-
- `debian-dist-command`: Command to run for the Debian package creation (default: `pack_python . -s fpm-deb` or `pack_python . -s dh-virtualenv`)
37+
- `debian-dist-command`: Command to run for the Debian package creation
3838

3939
### Cross-platform package creation
4040

41+
- `add-wheel-dist`: Add wheel distribution to the package creation (default: `true`)
42+
- `debian-dist-type`: Type of the Debian package to create: `fpm-deb`/`dh-virtualenv`/`none` (default: `none`)
43+
- `debian-dist-command`: Command to run for the Debian package creation
4144
- `docker-registry`: Docker registry to use (default: `docker.io`)
4245
- `docker-username`: Docker registry username
4346
- `docker-password`: Docker registry password
4447
- `container-platform`: Devcontainer platform (eg. `linux/amd64,linux/arm64,linux/arm/v7`, default: `linux/amd64`)
4548
- `container-config`: Devcontainer configuration selector `.devcontainer/<config>/devcontainer.json` (if not
4649
specified, it will use `.devcontainer/devcontainer.json`)
4750
- `packaging-folder`: Optional subfolder for running the packaging command (default: `.`)
48-
- `packaging-command`: Command to run in the devcontainer
4951

5052
## Outputs
5153

@@ -106,5 +108,5 @@ jobs:
106108
docker-password: ${{ secrets.DOCKERHUB_TOKEN }}
107109
container-platform: 'linux/arm/v7'
108110
container-config: 'arm32v7'
109-
packaging-command: 'pack_python . --all'
111+
debian-dist-command: 'pack_python . --all'
110112
```

action.yml

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,17 @@ inputs:
1313
description: 'Build packages using devcontainer'
1414
required: false
1515
default: 'false'
16-
add-source-dist:
17-
description: 'Should create source distribution?'
18-
required: false
19-
default: 'true'
2016
pre-build-command:
2117
description: 'Command to execute before packaging'
2218
required: false
2319
post-build-command:
2420
description: 'Command to execute after packaging'
2521
required: false
26-
27-
python-version:
28-
description: 'Python version'
22+
add-source-dist:
23+
description: 'Should create source distribution?'
2924
required: false
30-
default: '3.9'
25+
default: 'true'
26+
3127
add-wheel-dist:
3228
description: 'Should create wheel distribution?'
3329
required: false
@@ -37,9 +33,14 @@ inputs:
3733
required: false
3834
default: 'none'
3935
debian-dist-command:
40-
description: 'Debian build command'
36+
description: 'Debian packaging custom command'
4137
required: false
4238

39+
python-version:
40+
description: 'Python version'
41+
required: false
42+
default: '3.9'
43+
4344
docker-registry:
4445
description: 'Docker registry'
4546
required: false
@@ -58,9 +59,10 @@ inputs:
5859
description: 'Devcontainer config selector (eg. architecture, OS, etc.)'
5960
required: false
6061
default: '.'
61-
packaging-command:
62-
description: 'Devcontainer run command'
62+
packaging-folder:
63+
description: 'Optional subfolder to run packaging command'
6364
required: false
65+
default: '.'
6466

6567
outputs:
6668
upload-name:
@@ -70,10 +72,13 @@ outputs:
7072
runs:
7173
using: 'composite'
7274
steps:
73-
- name: Symlink current Actions repo
74-
working-directory: ${{ github.action_path }}
75+
- name: Symlink current action repo
76+
env:
77+
action_path: ${{ github.action_path }}
7578
shell: bash
76-
run: ln -fs $(realpath ../) ${{ github.workspace }}/
79+
run: |
80+
ln -fs ${{ env.action_path }} .github/actions
81+
7782
- name: Set up environment
7883
id: set-env
7984
shell: bash
@@ -95,7 +100,7 @@ runs:
95100
shell: bash
96101
run: |
97102
git clone https://github.com/EffectiveRange/packaging-tools.git /tmp/packaging-tools
98-
echo "/tmp/packaging-tools/python" >> $GITHUB_PATH
103+
sudo bash /tmp/packaging-tools/python/install.sh
99104
100105
- if: ${{ inputs.pre-build-command }}
101106
name: Run pre-build command
@@ -109,24 +114,30 @@ runs:
109114

110115
- if: ${{ inputs.use-devcontainer != 'true' }}
111116
name: Build native packages
112-
uses: ./native
117+
uses: ./.github/actions/native
113118
with:
114119
python-version: ${{ inputs.python-version }}
115-
add-source-dist: ${{ inputs.add-source-dist }}
116120
add-wheel-dist: ${{ inputs.add-wheel-dist }}
117121
debian-dist-type: ${{ inputs.debian-dist-type }}
118122
debian-dist-command: ${{ inputs.debian-dist-command }}
119123

120124
- if: ${{ inputs.use-devcontainer == 'true' }}
121125
name: Build packages using a devcontainer
122-
uses: ./devcontainer
126+
uses: ./.github/actions/devcontainer
123127
with:
128+
add-wheel-dist: ${{ inputs.add-wheel-dist }}
129+
debian-dist-type: ${{ inputs.debian-dist-type }}
130+
debian-dist-command: ${{ inputs.debian-dist-command }}
124131
docker-registry: ${{ inputs.docker-registry }}
125132
docker-username: ${{ inputs.docker-username }}
126133
docker-password: ${{ inputs.docker-password }}
127134
container-platform: ${{ inputs.container-platform }}
128135
container-config: ${{ inputs.container-config }}
129-
packaging-command: ${{ inputs.packaging-command }}
136+
packaging-folder: ${{ inputs.packaging-folder }}
137+
138+
- name: Unlink the action repository
139+
run: rm -f .github/actions
140+
shell: bash
130141

131142
- if: ${{ inputs.post-build-command }}
132143
name: Run post-build command

0 commit comments

Comments
 (0)