Skip to content

Fix token in workflow #32

Fix token in workflow

Fix token in workflow #32

Workflow file for this run

name: Upload package to PyPI
on:
push:
branches:
- main
jobs:
create_tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Tag version
run: |
version=$(sed -nE 's/^version = "([0-9v\.]+)"/\1/p' pyproject.toml)
if [ -z "$version" ]; then
echo "Could not extract version."
exit 1
fi
echo "Extracted version '$version'."
if [ $(git tag -l "$version") ]; then
echo "Version tag already exists."
exit 1
fi
latest=$(git tag | tail -n 1)
printf '%s\n%s\n' "$latest" "$version" | sort -V -C
if [ $? -eq 1 ]; then
echo "Version tag precedes latest ($latest)."
exit 1
fi
echo "Creating release..."
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases" \
-d '{"tag_name": "$version", "name": "$version"}'
echo "Done!"
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install build
run: python3 -m pip install build --user
- name: Build package
run: python3 -m build
- name: Store distribution packages
uses: actions/upload-artifact@v4
with:
name: dist
path: ./dist
publish-to-pypi:
runs-on: ubuntu-latest
needs:
- build
- create_tag
environment:
name: pypi
url: https://pypi.org/p/qc-parallelizer
permissions:
id-token: write
steps:
- name: Download dist
uses: actions/download-artifact@v4
with:
name: dist
path: ./dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1