Skip to content

Commit eb06b5d

Browse files
Add pre-build and post-build command options (#6)
1 parent ff39995 commit eb06b5d

3 files changed

Lines changed: 37 additions & 20 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ Create Python distribution packages: source, wheel and Debian packages
2525

2626
- `package-version`: Version of the package to create (if not provided, will use the given git tag)
2727
- `is-cross-platform`: Create cross-platform packages using Docker buildx and QEMU (default: `false`)
28+
- `pre-build-command`: Command to run before the package creation
29+
- `post-build-command`: Command to run after the package creation
2830

2931
### Platform independent or native package creation
3032

action.yml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ inputs:
1313
description: 'Is cross platform build?'
1414
required: false
1515
default: 'false'
16+
pre-build-command:
17+
description: 'Command to execute before packaging'
18+
required: false
19+
post-build-command:
20+
description: 'Command to execute after packaging'
21+
required: false
1622

1723
python-version:
1824
description: 'Python version'
@@ -73,18 +79,26 @@ runs:
7379
echo "Error: Invalid version"
7480
exit 1
7581
fi
82+
echo "GIT_TAG=v$VERSION" >> $GITHUB_ENV
7683
- name: Update version in setup.py
7784
shell: bash
7885
run: sed -i "s/version='.*',/version='$VERSION',/" setup.py
7986
- if: ${{ inputs.debian-dist-type == 'application' }}
80-
name: Update version in debian/changelog
87+
name: Check and update version in debian/changelog
8188
shell: bash
8289
run: |
83-
sudo apt-get update
84-
sudo apt-get install -y devscripts
85-
export DEBEMAIL="action@github.com"
86-
export DEBFULLNAME="GitHub Action"
87-
dch -v $VERSION -D stable "Release $VERSION"
90+
if ! grep -q "($VERSION)" debian/changelog; then
91+
sudo apt-get update
92+
sudo apt-get install -y devscripts
93+
export DEBEMAIL="action@github.com"
94+
export DEBFULLNAME="GitHub Action"
95+
dch -v $VERSION -D stable "Release $VERSION"
96+
fi
97+
98+
- if: ${{ inputs.pre-build-command }}
99+
name: Run pre-build command
100+
shell: bash
101+
run: ${{ inputs.pre-build-command }}
88102

89103
- if: ${{ inputs.is-cross-platform != 'true' }}
90104
name: Build native or platform independent packages
@@ -106,6 +120,11 @@ runs:
106120
devcontainer-config: ${{ inputs.devcontainer-config }}
107121
devcontainer-command: ${{ inputs.devcontainer-command }}
108122

123+
- if: ${{ inputs.post-build-command }}
124+
name: Run post-build command
125+
shell: bash
126+
run: ${{ inputs.post-build-command }}
127+
109128
- name: Commit changes
110129
shell: bash
111130
run: |

native/action.yml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ runs:
3838
python -m pip install --upgrade pip
3939
pip install .
4040
mkdir -p dist
41+
- if: ${{ inputs.add-source-dist == 'true' }}
42+
name: Create source distribution
43+
shell: bash
44+
run: python setup.py sdist
45+
- if: ${{ inputs.add-wheel-dist == 'true' }}
46+
name: Create wheel distribution
47+
shell: bash
48+
run: |
49+
pip install wheel
50+
python setup.py bdist_wheel
4151
- if: ${{ inputs.debian-dist-type == 'library' }}
4252
name: Create debian distribution (library)
4353
shell: bash
@@ -68,17 +78,3 @@ runs:
6878
6979
# Copy debian package to dist folder if generated out of tree
7080
cp ../*.deb dist || true
71-
72-
# Keep only .deb files
73-
shopt -s extglob
74-
rm -f dist/!(*.deb)
75-
- if: ${{ inputs.add-source-dist == 'true' }}
76-
name: Create source distribution
77-
shell: bash
78-
run: python setup.py sdist
79-
- if: ${{ inputs.add-wheel-dist == 'true' }}
80-
name: Create wheel distribution
81-
shell: bash
82-
run: |
83-
pip install wheel
84-
python setup.py bdist_wheel

0 commit comments

Comments
 (0)