Skip to content

Commit 3903a7b

Browse files
committed
Fix PyPI publishing
Signed-off-by: Max Dymond <max.dymond@alianza.com>
1 parent e6bad36 commit 3903a7b

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

.github/workflows/deploy.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,25 @@ on:
66
jobs:
77
Deploy:
88
runs-on: ubuntu-latest
9+
permissions:
10+
# IMPORTANT: this permission is mandatory for Trusted Publishing
11+
id-token: write
912
steps:
1013
- name: 'Set up Python'
1114
uses: actions/setup-python@v5
1215
with:
1316
python-version: 3.9
1417
- uses: actions/checkout@v4
1518
- run: bash install.sh
19+
# Build the package and publish it.
20+
- run: poetry build
21+
- name: Publish package distributions to PyPI
22+
uses: pypa/gh-action-pypi-publish@release/v1
23+
# Build the docker image and publish it
1624
- run: bash deploy.sh
1725
env:
1826
DOCKER_USER: ${{ secrets.DOCKER_USER }}
1927
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
20-
PYPI_USER: ${{ secrets.PYPI_USER }}
21-
PYPI_PASS: ${{ secrets.PYPI_PASS }}
2228
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2329
- run: bash after_deploy.sh
2430
env:

after_deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
echo "Announce changes to the world!"
44

5-
VERSION=$(tomlq -r '.tool.poetry.version' pyproject.toml)
5+
VERSION=$(tomlq -r '.project.version' pyproject.toml)
66
echo "Version: $VERSION"
77

88
# Send announcement to a standalone test webhook.

deploy.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
#!/usr/bin/env bash
22

3-
VERSION=$(tomlq -r '.tool.poetry.version' pyproject.toml)
3+
VERSION=$(tomlq -r '.project.version' pyproject.toml)
44
echo "Version: $VERSION"
55

66
# Log into docker
77
docker login -u $DOCKER_USER -p $DOCKER_PASS
88

9-
echo "Deploying to pypi"
10-
poetry publish --username $PYPI_USER --password $PYPI_PASS --build
11-
129
# Try and compile the Docker image - this will fail while the package isn't yet released.
1310
while ! docker build --build-arg VERSION=$VERSION -t metaswitch/announcer:$VERSION .
1411
do

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ set -ex
55
# Because poetry doesn't support dev-dependency extras, we need to install these
66
# tools outside of the tox poetry environment (because they're not required inside).
77
#
8-
pip install -U poetry tox-gh-actions tomlq
8+
pip install -U poetry tox-gh-actions yq

0 commit comments

Comments
 (0)