Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(release): upload artifact if we need to release #141

Merged
merged 2 commits into from
Feb 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 28 additions & 27 deletions .github/workflows/code_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ jobs:
python-checks:
name: Python checks
runs-on: ubuntu-latest
outputs:
deploy_env: ${{ steps.detect-deploy-env.outputs.deploy_env }}
needs:
- pre-commit
steps:
Expand Down Expand Up @@ -148,39 +150,38 @@ jobs:
make dist
echo "::endgroup::"

- name: Store the distribution packages
uses: actions/upload-artifact@v4
if: ${{ github.event_name == 'push' || inputs.force_release }}
with:
name: python-package-distributions
path: dist/

- name: Detect environment
if: ${{ github.event_name == 'push' || inputs.force_release }}
id: detect-deploy-env
run: |
echo "deploy_env=${{ startsWith(github.ref, 'refs/tags') && 'pypi' || 'testpypi' }}" >> "${GITHUB_OUTPUT}"

deploy-release:
name: Deploy Release
runs-on: ubuntu-latest
if: github.event_name == 'push' || inputs.force_release
if: ${{ github.event_name == 'push' || inputs.force_release }}
environment:
name: ${{ needs.python-checks.outputs.deploy_env }}
url: ${{ needs.python-checks.outputs.deploy_env == 'pypi' && 'https://pypi.org/project/yamkix/' || 'https://test.pypi.org/project/yamkix/' }}
permissions:
id-token: write
needs:
- python-checks
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Download the distribution packages
uses: actions/download-artifact@v4
with:
fetch-depth: 0
name: python-package-distributions
path: dist/

- uses: jdx/mise-action@v2
- name: Publish package distributions to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
install: true
cache: true

- name: Restore uv cache
uses: actions/cache@v4
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}

- name: Setup venv
run: |
uv python install
make setup-venv

- name: Build the distribution
run: |
echo "::group::make dist"
make dist
echo "::endgroup::"
repository-url: ${{ needs.python-checks.outputs.deploy_env == 'pypi' && 'https://upload.pypi.org/legacy/' || 'https://test.pypi.org/legacy/' }}
Loading