Skip to content

Commit 8bb7c86

Browse files
committed
🧪 Add a PROJECT_NAME var to CI/CD definition
1 parent 88b9287 commit 8bb7c86

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

.github/workflows/ci-cd.yml

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ env:
7676
PIP_DISABLE_PIP_VERSION_CHECK: 1 # Hide "there's a newer pip" message
7777
PIP_NO_PYTHON_VERSION_WARNING: 1 # Hide "this Python is deprecated" message
7878
PIP_NO_WARN_SCRIPT_LOCATION: 1 # Hide "script dir is not in $PATH" message
79+
PROJECT_NAME: ansible-pylibssh
7980
PY_COLORS: 1 # Recognized by the `py` package, dependency of `pytest`
8081
TOX_PARALLEL_NO_SPINNER: 1 # Disable tox's parallel run spinner animation
8182
TOX_TESTENV_PASSENV: >- # Make tox-wrapped tools see color requests
@@ -306,19 +307,22 @@ jobs:
306307
307308
FILE_APPEND_MODE = 'a'
308309
310+
whl_file_prj_base_name = '${{ env.PROJECT_NAME }}'.replace('-', '_')
311+
sdist_file_prj_base_name = whl_file_prj_base_name.replace('.', '_')
312+
309313
with Path(environ['GITHUB_OUTPUT']).open(
310314
mode=FILE_APPEND_MODE,
311315
) as outputs_file:
312316
print(
313-
"sdist=ansible-pylibssh-${{
317+
"sdist=${{ env.PROJECT_NAME }}-${{
314318
steps.request-check.outputs.release-requested == 'true'
315319
&& github.event.inputs.release-version
316320
|| steps.scm-version.outputs.dist-version
317321
}}.tar.gz",
318322
file=outputs_file,
319323
)
320324
print(
321-
"wheel=ansible_pylibssh-${{
325+
f"wheel={whl_file_prj_base_name !s}-${{
322326
steps.request-check.outputs.release-requested == 'true'
323327
&& github.event.inputs.release-version
324328
|| steps.scm-version.outputs.dist-version
@@ -491,7 +495,7 @@ jobs:
491495
-e 's/:gh:`\([-.a-zA-Z0-9]\+\)`/https:\/\/github.com\/\1/g'
492496
-e 's/:\(issue\|pr\):`\([0-9]\+\)`/#\2/g'
493497
-e 's/:user:`\([-.a-zA-Z0-9]\+\)`/@\1/g'
494-
-e 's/|project|/ansible-pylibssh/g'
498+
-e 's/|project|/${{ env.PROJECT_NAME }}/g'
495499
'${{ needs.pre-setup.outputs.changelog-draft-name-rst }}'
496500
shell: bash
497501
- name: Install pandoc via apt
@@ -970,7 +974,7 @@ jobs:
970974
run: >-
971975
sed -i
972976
"s#^\(Version:\s\+\).*#\1${{ needs.pre-setup.outputs.dist-version }}#"
973-
packaging/rpm/ansible-pylibssh.spec
977+
packaging/rpm/${{ env.PROJECT_NAME }}.spec
974978
975979
- name: Download all the dists # because `rpmlint` executes the spec file
976980
uses: actions/download-artifact@v4
@@ -980,7 +984,7 @@ jobs:
980984
merge-multiple: true
981985

982986
- name: Lint the RPM spec file
983-
run: rpmlint packaging/rpm/ansible-pylibssh.spec
987+
run: rpmlint packaging/rpm/${{ env.PROJECT_NAME }}.spec
984988

985989
- name: Copy sdist to the sources dir
986990
run: >-
@@ -1046,26 +1050,26 @@ jobs:
10461050
}}.noarch.rpm
10471051
10481052
- name: Install static build requirements
1049-
run: dnf builddep --assumeyes --spec packaging/rpm/ansible-pylibssh.spec
1053+
run: dnf builddep --assumeyes --spec packaging/rpm/${{ env.PROJECT_NAME }}.spec
10501054

