Skip to content

Commit 3a4f7e2

Browse files
authored
Merge pull request #9 from buserbrasil/publish-package
Publish package to PyPI
2 parents 36bfd81 + 65d9103 commit 3a4f7e2

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

.github/workflows/test.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
push:
55
branches:
66
- main
7+
tags:
8+
- "v*"
79
pull_request:
810
branches:
911
- main
@@ -42,3 +44,84 @@ jobs:
4244

4345
- name: Test with python ${{ matrix.python-version }}
4446
run: uv run --frozen -m pytest
47+
48+
build:
49+
name: Build package
50+
runs-on: ubuntu-latest
51+
needs: [test]
52+
steps:
53+
- uses: actions/checkout@v4
54+
55+
- name: Install the latest version of uv and set the python version
56+
uses: astral-sh/setup-uv@v5
57+
with:
58+
python-version: 3.12
59+
60+
- name: Build
61+
run: uv build
62+
63+
- name: Store the distribution packages
64+
uses: actions/upload-artifact@v4
65+
with:
66+
name: python-package-distributions
67+
path: dist/
68+
69+
publish-to-pypi:
70+
name: Publish to PyPI
71+
runs-on: ubuntu-latest
72+
if: "startsWith(github.ref, 'refs/tags/')"
73+
needs: [build]
74+
environment:
75+
name: pypi
76+
url: https://pypi.org/p/santander-python-sdk
77+
permissions:
78+
id-token: write
79+
steps:
80+
- name: Download all the dists
81+
uses: actions/download-artifact@v4
82+
with:
83+
name: python-package-distributions
84+
path: dist/
85+
- name: Publish distribution 📦 to PyPI
86+
uses: pypa/gh-action-pypi-publish@release/v1
87+
88+
github-release:
89+
name: GitHub Release
90+
needs:
91+
- publish-to-pypi
92+
runs-on: ubuntu-latest
93+
94+
permissions:
95+
contents: write
96+
id-token: write
97+
98+
steps:
99+
- name: Download all the dists
100+
uses: actions/download-artifact@v4
101+
with:
102+
name: python-package-distributions
103+
path: dist/
104+
- name: Sign the dists with Sigstore
105+
uses: sigstore/[email protected]
106+
with:
107+
inputs: >-
108+
./dist/*.tar.gz
109+
./dist/*.whl
110+
- name: Create GitHub Release
111+
env:
112+
GITHUB_TOKEN: ${{ github.token }}
113+
run: >-
114+
gh release create
115+
'${{ github.ref_name }}'
116+
--repo '${{ github.repository }}'
117+
--notes ""
118+
- name: Upload artifact signatures to GitHub Release
119+
env:
120+
GITHUB_TOKEN: ${{ github.token }}
121+
# Upload to GitHub Release using the `gh` CLI.
122+
# `dist/` contains the built packages, and the
123+
# sigstore-produced signatures and certificates.
124+
run: >-
125+
gh release upload
126+
'${{ github.ref_name }}' dist/**
127+
--repo '${{ github.repository }}'

0 commit comments

Comments
 (0)