jsii-release 0.2.1008 → 0.2.1010
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -6
- package/bin/publib-pypi +62 -14
- package/package.json +1 -1
- package/package.json.bak +1 -1
package/README.md
CHANGED
|
@@ -125,7 +125,7 @@ The server type is selected using the `MAVEN_SERVER_ID` variable.
|
|
|
125
125
|
| `ossrh` (deprecated) | `MAVEN_STAGING_PROFILE_ID` | Yes | Central Publisher (sonatype) staging profile ID, corresponding to namespace (e.g. `com.sonatype.software`). |
|
|
126
126
|
| `ossrh` (deprecated) | `MAVEN_ENDPOINT` | No | URL of Nexus repository. Defaults to `https://central.sonatype.com`. |
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
### How to create a GPG key
|
|
129
129
|
|
|
130
130
|
Install [GnuPG](https://gnupg.org/).
|
|
131
131
|
|
|
@@ -214,11 +214,31 @@ npx publib-pypi [DIR]
|
|
|
214
214
|
|
|
215
215
|
**Options (environment variables):**
|
|
216
216
|
|
|
217
|
-
| Option
|
|
218
|
-
|
|
|
219
|
-
| `TWINE_USERNAME`
|
|
220
|
-
| `TWINE_PASSWORD`
|
|
221
|
-
| `
|
|
217
|
+
| Option | Required | Description |
|
|
218
|
+
| --------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
219
|
+
| `TWINE_USERNAME` | Optional | PyPI username ([register](https://pypi.org/account/register/)). Not required when using Trusted Publishers. |
|
|
220
|
+
| `TWINE_PASSWORD` | Optional | PyPI password or API token. Not required when using Trusted Publishers. |
|
|
221
|
+
| `TWINE_REPOSITORY` | Optional | The repository to upload the package to. Defaults to `pypi`, set `testpypi` to publish to the testing index. |
|
|
222
|
+
| `TWINE_REPOSITORY_URL` | Optional | A custom repository URL, overrides `TWINE_REPOSITORY`. |
|
|
223
|
+
| `PYPI_TRUSTED_PUBLISHER` | Optional | Set to any value to use PyPI [Trusted Publisher](https://docs.pypi.org/trusted-publishers/) authentication (OIDC). Requires a supported ambient identity (i.e. CI/CD environment). |
|
|
224
|
+
| `PYPI_DISABLE_ATTESTATIONS` | Optional | Set to any value to disable [PyPI attestations](https://docs.pypi.org/attestations/producing-attestations/) (enabled by default with Trusted Publishers). |
|
|
225
|
+
|
|
226
|
+
### Trusted Publishers and Attestations
|
|
227
|
+
|
|
228
|
+
PyPI [Trusted Publishers](https://docs.pypi.org/trusted-publishers/) allows publishing without API tokens by using OpenID Connect (OIDC) authentication between a trusted third-party service and PyPI.
|
|
229
|
+
Typically these are CI/CD providers like GitHub Actions or Gitlab CI/CD.
|
|
230
|
+
PyPI attestations provide cryptographic proof of package provenance and integrity and are **enabled by default when using Trusted Publishers**. Attestations are only available when using Trusted Publisher authentication.
|
|
231
|
+
|
|
232
|
+
**Trusted Publisher Setup:**
|
|
233
|
+
|
|
234
|
+
1. Configure your PyPI project to use a [Trusted Publisher](https://docs.pypi.org/trusted-publishers/adding-a-publisher/)
|
|
235
|
+
2. Set `PYPI_TRUSTED_PUBLISHER=1` in your workflow environment
|
|
236
|
+
3. No `TWINE_USERNAME` or `TWINE_PASSWORD` needed
|
|
237
|
+
|
|
238
|
+
**Requirements:**
|
|
239
|
+
|
|
240
|
+
* **GitHub Actions**: Your workflow must have `id-token: write` permission.
|
|
241
|
+
* **Gitlab CI/CD**: The keyword `id_tokens` is used to request an OIDC token from GitLab with name `PYPI_ID_TOKEN` and audience `pypi`.
|
|
222
242
|
|
|
223
243
|
## Golang
|
|
224
244
|
|
package/bin/publib-pypi
CHANGED
|
@@ -9,27 +9,75 @@ set -euo pipefail
|
|
|
9
9
|
#
|
|
10
10
|
# DIR is where *.whl files are looked up (default is "dist/python")
|
|
11
11
|
#
|
|
12
|
-
# TWINE_USERNAME (
|
|
13
|
-
# TWINE_PASSWORD (
|
|
12
|
+
# TWINE_USERNAME (optional, ignored when using Trusted Publishers)
|
|
13
|
+
# TWINE_PASSWORD (optional, ignored when using Trusted Publishers)
|
|
14
|
+
# PYPI_TRUSTED_PUBLISHER (optional) - set to any value to use Trusted Publisher authentication
|
|
15
|
+
# PYPI_DISABLE_ATTESTATIONS (optional) - set to any value to disable attestations
|
|
14
16
|
#
|
|
15
17
|
###
|
|
16
18
|
|
|
17
19
|
cd "${1:-"dist/python"}"
|
|
18
20
|
|
|
19
|
-
[ -z "${TWINE_USERNAME:-}" ] && {
|
|
20
|
-
echo "Missing TWINE_USERNAME"
|
|
21
|
-
exit 1
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
[ -z "${TWINE_PASSWORD:-}" ] && {
|
|
25
|
-
echo "Missing TWINE_PASSWORD"
|
|
26
|
-
exit 1
|
|
27
|
-
}
|
|
28
|
-
|
|
29
21
|
if [ -z "$(ls *.whl)" ]; then
|
|
30
22
|
echo "cannot find any .whl files in $PWD"
|
|
31
23
|
exit 1
|
|
32
24
|
fi
|
|
33
25
|
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
# Validate credentials before installing packages
|
|
27
|
+
if [ -z "${PYPI_TRUSTED_PUBLISHER:-}" ]; then
|
|
28
|
+
[ -z "${TWINE_USERNAME:-}" ] && {
|
|
29
|
+
echo "Missing TWINE_USERNAME (required when not using Trusted Publishers)"
|
|
30
|
+
exit 1
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
[ -z "${TWINE_PASSWORD:-}" ] && {
|
|
34
|
+
echo "Missing TWINE_PASSWORD (required when not using Trusted Publishers)"
|
|
35
|
+
exit 1
|
|
36
|
+
}
|
|
37
|
+
fi
|
|
38
|
+
|
|
39
|
+
# Basic upload command options
|
|
40
|
+
upload_opts="--verbose --skip-existing"
|
|
41
|
+
|
|
42
|
+
# Install required packages
|
|
43
|
+
packages="twine"
|
|
44
|
+
if [ -n "${PYPI_TRUSTED_PUBLISHER:-}" ]; then
|
|
45
|
+
packages="$packages id"
|
|
46
|
+
|
|
47
|
+
if [ -z "${PYPI_DISABLE_ATTESTATIONS:-}" ]; then
|
|
48
|
+
# add attestations package
|
|
49
|
+
packages="$packages pypi-attestations"
|
|
50
|
+
# add attestations opt to upload command
|
|
51
|
+
upload_opts="$upload_opts --attestations"
|
|
52
|
+
fi
|
|
53
|
+
fi
|
|
54
|
+
python3 -m pip install --user --upgrade $packages
|
|
55
|
+
|
|
56
|
+
# Check for Trusted Publisher
|
|
57
|
+
if [ -n "${PYPI_TRUSTED_PUBLISHER:-}" ]; then
|
|
58
|
+
echo "Using PyPI Trusted Publisher authentication"
|
|
59
|
+
|
|
60
|
+
# Determine audience based on repository
|
|
61
|
+
audience="pypi"
|
|
62
|
+
mint_url="https://pypi.org/_/oidc/mint-token"
|
|
63
|
+
if [ "${TWINE_REPOSITORY:-}" = "testpypi" ]; then
|
|
64
|
+
audience="testpypi"
|
|
65
|
+
mint_url="https://test.pypi.org/_/oidc/mint-token"
|
|
66
|
+
fi
|
|
67
|
+
|
|
68
|
+
# Generate OIDC token and mint API token
|
|
69
|
+
oidc_token=$(python3 -m id "$audience")
|
|
70
|
+
resp=$(curl -s -X POST "$mint_url" -d "{\"token\": \"${oidc_token}\"}")
|
|
71
|
+
api_token=$(jq -r '.token' <<< "${resp}")
|
|
72
|
+
|
|
73
|
+
export TWINE_USERNAME="__token__"
|
|
74
|
+
export TWINE_PASSWORD="$api_token"
|
|
75
|
+
|
|
76
|
+
if [ -z "${PYPI_DISABLE_ATTESTATIONS:-}" ]; then
|
|
77
|
+
echo "Signing packages with pypi-attestations"
|
|
78
|
+
python3 -m pypi_attestations sign *
|
|
79
|
+
fi
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
echo "Uploading packages to PyPI"
|
|
83
|
+
python3 -m twine upload $upload_opts *
|
package/package.json
CHANGED