Skip to content

.github/workflows/nox.yaml #487

.github/workflows/nox.yaml

.github/workflows/nox.yaml #487

Workflow file for this run

# .github/workflows/nox.yaml
# Copyright 2023 Keith Maxwell
# SPDX-License-Identifier: CC0-1.0
on: # yamllint disable-line rule:truthy
push: { branches: [main] }
pull_request: { branches: [main] }
schedule: [{ cron: "15 0 * * *" }]
workflow_dispatch:
inputs:
repository-url:
type: choice
description: Upload API endpoint for PyPI
options:
# https://github.com/pypa/gh-action-pypi-publish/blob/unstable/v1/action.yml#L23
- https://upload.pypi.org/legacy/
- https://test.pypi.org/legacy/
default: https://upload.pypi.org/legacy/
jobs:
nox:
runs-on: ubuntu-latest
outputs: { version: "${{ steps.version.outputs.version }}" }
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with: { python-version: "3.11" }
id: setup
- run: pipx run "--python=${{ steps.setup.outputs.python-path }}" nox
- run: git diff --exit-code dist/SHA256SUMS
- run: >-
pipx run "--python=${{ steps.setup.outputs.python-path }}"
nox --session=github_output >> "$GITHUB_OUTPUT"
id: version
- uses: actions/upload-artifact@v4
with: { path: dist }
- name: Upload wheelhouse/ to debug unexpected changes
uses: actions/upload-artifact@v4
with: { name: wheelhouse, path: wheelhouse }
if: always()
- uses: dprint/check@v2.2
publish:
needs: [nox]
runs-on: ubuntu-latest
if: "${{ github.event_name == 'workflow_dispatch' }}"
permissions: { id-token: write }
environment:
name: pypi
url: >-
https://${{
contains(github.event.inputs.repository-url, 'test') && 'test.' || ''
}}pypi.org/project/reproducibly/${{
needs.nox.outputs.version
}}/
steps:
- name: Prevent deployments outside test from outside main
run: "false"
if: >-
${{ !( github.ref == 'refs/heads/main'
|| contains(github.event.inputs.repository-url, 'test')) }}
- uses: actions/download-artifact@v4
with: { name: artifact }
- run: sha256sum -c SHA256SUMS
- run: rm SHA256SUMS
- uses: pypa/gh-action-pypi-publish@release/v1
with:
print-hash: true
packages-dir: .
repository-url: ${{ github.event.inputs.repository-url }}