mirror of
https://github.com/arsenetar/send2trash.git
synced 2026-01-22 14:41:40 +00:00
ci: Add ability to use trusted-publishing for PyPI
- Add Publish workflow to run on release tags to upload package to PyPI - Add Build of packages to end of Default CI/CD workflow when on master branch.
This commit is contained in:
32
.github/workflows/publish.yml
vendored
Normal file
32
.github/workflows/publish.yml
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
name: Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+'
|
||||
|
||||
jobs:
|
||||
pypi-publish:
|
||||
name: Upload to PyPI
|
||||
runs-on: ubuntu-latest
|
||||
environment: pypi
|
||||
permissions:
|
||||
# IMPORTANT: this permission is mandatory for Trusted Publishing
|
||||
id-token: write
|
||||
steps:
|
||||
- name: Get artifact run
|
||||
id: get_artifact_run
|
||||
run: |
|
||||
RUN_ID=$(gh run list --workflow "Default CI/CD" --branch master --commit "${{ github.sha }}" --status completed --limit 1 --json databaseId --jq ".[].databaseId")
|
||||
if [ -z "$RUN_ID" ]; then
|
||||
echo "No completed workflow run found for commit ${{ github.sha }}"
|
||||
exit 1
|
||||
fi
|
||||
echo "run=$RUN_ID" >> $GITHUB_OUTPUT
|
||||
- name: Fetch build artifacts
|
||||
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
|
||||
with:
|
||||
name: dist
|
||||
run-id: ${{ steps.get_artifact_run.outputs.run }}
|
||||
- name: Publish package distributions to PyPI
|
||||
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
|
||||
Reference in New Issue
Block a user