Skip to content

Commit 371b9a8

Browse files
committed
fix: pin CI tooling, isolate SDK publish credentials and refuse dot-segment path params (#303)
1 parent 4263caa commit 371b9a8

6 files changed

Lines changed: 35 additions & 37 deletions

File tree

‎.github/workflows/build-release.yaml‎

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
jobs:
88
build:
99
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
1012
strategy:
1113
matrix:
1214
python-version: [ "3.11", "3.12" ]
@@ -55,61 +57,57 @@ jobs:
5557
5658
- name: Create release
5759
if: steps.version.outputs.released == 'true'
58-
uses: ncipollo/release-action@v1
59-
with:
60-
tag: v${{ steps.version.outputs.version }}
61-
generateReleaseNotes: true
60+
env:
61+
GH_TOKEN: ${{ github.token }}
62+
VERSION: ${{ steps.version.outputs.version }}
63+
run: gh release create "v$VERSION" --target "$GITHUB_SHA" --generate-notes
6264

63-
publish:
65+
package:
6466
runs-on: ubuntu-latest
6567
needs: [release]
6668
if: needs.release.outputs.released == 'true'
6769
permissions:
68-
id-token: write
70+
contents: read
6971
steps:
70-
- uses: actions/checkout@v3
72+
- uses: actions/checkout@v4
7173

7274
- uses: actions/setup-python@v4
7375
with:
7476
python-version: "3.x"
7577

76-
- name: deps
77-
run: python -m pip install -U build
78-
7978
- name: build
80-
run: python -m build
81-
82-
- name: mint API token
83-
id: mint-token
8479
run: |
85-
# retrieve the ambient OIDC token
86-
resp=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
87-
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=pypi")
88-
oidc_token=$(jq -r '.value' <<< "${resp}")
89-
90-
# exchange the OIDC token for an API token
91-
resp=$(curl -X POST https://pypi.org/_/oidc/mint-token -d "{\"token\": \"${oidc_token}\"}")
92-
api_token=$(jq -r '.token' <<< "${resp}")
80+
python -m pip install -U build
81+
python -m build
9382
94-
# mask the newly minted API token, so that we don't accidentally leak it
95-
echo "::add-mask::${api_token}"
83+
- uses: actions/upload-artifact@v4
84+
with:
85+
name: dist
86+
path: dist/
9687

97-
# see the next step in the workflow for an example of using this step output
98-
echo "api-token=${api_token}" >> "${GITHUB_OUTPUT}"
88+
# PyPI trusted publishing trusts this whole workflow file, so only this job holds id-token: write, and it
89+
# installs and runs nothing but the pinned publish action on the distributions the package job built.
90+
publish:
91+
runs-on: ubuntu-latest
92+
needs: [package]
93+
permissions:
94+
id-token: write
95+
steps:
96+
- uses: actions/download-artifact@v4
97+
with:
98+
name: dist
99+
path: dist/
99100

100101
- name: publish
101-
# gh-action-pypi-publish uses TWINE_PASSWORD automatically
102-
uses: pypa/gh-action-pypi-publish@release/v1
103-
with:
104-
password: ${{ steps.mint-token.outputs.api-token }}
102+
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
105103

106104
notify-failure:
107-
needs: [build, release, publish]
105+
needs: [build, release, package, publish]
108106
if: failure()
109107
runs-on: ubuntu-latest
110108
steps:
111109
- name: Notify Slack on release failure
112-
uses: slackapi/slack-github-action@v4.0.0
110+
uses: slackapi/slack-github-action@dcb1066f776dd043e64d0e8ba94ca15cc7e1875d # v4.0.0
113111
with:
114112
errors: true
115113
webhook: ${{ secrets.PLATFORM_INCIDENT_SLACK_CHANNEL_WEBHOOK }}

‎hostinger_api/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
""" # noqa: E501
1313

1414

15-
__version__ = "4.13.1"
15+
__version__ = "4.13.2"
1616

1717
# import apis into sdk package
1818
from hostinger_api.api.agency_hosting_cache_api import AgencyHostingCacheApi

‎hostinger_api/api_client.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def __init__(
8888
self.default_headers[header_name] = header_value
8989
self.cookie = cookie
9090
# Set default User-Agent.
91-
self.user_agent = 'hostinger_api-python/4.13.1'
91+
self.user_agent = 'hostinger_api-python/4.13.2'
9292
self.client_side_validation = configuration.client_side_validation
9393

9494
def __enter__(self):

‎hostinger_api/configuration.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ def to_debug_report(self) -> str:
508508
"OS: {env}\n"\
509509
"Python Version: {pyversion}\n"\
510510
"Version of the API: 2.13.1\n"\
511-
"SDK Package Version: 4.13.1".\
511+
"SDK Package Version: 4.13.2".\
512512
format(env=sys.platform, pyversion=sys.version)
513513

514514
def get_host_settings(self) -> List[HostSetting]:

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "hostinger_api"
3-
version = "4.13.1"
3+
version = "4.13.2"
44
description = "Hostinger API"
55
authors = ["Hostinger <devs@hostinger.com>"]
66
license = "MIT"

‎setup.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def read(filename):
2222
# prerequisite: setuptools
2323
# http://pypi.python.org/pypi/setuptools
2424
NAME = "hostinger_api"
25-
VERSION = "4.13.1"
25+
VERSION = "4.13.2"
2626
PYTHON_REQUIRES = ">= 3.11"
2727
REQUIRES = [
2828
"urllib3 >= 2.7.0, < 3.0.0",

0 commit comments

Comments
 (0)