|
| 1 | +name: build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - '*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + publish: |
| 10 | + runs-on: ledgerhq-shared-small |
| 11 | + permissions: |
| 12 | + id-token: write |
| 13 | + contents: read |
| 14 | + attestations: write |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + - uses: actions/setup-python@v5 |
| 18 | + with: |
| 19 | + python-version: '3.10' |
| 20 | + - run: | |
| 21 | + pip install tox |
| 22 | + tox -e build |
| 23 | + # initiate jfrog login and install jf |
| 24 | + - name: Login to JFrog Ledger |
| 25 | + uses: LedgerHQ/actions-security/actions/jfrog-login@actions/jfrog-login-1 |
| 26 | + # upload package to jfrog |
| 27 | + - name: upload package |
| 28 | + run: jf rt u --build-name=python-etcd3-release --build-number=1 --module=etcd3 'dist/*.tar.gz' enclave-pypi-prod-green |
| 29 | + # attest that the delivered package is authenticated as a CI build |
| 30 | + - name: Attest |
| 31 | + id: attest |
| 32 | + uses: LedgerHQ/actions-security/actions/attest@actions/attest-1 |
| 33 | + with: |
| 34 | + subject-path: 'dist/*.tar.gz' |
| 35 | + push-to-registry: false |
| 36 | + - uses: LedgerHQ/actions/gemfury/publish@main |
| 37 | + env: |
| 38 | + PUSH_TOKEN: ${{ secrets.PYPI_PUSH_TOKEN }} |
| 39 | + - uses: actions/upload-artifact@v4 |
| 40 | + with: |
| 41 | + name: dist-${{ github.run_id }} |
| 42 | + path: | |
| 43 | + dist |
| 44 | + retention-days: 2 |
| 45 | + |
| 46 | + validate: |
| 47 | + runs-on: ledgerhq-shared-small |
| 48 | + permissions: |
| 49 | + id-token: write |
| 50 | + contents: read |
| 51 | + needs: |
| 52 | + - publish |
| 53 | + steps: |
| 54 | + - uses: actions/checkout@v4 |
| 55 | + - uses: actions/download-artifact@v4 |
| 56 | + with: |
| 57 | + name: dist-${{ github.run_id }} |
| 58 | + path: dist |
| 59 | + - uses: actions/setup-python@v5 |
| 60 | + with: |
| 61 | + python-version: '3.10' |
| 62 | + cache: 'pip' |
| 63 | + - run: | |
| 64 | + pip install build twine wheel-filename blob |
| 65 | + # in order to allow test pip install after publish, get back pkg version |
| 66 | + - name: get back local build version |
| 67 | + id: get_pkg_version |
| 68 | + run: | |
| 69 | + from wheel_filename import parse_wheel_filename |
| 70 | + import glob |
| 71 | + import os |
| 72 | + from random import choices |
| 73 | + from string import ascii_letters |
| 74 | +
|
| 75 | + whl = str(glob.glob('dist/*.whl')[0]); |
| 76 | + pwf = parse_wheel_filename('dist/' + whl); |
| 77 | + with open(os.environ["GITHUB_OUTPUT"], "a") as gh_output: |
| 78 | + delimiter = "".join(choices(ascii_letters, k=16)) |
| 79 | + gh_output.writelines([ |
| 80 | + f"pkg_version<<{delimiter}\n", |
| 81 | + f"{pwf.version}\n", |
| 82 | + delimiter + "\n", |
| 83 | + ]) |
| 84 | + shell: python |
| 85 | + - name: Login to JFrog Ledger |
| 86 | + uses: LedgerHQ/actions-security/actions/jfrog-login@actions/jfrog-login-1 |
| 87 | + # configure jfrog repo and test pip install from it for the delivered package |
| 88 | + - name: set jfrog Repo URL |
| 89 | + run: jf pipc --global --repo-resolve=enclave-pypi-virtual-green |
| 90 | + - name: test install from jfrog |
| 91 | + run: | |
| 92 | + jf pip install etcd3==${{ steps.get_pkg_version.outputs.pkg_version }} |
| 93 | + pip show etcd3 |
| 94 | + shell: bash |
0 commit comments