diff --git a/.github/actions/build/build-wheel/action.yml b/.github/actions/build/build-wheel/action.yml index 9b4c936..7854994 100644 --- a/.github/actions/build/build-wheel/action.yml +++ b/.github/actions/build/build-wheel/action.yml @@ -6,9 +6,9 @@ runs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/setup/install-python-core - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/setup/install-python-core@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} - name: Create wheel run: | diff --git a/.github/actions/build/verify-structure/action.yml b/.github/actions/build/verify-structure/action.yml index edee5a7..142df6f 100644 --- a/.github/actions/build/verify-structure/action.yml +++ b/.github/actions/build/verify-structure/action.yml @@ -6,9 +6,9 @@ runs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/setup/install-python-core - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/setup/install-python-core@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} - name: Download wheel artifact uses: actions/download-artifact@v7 diff --git a/.github/actions/ci/bandit/action.yml b/.github/actions/ci/bandit/action.yml index 6e00aed..6bbb76a 100644 --- a/.github/actions/ci/bandit/action.yml +++ b/.github/actions/ci/bandit/action.yml @@ -6,9 +6,9 @@ runs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/setup/install-python-dev - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/setup/install-python-dev@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} - name: Security check run: | diff --git a/.github/actions/ci/mypy/action.yml b/.github/actions/ci/mypy/action.yml index c2cf6b2..18b3162 100644 --- a/.github/actions/ci/mypy/action.yml +++ b/.github/actions/ci/mypy/action.yml @@ -6,9 +6,9 @@ runs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/setup/install-python-dev - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/setup/install-python-dev@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} - name: Check with mypy run: | diff --git a/.github/actions/ci/pip-audit/action.yml b/.github/actions/ci/pip-audit/action.yml index e682b18..0844e10 100644 --- a/.github/actions/ci/pip-audit/action.yml +++ b/.github/actions/ci/pip-audit/action.yml @@ -6,9 +6,9 @@ runs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/setup/install-python-dev - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/setup/install-python-dev@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} - name: Audit dependencies run: | diff --git a/.github/actions/ci/pytest/action.yml b/.github/actions/ci/pytest/action.yml index 6f5dff8..4add27b 100644 --- a/.github/actions/ci/pytest/action.yml +++ b/.github/actions/ci/pytest/action.yml @@ -6,9 +6,9 @@ runs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/setup/install-python-dev - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/setup/install-python-dev@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} - name: Test with pytest run: | diff --git a/.github/actions/ci/ruff/action.yml b/.github/actions/ci/ruff/action.yml index 321f384..d44e7fc 100644 --- a/.github/actions/ci/ruff/action.yml +++ b/.github/actions/ci/ruff/action.yml @@ -6,9 +6,9 @@ runs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/setup/install-python-dev - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/setup/install-python-dev@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} - name: Check with ruff run: | diff --git a/.github/actions/ci/validate-pyproject/action.yml b/.github/actions/ci/validate-pyproject/action.yml index aa79d89..214bc7f 100644 --- a/.github/actions/ci/validate-pyproject/action.yml +++ b/.github/actions/ci/validate-pyproject/action.yml @@ -6,9 +6,9 @@ runs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/setup/install-python-dev - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/setup/install-python-dev@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} - name: Validate pyproject.toml run: | diff --git a/.github/actions/ci/version-check/action.yml b/.github/actions/ci/version-check/action.yml index b4ea0be..fc7f170 100644 --- a/.github/actions/ci/version-check/action.yml +++ b/.github/actions/ci/version-check/action.yml @@ -12,9 +12,9 @@ runs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/setup/install-python-dev - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/setup/install-python-dev@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} - name: Check version consistency run: | diff --git a/.github/actions/setup/install-python-core/action.yml b/.github/actions/setup/install-python-core/action.yml index fde5028..5bf9797 100644 --- a/.github/actions/setup/install-python-core/action.yml +++ b/.github/actions/setup/install-python-core/action.yml @@ -6,9 +6,9 @@ runs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/setup/setup-uv-python - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/setup/setup-uv-python@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} - name: Install dependencies run: | diff --git a/.github/actions/setup/install-python-dev/action.yml b/.github/actions/setup/install-python-dev/action.yml index a627331..be96318 100644 --- a/.github/actions/setup/install-python-dev/action.yml +++ b/.github/actions/setup/install-python-dev/action.yml @@ -6,9 +6,9 @@ runs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/setup/setup-uv-python - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/setup/setup-uv-python@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} - name: Install dependencies run: | diff --git a/.github/actions/setup/set-package-name/action.yml b/.github/actions/setup/set-package-name/action.yml new file mode 100644 index 0000000..2341112 --- /dev/null +++ b/.github/actions/setup/set-package-name/action.yml @@ -0,0 +1,11 @@ +name: Set Package Name +description: Sets the PACKAGE_NAME environment variable by replacing hyphens with underscores in the repository name. + +runs: + using: composite + steps: + - name: Set package name + run: | + REPO_NAME="${{ github.event.repository.name }}" + echo "PACKAGE_NAME=${REPO_NAME//-/_}" >> $GITHUB_ENV + shell: bash diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ab27475..b68ccba 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,25 +8,30 @@ on: branches: - main -env: - PACKAGE_NAME: template_python - jobs: build-wheel: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 + - uses: ./.github/actions/setup/set-package-name + if: ${{ github.event.repository.name == 'template-python' }} + # - uses: javidahmed64592/template-python/.github/actions/setup/set-package-name@main + # if: ${{ github.event.repository.name != 'template-python' }} - uses: ./.github/actions/build/build-wheel - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/build/build-wheel@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} verify-structure: runs-on: ubuntu-latest needs: build-wheel steps: - uses: actions/checkout@v6 + - uses: ./.github/actions/setup/set-package-name + if: ${{ github.event.repository.name == 'template-python' }} + # - uses: javidahmed64592/template-python/.github/actions/setup/set-package-name@main + # if: ${{ github.event.repository.name != 'template-python' }} - uses: ./.github/actions/build/verify-structure - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/build/verify-structure@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6dd49a..6b4e32e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,69 +8,70 @@ on: branches: - main -env: - PACKAGE_NAME: template_python - jobs: validate-pyproject: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - uses: ./.github/actions/ci/validate-pyproject - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/ci/validate-pyproject@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} ruff: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - uses: ./.github/actions/ci/ruff - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/ci/ruff@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} mypy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - uses: ./.github/actions/ci/mypy - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/ci/mypy@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} pytest: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - uses: ./.github/actions/ci/pytest - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/ci/pytest@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} bandit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 + - uses: ./.github/actions/setup/set-package-name + if: ${{ github.event.repository.name == 'template-python' }} + # - uses: javidahmed64592/template-python/.github/actions/setup/set-package-name@main + # if: ${{ github.event.repository.name != 'template-python' }} - uses: ./.github/actions/ci/bandit - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/ci/bandit@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} pip-audit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - uses: ./.github/actions/ci/pip-audit - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/ci/pip-audit@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} version-check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - uses: ./.github/actions/ci/version-check - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/ci/version-check@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} diff --git a/docs/WORKFLOWS.md b/docs/WORKFLOWS.md index 0de05ba..951522f 100644 --- a/docs/WORKFLOWS.md +++ b/docs/WORKFLOWS.md @@ -65,6 +65,21 @@ steps: --- +**set-package-name:** +- Description: Sets the `PACKAGE_NAME` environment variable by replacing hyphens with underscores in the repository name. +- Location: `set-package-name/action.yml` +- Steps: + - Derives `PACKAGE_NAME` from `github.event.repository.name` using bash parameter expansion (`${REPO_NAME//-/_}`) + - Writes the result to `$GITHUB_ENV` so it is available to all subsequent steps + +Usage: +```yaml +steps: + - uses: javidahmed64592/template-python/.github/actions/setup/set-package-name@main +``` + +--- + ### CI Actions (`/ci/**/action.yml`) **validate-pyproject:** @@ -139,9 +154,8 @@ steps: Usage: ```yaml -env: - PACKAGE_NAME: your_package_name steps: + - uses: javidahmed64592/template-python/.github/actions/setup/set-package-name@main - uses: javidahmed64592/template-python/.github/actions/ci/bandit@main ``` @@ -201,9 +215,8 @@ steps: Usage: ```yaml -env: - PACKAGE_NAME: your_package_name steps: + - uses: javidahmed64592/template-python/.github/actions/setup/set-package-name@main - uses: javidahmed64592/template-python/.github/actions/build/build-wheel@main ``` @@ -221,9 +234,8 @@ steps: Usage: ```yaml -env: - PACKAGE_NAME: your_package_name steps: + - uses: javidahmed64592/template-python/.github/actions/setup/set-package-name@main - uses: javidahmed64592/template-python/.github/actions/build/verify-structure@main ```