From 591d2152d9208639fe8b653efbab0ee4a254fe05 Mon Sep 17 00:00:00 2001 From: rorywhite200 <125914446+rorywhite200@users.noreply.github.com> Date: Tue, 30 Jan 2024 15:30:35 -0800 Subject: [PATCH 1/3] fix: update ci-cd.yml --- .github/workflows/ci-cd.yml | 54 +++++++++++++++---------------------- 1 file changed, 22 insertions(+), 32 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 9b365d1..f5609ca 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -12,7 +12,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.11" + python-version: "{{ cookiecutter.python_version }}" - name: Check-out repository uses: actions/checkout@v3 @@ -24,7 +24,7 @@ jobs: run: poetry install - name: Test with pytest - run: poetry run pytest tests/ --cov=passwordler --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@v3 @@ -35,12 +35,15 @@ jobs: run: poetry run make html --directory docs/ cd: + permissions: + id-token: write + contents: write + # Only run this job if the "ci" job passes needs: ci # Only run this job if new work is pushed to "main" - ### NOTE: REMOVE the `false` in later milestones - if: github.event_name == 'push' && github.ref == 'refs/heads/main' && false + if: github.event_name == 'push' && github.ref == 'refs/heads/main' # Set up operating system runs-on: ubuntu-latest @@ -50,54 +53,41 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.11" + python-version: "{{ cookiecutter.python_version }}" - name: Check-out repository uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Install poetry - uses: snok/install-poetry@v1 - - - name: Install package - run: poetry install - - - name: Install Python Semantic Release - run: poetry run pip install python-semantic-release - - name: Use Python Semantic Release to prepare release - env: - # This token is created automatically by GH Actions - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - git config user.name github-actions - git config user.email github-actions@github.com - poetry run semantic-release publish - - ### For milestone 1, no need to publish release 0.01 - ### For later milestones, we need to setup TEST_PYPI_API_TOKEN and PYPI_API_TOKEN in the repo settings + id: release + uses: python-semantic-release/python-semantic-release@v8.3.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} - name: Publish to TestPyPI uses: pypa/gh-action-pypi-publish@release/v1 + if: steps.release.outputs.released == 'true' with: - user: __token__ - password: ${{ secrets.TEST_PYPI_API_TOKEN }} repository-url: https://test.pypi.org/legacy/ - # skip uploading a package if a version with the same name and version number already exists on the specified package index - skip-existing: true + password: ${{ secrets.TEST_PYPI_API_TOKEN }} - name: Test install from TestPyPI run: | pip install \ --index-url https://test.pypi.org/simple/ \ --extra-index-url https://pypi.org/simple \ - passwordler + {{ cookiecutter.__package_slug }} - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@release/v1 + if: steps.release.outputs.released == 'true' with: - user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} - # skip uploading a package if a version with the same name and version number already exists on the specified package index - skip-existing: true + + - 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 }} From ae5bea8f840d6b19b4110dfe90741573abd7dfc3 Mon Sep 17 00:00:00 2001 From: rorywhite200 <125914446+rorywhite200@users.noreply.github.com> Date: Tue, 30 Jan 2024 15:39:50 -0800 Subject: [PATCH 2/3] fix: change python version on cookie-cutter --- .github/workflows/ci-cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index f5609ca..3672095 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -12,7 +12,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "{{ cookiecutter.python_version }}" + python-version: "3.11" - name: Check-out repository uses: actions/checkout@v3 From 05fea95b385d26527acf27603af722db8ab93c07 Mon Sep 17 00:00:00 2001 From: rorywhite200 <125914446+rorywhite200@users.noreply.github.com> Date: Tue, 30 Jan 2024 15:53:27 -0800 Subject: [PATCH 3/3] fix: update variables in yaml --- .github/workflows/ci-cd.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 3672095..7e5006e 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -24,7 +24,7 @@ jobs: run: poetry install - name: Test with pytest - run: poetry run pytest tests/ --cov={{ cookiecutter.__package_slug }} --cov-report=xml + run: poetry run pytest tests/ --cov=passwordler --cov-report=xml - name: Use Codecov to track coverage uses: codecov/codecov-action@v3 @@ -53,7 +53,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "{{ cookiecutter.python_version }}" + python-version: "3.11" - name: Check-out repository uses: actions/checkout@v3 @@ -78,7 +78,7 @@ jobs: pip install \ --index-url https://test.pypi.org/simple/ \ --extra-index-url https://pypi.org/simple \ - {{ cookiecutter.__package_slug }} + passwordler - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@release/v1