10511055
- name: Fetch sources and patches
10521056
run: >-
10531057
spectool --all --get-files --sourcedir
1054-
packaging/rpm/ansible-pylibssh.spec
1058+
packaging/rpm/${{ env.PROJECT_NAME }}.spec
10551059
10561060
- name: Resolve and install dynamic build deps and build an SRPM
10571061
# Ref: https://github.com/rpm-software-management/rpm/commit/58dcfdd
10581062
run: |
10591063
while :
10601064
do
10611065
set +e
1062-
rpmbuild -br packaging/rpm/ansible-pylibssh.spec
1066+
rpmbuild -br packaging/rpm/${{ env.PROJECT_NAME }}.spec
10631067
rc="$?"
10641068
[ "${rc}" -eq 0 ] && break
10651069
[ "${rc}" -ne 11 ] && exit "${rc}"
10661070
set -e
10671071
dnf builddep --assumeyes \
1068-
$HOME/rpmbuild/SRPMS/python-ansible-pylibssh-${{
1072+
$HOME/rpmbuild/SRPMS/python-${{ env.PROJECT_NAME }}-${{
10691073
needs.pre-setup.outputs.dist-version
10701074
}}-1${{
10711075
steps.distribution-meta.outputs.dist-tag
@@ -1076,7 +1080,7 @@ jobs:
10761080
run: >-
10771081
rpmbuild
10781082
--rebuild
1079-
"$HOME/rpmbuild/SRPMS/python-ansible-pylibssh-${{
1083+
"$HOME/rpmbuild/SRPMS/python-${{ env.PROJECT_NAME }}-${{
10801084
needs.pre-setup.outputs.dist-version
10811085
}}-1${{
10821086
steps.distribution-meta.outputs.dist-tag
@@ -1086,7 +1090,7 @@ jobs:
10861090
dnf
10871091
install
10881092
--assumeyes
1089-
"$HOME/rpmbuild/RPMS/x86_64/python3-ansible-pylibssh-${{
1093+
"$HOME/rpmbuild/RPMS/x86_64/python3-${{ env.PROJECT_NAME }}-${{
10901094
needs.pre-setup.outputs.dist-version
10911095
}}-1${{
10921096
steps.distribution-meta.outputs.dist-tag
@@ -1277,7 +1281,7 @@ jobs:
12771281
environment:
12781282
name: pypi
12791283
url: >-
1280-
https://pypi.org/project/ansible-pylibssh/${{
1284+
https://pypi.org/project/${{ env.PROJECT_NAME }}/${{
12811285
needs.pre-setup.outputs.dist-version
12821286
}}
12831287
@@ -1322,7 +1326,7 @@ jobs:
13221326
environment:
13231327
name: testpypi
13241328
url: >-
1325-
https://test.pypi.org/project/ansible-pylibssh/${{
1329+
https://test.pypi.org/project/${{ env.PROJECT_NAME }}/${{
13261330
needs.pre-setup.outputs.dist-version
13271331
}}
13281332
@@ -1448,7 +1452,9 @@ jobs:
14481452
run: >-
14491453
git tag
14501454
-m '${{ needs.pre-setup.outputs.git-tag }}'
1451-
-m 'Published at https://pypi.org/project/ansible-pylibssh/${{
1455+
-m 'Published at https://pypi.org/project/${{
1456+
env.PROJECT_NAME
1457+
}}/${{
14521458
needs.pre-setup.outputs.dist-version
14531459
}}'
14541460
-m 'This release has been produced by the following workflow run: ${{
@@ -1564,7 +1570,9 @@ jobs:
15641570
echo '## 📝 Release notes' | tee -a release-notes.md
15651571
echo | tee -a release-notes.md
15661572
echo | tee -a release-notes.md
1567-
echo '📦 PyPI page: https://pypi.org/project/ansible-pylibssh/${{
1573+
echo '📦 PyPI page: https://pypi.org/project/${{
1574+
env.PROJECT_NAME
1575+
}}/${{
15681576
needs.pre-setup.outputs.dist-version
15691577
}}' | tee -a release-notes.md
15701578
echo | tee -a release-notes.md
@@ -1650,7 +1658,7 @@ jobs:
16501658

16511659
environment:
16521660
name: github-pages
1653-
url: ${{ steps.deployment.outputs.page_url }}/simple/ansible-pylibssh/
1661+
url: ${{ steps.deployment.outputs.page_url }}/simple/${{ env.PROJECT_NAME }}/
16541662

16551663
permissions:
16561664
contents: read # This job doesn't need to `git push` anything
@@ -1669,7 +1677,7 @@ jobs:
16691677
--dest dist/
16701678
--no-deps
16711679
--pre
1672-
ansible-pylibssh
1680+
'${{ env.PROJECT_NAME }}'
16731681
- name: Download all the dists
16741682
uses: actions/download-artifact@v4
16751683
with:

0 commit comments

Comments
 (0)