Skip to content

Commit

Permalink
Publish ft_utils to PyPi
Browse files Browse the repository at this point in the history
Summary: This mostly follows the docs from https://github.com/pypa/packaging.python.org/blob/main/source/guides/github-actions-ci-cd-sample/publish-to-test-pypi.yml. All I need is someone from the open source support team to add GitHub as a publisher (https://docs.pypi.org/trusted-publishers/adding-a-publisher/) (https://www.internalfb.com/wiki/Open_Source/Launch_an_OSS_Project/Releasing/#pypi) and we should be good.

Reviewed By: SonicField

Differential Revision: D68024795

fbshipit-source-id: 76531a9e17d035a53407986604ebad37cd1e0b65
  • Loading branch information
Kevin Newton authored and facebook-github-bot committed Jan 13, 2025
1 parent 39e2eb0 commit d4be4f4
Showing 1 changed file with 91 additions and 0 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
push:
branches:
- main
tags:
- 'v*'

# This build configuration uses a matrix to build and test multiple Python versions.
# Each version is actioned across on multiple operating systems (Ubuntu, Windows, macOS).
Expand Down Expand Up @@ -120,3 +122,92 @@ jobs:
with:
name: ${{ matrix.wheel }}.zip
path: build/dist/*.whl

publish-to-testpypi:
runs-on: ubuntu-latest
needs:
- cibuildwheel
- deadsnakes
environment:
name: testpypi
url: https://test.pypi.org/p/ft_utils
permissions:
id-token: write

steps:
- name: Download Python wheels
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true

- name: List Python wheels
run: ls -lR dist

- name: Publish Python wheels
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/

publish-to-pypi:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs:
- cibuildwheel
- deadsnakes
environment:
name: pypi
url: https://pypi.org/p/ft_utils
permissions:
id-token: write

steps:
- name: Download Python wheels
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true

- name: List Python wheels
run: ls -lR dist

- name: Publish Python wheels
uses: pypa/gh-action-pypi-publish@release/v1

github-release:
runs-on: ubuntu-latest
needs:
- publish-to-pypi

permissions:
contents: write
id-token: write

steps:
- name: Download Python wheels
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true

- name: Sign Python wheels
uses: sigstore/[email protected]
with:
inputs: ./dist/*.whl

- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
"$GITHUB_REF_NAME"
--repo "$GITHUB_REPOSITORY"
--notes ""
- name: Upload artifacts
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release upload
"$GITHUB_REF_NAME" dist/**
--repo "$GITHUB_REPOSITORY"

0 comments on commit d4be4f4

Please sign in to comment.