# Build, check and publish m68000-python to PyPI with Trusted Publishing # (OIDC): no stored token. PyPI must know this repository, this workflow # file and the `pypi` environment as the project's publisher (Aubrey # registers it before the first tag, as for z80-python). # # A pushed release tag (v0.1.0, not v0.1.0-rc1) builds, smoke-tests and # uploads. Every pull request runs the same build, check and smoke test as # a dry run, so a broken release is caught before the tag. Run it by hand # (workflow_dispatch) for the same dry run on any branch; only a tag is # ever uploaded. name: Publish on: push: tags: - "v*" - "!v*-rc*" pull_request: workflow_dispatch: inputs: dry_run: description: "Build, smoke-test and check only; never upload" type: boolean default: true jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: "3.12" - run: python -m pip install --upgrade pip build twine - run: python -m build --wheel --sdist - run: python -m twine check --strict dist/* - name: A release tag must name the package version if: startsWith(github.ref, 'refs/tags/v') run: | version=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])") test "${GITHUB_REF_NAME}" = "v${version}" || { echo "tag ${GITHUB_REF_NAME} does not match version ${version}"; exit 1; } - run: python -m pip install dist/*.whl - name: Smoke-test the installed wheel working-directory: ${{ runner.temp }} run: python ${{ github.workspace }}/scripts/smoke_installed_package.py - uses: actions/upload-artifact@v4 with: name: dist path: dist/ publish: needs: build if: >- startsWith(github.ref, 'refs/tags/v') && (github.event_name == 'push' || inputs.dry_run == false) runs-on: ubuntu-latest environment: pypi permissions: id-token: write steps: - uses: actions/download-artifact@v4 with: name: dist path: dist/ - uses: pypa/gh-action-pypi-publish@release/v1