Skip to content

Commit 494372c

Browse files
authored
Merge pull request #921 from mandiant/trusted-publishing
Trusted publishing
2 parents 1765846 + 1f9a25e commit 494372c

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

.github/workflows/publish.yml

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
# This workflows will upload a Python Package using Twine when a release is created
2-
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3-
1+
# use PyPI trusted publishing, as described here:
2+
# https://blog.trailofbits.com/2023/05/23/trusted-publishing-a-new-benchmark-for-packaging-security/
43
name: publish to pypi
54

65
on:
76
release:
87
types: [published]
9-
branches: [master]
8+
9+
permissions:
10+
contents: write
1011

1112
jobs:
12-
deploy:
13-
runs-on: ubuntu-20.04
14-
# Pin action version by commit hash to maximize trust, ref: https://securitylab.github.com/research/github-actions-building-blocks/
13+
pypi-publish:
14+
runs-on: ubuntu-latest
15+
environment:
16+
name: release
17+
permissions:
18+
id-token: write
1519
steps:
1620
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
1721
- name: Set up Python
@@ -21,11 +25,17 @@ jobs:
2125
- name: Install dependencies
2226
run: |
2327
python -m pip install --upgrade pip
24-
pip install setuptools wheel twine
25-
- name: Build and publish
26-
env:
27-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
28-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
28+
pip install -e .[build]
29+
- name: build package
2930
run: |
30-
python setup.py sdist bdist_wheel
31-
twine upload --skip-existing dist/*
31+
python -m build
32+
- name: upload package artifacts
33+
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
34+
with:
35+
path: dist/*
36+
- name: publish package
37+
uses: pypa/gh-action-pypi-publish@f5622bde02b04381239da3573277701ceca8f6a0 # release/v1
38+
with:
39+
skip-existing: true
40+
verbose: true
41+
print-hash: true

setup.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@
7171
"types-PyYAML==6.0.10",
7272
"types-tabulate==0.9.0.3",
7373
],
74-
"build": [
75-
"pyinstaller==6.3.0",
76-
],
74+
"build": ["pyinstaller==6.3.0", "setuptools==69.0.2", "build==1.0.3"],
7775
},
7876
zip_safe=False,
7977
keywords="floss malware analysis obfuscation strings FLARE",

0 commit comments

Comments
 (0)