diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9dacd323..830b5d80 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,6 +1,5 @@ -# This workflows will upload a Python Package using Twine when a release is created -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries - +# use PyPI trusted publishing, as described here: +# https://blog.trailofbits.com/2023/05/23/trusted-publishing-a-new-benchmark-for-packaging-security/ name: publish to pypi on: @@ -8,8 +7,12 @@ on: types: [published] jobs: - deploy: - runs-on: ubuntu-20.04 + pypi-publish: + runs-on: ubuntu-latest + environment: + name: release + permissions: + id-token: write steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - name: Set up Python @@ -19,14 +22,24 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install twine pip install -e .[build] - name: build package run: | python -m build + - name: upload package artifacts + uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 + with: + name: ${{ matrix.asset_name }} + path: dist/* + - name: upload package to GH Release + uses: svenstaro/upload-release-action@2728235f7dc9ff598bd86ce3c274b74f802d2208 # v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN}} + file: dist/* + tag: ${{ github.ref }} - name: publish package - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - twine upload --skip-existing dist/* + uses: pypa/gh-action-pypi-publish@f5622bde02b04381239da3573277701ceca8f6a0 # release/v1 + with: + skip-existing: true + verbose: true + print-hash: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 41525dfc..d6cb5552 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Utility script to detect feature overlap between new and existing CAPA rules [#1451](https://github.com/mandiant/capa/issues/1451) [@Aayush-Goel-04](https://github.com/aayush-goel-04) - use fancy box drawing characters for default output #1586 @williballenthin - use [pre-commit](https://pre-commit.com/) to invoke linters #1579 @williballenthin +- publish via PyPI trusted publishing #1491 @williballenthin - migrate to pyproject.toml #1301 @williballenthin ### Breaking Changes