2022-12-19 13:55:18 +00:00
|
|
|
---
|
2023-01-29 10:21:20 +00:00
|
|
|
name: Build & maybe upload PyPI package
|
2022-12-19 13:55:18 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2023-01-29 10:21:20 +00:00
|
|
|
branches: [main]
|
2022-12-19 13:55:18 +00:00
|
|
|
tags: ["*"]
|
|
|
|
release:
|
|
|
|
types:
|
|
|
|
- published
|
2023-01-29 10:21:20 +00:00
|
|
|
workflow_dispatch:
|
2022-12-19 13:55:18 +00:00
|
|
|
|
|
|
|
permissions:
|
2024-08-03 14:04:13 +00:00
|
|
|
attestations: write
|
2022-12-19 13:55:18 +00:00
|
|
|
contents: read
|
2023-04-24 20:37:37 +00:00
|
|
|
id-token: write
|
2022-12-19 13:55:18 +00:00
|
|
|
|
|
|
|
jobs:
|
2023-01-29 10:21:20 +00:00
|
|
|
# Always build & lint package.
|
|
|
|
build-package:
|
|
|
|
name: Build & verify package
|
2022-12-19 15:06:37 +00:00
|
|
|
runs-on: ubuntu-latest
|
2022-12-19 13:55:18 +00:00
|
|
|
|
|
|
|
steps:
|
2023-10-01 05:45:12 +00:00
|
|
|
- uses: actions/checkout@v4
|
2023-01-29 10:21:20 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
|
2023-12-31 05:43:57 +00:00
|
|
|
- uses: hynek/build-and-inspect-python-package@v2
|
2024-08-03 14:03:14 +00:00
|
|
|
with:
|
|
|
|
attest-build-provenance-github: 'true'
|
2023-01-29 10:21:20 +00:00
|
|
|
|
|
|
|
# Upload to Test PyPI on every commit on main.
|
|
|
|
release-test-pypi:
|
|
|
|
name: Publish in-dev package to test.pypi.org
|
|
|
|
environment: release-test-pypi
|
2023-08-20 10:08:07 +00:00
|
|
|
if: github.repository_owner == 'python-attrs' && github.event_name == 'push' && github.ref == 'refs/heads/main'
|
2023-01-29 10:21:20 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: build-package
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Download packages built by build-and-inspect-python-package
|
2023-12-31 05:43:57 +00:00
|
|
|
uses: actions/download-artifact@v4
|
2023-01-29 10:21:20 +00:00
|
|
|
with:
|
|
|
|
name: Packages
|
|
|
|
path: dist
|
2022-12-19 14:33:05 +00:00
|
|
|
|
2023-01-29 10:21:20 +00:00
|
|
|
- name: Upload package to Test PyPI
|
2022-12-19 13:55:18 +00:00
|
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
|
|
with:
|
2024-09-03 09:15:33 +00:00
|
|
|
attestations: true
|
2023-03-17 05:12:37 +00:00
|
|
|
repository-url: https://test.pypi.org/legacy/
|
2022-12-19 13:55:18 +00:00
|
|
|
|
2023-01-29 10:21:20 +00:00
|
|
|
# Upload to real PyPI on GitHub Releases.
|
2022-12-19 13:55:18 +00:00
|
|
|
release-pypi:
|
2023-01-29 10:21:20 +00:00
|
|
|
name: Publish released package to pypi.org
|
2022-12-19 13:55:18 +00:00
|
|
|
environment: release-pypi
|
2023-08-20 10:08:07 +00:00
|
|
|
if: github.repository_owner == 'python-attrs' && github.event.action == 'published'
|
2022-12-19 15:06:37 +00:00
|
|
|
runs-on: ubuntu-latest
|
2023-01-29 10:21:20 +00:00
|
|
|
needs: build-package
|
2022-12-19 13:55:18 +00:00
|
|
|
|
|
|
|
steps:
|
2023-01-29 10:21:20 +00:00
|
|
|
- name: Download packages built by build-and-inspect-python-package
|
2023-12-31 05:43:57 +00:00
|
|
|
uses: actions/download-artifact@v4
|
2023-01-29 10:21:20 +00:00
|
|
|
with:
|
|
|
|
name: Packages
|
|
|
|
path: dist
|
2022-12-19 13:55:18 +00:00
|
|
|
|
2023-01-29 10:21:20 +00:00
|
|
|
- name: Upload package to PyPI
|
2022-12-19 13:55:18 +00:00
|
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
2024-09-03 09:15:33 +00:00
|
|
|
with:
|
|
|
|
attestations: true
|