Skip to content

Commit

Permalink
Update release to pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
vlouf committed Aug 23, 2024
1 parent 0e33239 commit 6214c7a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 36 deletions.
65 changes: 30 additions & 35 deletions .github/workflows/release_to_pypi.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
name: Publish UNRAVEL to PyPI / GitHub
name: Publish suncal to PyPI / GitHub

on:
push:
tags:
- "v*"
release:
types:
- published

jobs:
build-n-publish:
name: Build and publish to PyPI
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read

steps:
- name: Checkout source
uses: actions/checkout@main
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@main
uses: actions/setup-python@v4
with:
python-version: "3.x"

Expand All @@ -24,35 +27,27 @@ jobs:
python -m pip install --upgrade build twine
python -m build
twine check --strict dist/*
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

- name: Create GitHub Release
id: create_release
uses: actions/create-release@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false
- name: Get Asset name
- name: mint API token
id: mint-token
run: |
export PKG=$(ls dist/ | grep tar)
set -- $PKG
echo "name=$1" >> $GITHUB_ENV
- name: Upload Release Asset (sdist) to GitHub
id: upload-release-asset
uses: actions/upload-release-asset@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# retrieve the ambient OIDC token
resp=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=pypi")
oidc_token=$(jq -r '.value' <<< "${resp}")
# exchange the OIDC token for an API token
resp=$(curl -X POST https://pypi.org/_/oidc/mint-token -d "{\"token\": \"${oidc_token}\"}")
api_token=$(jq -r '.token' <<< "${resp}")
# mask the newly minted API token, so that we don't accidentally leak it
echo "::add-mask::${api_token}"
# see the next step in the workflow for an example of using this step output
echo "api-token=${api_token}" >> "${GITHUB_OUTPUT}"
- name: Publish distribution to PyPI
# gh-action-pypi-publish uses TWINE_PASSWORD automatically
uses: pypa/gh-action-pypi-publish@release/v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/${{ env.name }}
asset_name: ${{ env.name }}
asset_content_type: application/zip
password: ${{ steps.mint-token.outputs.api-token }}
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setup(
name="unravel", # Required
version="1.3.1", # Required
version="1.3.2", # Required
description="A dealiasing technique for Doppler radar velocity.", # Optional
long_description=long_description, # Optional
long_description_content_type="text/markdown", # Optional (see note above)
Expand Down

0 comments on commit 6214c7a

Please sign in to comment.