Skip to content

Commit

Permalink
Update ci-cd.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
gracez-20 authored Jan 30, 2025
1 parent bd74a29 commit 5bc60f1
Showing 1 changed file with 11 additions and 50 deletions.
61 changes: 11 additions & 50 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "{{ cookiecutter.python_version }}"

- name: Check-out repository
uses: actions/checkout@v3
Expand All @@ -24,12 +24,12 @@ jobs:
run: poetry install

- name: Test with pytest
run: poetry run pytest tests/ --cov=matrics_calculator --cov-report=xml
run: poetry run pytest tests/ --cov={{ cookiecutter.__package_slug }} --cov-report=xml

- name: Use Codecov to track coverage
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
token: {% raw %}${{ secrets.CODECOV_TOKEN }}{% endraw %}
files: ./coverage.xml # coverage report

- name: Build documentation
Expand All @@ -39,7 +39,6 @@ jobs:
permissions:
id-token: write
contents: write
pull-requests: write

# Only run this job if the "ci" job passes
needs: ci
Expand All @@ -55,7 +54,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "{{ cookiecutter.python_version }}"

- name: Check-out repository
uses: actions/checkout@v3
Expand All @@ -66,63 +65,25 @@ jobs:
id: release
uses: python-semantic-release/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Verify changes after semantic release
run: git status
github_token: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}

- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: steps.release.outputs.released == 'true'
with:
repository-url: https://test.pypi.org/legacy/
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
password: {% raw %}${{ secrets.TEST_PYPI_API_TOKEN }}{% endraw %}

- name: Test install from TestPyPI
if: steps.release.outputs.released == 'true'
run: |
pip install \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple \
matrics_calculator
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: steps.release.outputs.released == 'true'
with:
password: ${{ secrets.PYPI_API_TOKEN }}
pip install \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple \
{{ cookiecutter.__package_slug }}
- name: Publish package distributions to GitHub Releases
uses: python-semantic-release/upload-to-gh-release@main
if: steps.release.outputs.released == 'true'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

# Create a release branch instead of pushing directly to main
- name: Create and push release branch
if: steps.release.outputs.released == 'true'
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b release-branch
git commit -am "chore: bump version [skip ci]" || echo "No changes to commit"
git push origin release-branch || echo "No changes to push"
# Install GitHub CLI and authenticate before creating PR
- name: Install GitHub CLI
run: sudo apt-get install gh -y

- name: Authenticate GitHub CLI
run: echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token

- name: Create pull request for version update
if: steps.release.outputs.released == 'true'
run: |
gh pr create \
--title "Release: New Version" \
--body "Automated version bump" \
--base main \
--head release-branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

github_token: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}

0 comments on commit 5bc60f1

Please sign in to comment.