Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/workflows/publish-s3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Publish to S3 PyPI

on:
push:
tags:
- 'v*'

concurrency:
group: publish-${{ github.ref }}
cancel-in-progress: true

env:
AWS_REGION: eu-central-1
AWS_ACCOUNT_ID: "485262375119"

jobs:
publish:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Build package
run: |
pip install build
python -m build

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/gh-oidc-role
role-session-name: GitHubActions-${{ github.run_id }}
aws-region: ${{ env.AWS_REGION }}

- name: Upload distribution to S3
run: |
aws s3 sync dist/ s3://wfp-hip-pypi/pypi/data-bridges-client/ \
--exclude "*" --include "*.whl" --include "*.tar.gz"

- name: Regenerate index.html
run: |
aws s3 ls s3://wfp-hip-pypi/pypi/data-bridges-client/ \
| awk -f scripts/render-simple-index.awk > index.html
aws s3 cp index.html s3://wfp-hip-pypi/pypi/data-bridges-client/index.html \
--content-type "text/html"
18 changes: 18 additions & 0 deletions scripts/render-simple-index.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/awk -f
#
# Generate "simple pypi index" from s3 directory listing
#
# > aws s3 ls s3://bucket/path/ | ./render-simple-index.awk | tee index.html
#
BEGIN {
print "<!DOCTYPE html>"
print "<html><body>"
}

/.*\.(whl|gz)$/ {
print " <a href=\"" $4 "\">" $4 "</a></br>"
}

END {
print "</body></html>"
}
Loading