Repository navigation
101 lines (87 loc) · 3.15 KB
/
Copy pathrelease.yml
File metadata and controls
101 lines (87 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: Release
on:
push:
tags: ['v*']
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version: '3.12'
- name: Extract version from tag
id: version
env:
GH_REF: ${{ github.ref }}
run: |
version="${GH_REF#refs/tags/v}"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Ensure tag matches pyproject version
env:
TAG_VERSION: ${{ steps.version.outputs.version }}
run: |
python - <<'PY'
from pathlib import Path
import tomllib
import os
import sys
data = tomllib.loads(Path("pyproject.toml").read_text(encoding="utf-8"))
project_version = data["project"]["version"]
tag_version = os.environ["TAG_VERSION"]
if project_version != tag_version:
print(
f"pyproject.toml version {project_version!r} does not match tag v{tag_version}",
file=sys.stderr,
)
raise SystemExit(1)
PY
- name: Install pinned pip
run: python -m pip install --require-hashes -r requirements/pip.txt
- name: Install build tools
# Pin to specific versions so a compromised upstream cannot
# substitute a malicious build backend or upload client during
# the release. Bump these explicitly when upstream releases.
run: python -m pip install --require-hashes -r requirements/release.txt
- name: Build sdist and wheel
run: python -m build --no-isolation
- name: Check distribution metadata
run: twine check dist/*
- name: Upload build artifacts
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: dist
path: dist/
publish-pypi:
needs: [build]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pipelock-verify
permissions:
id-token: write
# attestations: write is required for SLSA / Sigstore provenance
# attachments on the published distributions (PEP 740).
attestations: write
contents: read
steps:
- name: Download build artifacts
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: dist
path: dist/
- name: Publish to PyPI with attestations
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
with:
# Emit SLSA / Sigstore attestations for each uploaded artifact
# via the OIDC trusted publisher flow. Published alongside the
# sdist and wheel so downstream consumers can verify provenance
# with `gh attestation verify --owner luckyPipewrench`.
attestations: true