Skip to content

Commit c7b0000

Browse files
committed
👷 Added trigger on tagging and TestPyPi to CI
1 parent 29abb17 commit c7b0000

1 file changed

Lines changed: 106 additions & 32 deletions

File tree

Lines changed: 106 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,110 @@
1-
# This workflow will upload a Python Package using Twine when a release is created
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3-
4-
# This workflow uses actions that are not certified by GitHub.
5-
# They are provided by a third-party and are governed by
6-
# separate terms of service, privacy policy, and support
7-
# documentation.
8-
9-
name: Upload Python Package
10-
1+
name: Deploy to PyPi
112
on:
12-
release:
13-
types: [published]
14-
15-
permissions:
16-
contents: read
17-
id-token: write
18-
3+
push:
4+
tags:
5+
- 'v*'
196
jobs:
20-
deploy:
21-
7+
build:
8+
name: Build Wheels and Package 🛠️
229
runs-on: ubuntu-latest
23-
2410
steps:
25-
- uses: actions/checkout@v4
26-
- name: Set up Python
27-
uses: actions/setup-python@v5
28-
with:
29-
python-version: '3.x'
30-
- name: Install dependencies
31-
run: |
32-
python -m pip install --upgrade pip
33-
pip install uv
34-
uv build
35-
- name: Publish package
36-
uses: pypa/gh-action-pypi-publish@release/v1
11+
- name: Checkout Code
12+
uses: actions/checkout@v5
13+
- name: Install uv
14+
uses: astral-sh/setup-uv@v7
15+
- name: Store the distribution packages
16+
uses: actions/upload-artifact@v4
17+
with:
18+
retention-days: 1
19+
if-no-files-found: error
20+
name: python-package-distributions
21+
path: dist/
22+
publish_test:
23+
name: Publish to TestPyPi 🧪
24+
needs:
25+
- build
26+
runs-on: ubuntu-latest
27+
environment:
28+
name: test_pypi
29+
url: https://test.pypi.org/p/ukaea-multiparser
30+
permissions:
31+
id-token: write
32+
steps:
33+
- name: Download all the dists
34+
uses: actions/download-artifact@v4
35+
with:
36+
name: python-package-distributions
37+
path: dist/
38+
- name: Publish to TestPyPi
39+
uses: pypa/gh-action-pypi-publish@release/v1
40+
with:
41+
repository-url: https://test.pypi.org/legacy/
42+
publish:
43+
name: Publish to PyPi 🐍📦
44+
needs:
45+
- publish_test
46+
if: "!contains(github.ref, 'rc') && !contains(github.ref, 'beta') && !contains(github.ref, 'alpha')"
47+
runs-on: ubuntu-latest
48+
environment:
49+
name: pypi
50+
url: https://pypi.org/p/ukaea-multiparser
51+
permissions:
52+
id-token: write
53+
steps:
54+
- name: Download all the dists
55+
uses: actions/download-artifact@v4
56+
with:
57+
name: python-package-distributions
58+
path: dist/
59+
- name: Publish to PyPi
60+
uses: pypa/gh-action-pypi-publish@release/v1
61+
github-release:
62+
name: Create Signed GitHub Release 🔏
63+
needs:
64+
- publish
65+
runs-on: ubuntu-latest
66+
permissions:
67+
contents: write
68+
id-token: write
69+
steps:
70+
- name: Download all the dists
71+
uses: actions/download-artifact@v4
72+
with:
73+
name: python-package-distributions
74+
path: dist/
75+
- name: Sign the dists with Sigstore
76+
uses: sigstore/gh-action-sigstore-python@v3.0.0
77+
with:
78+
inputs: >-
79+
./dist/*.tar.gz
80+
./dist/*.whl
81+
- name: Create GitHub Release
82+
env:
83+
GITHUB_TOKEN: ${{ github.token }}
84+
run: >-
85+
LATESTCHANGES=$(awk '
86+
BEGIN { header_found = 0 }
87+
/^## / {
88+
if (header_found == 0) {
89+
header = $0
90+
header_found = 1
91+
next
92+
} else {
93+
exit
94+
}
95+
}
96+
header_found == 1 && /^\* / { print }
97+
' CHANGELOG.md)
98+
gh release create
99+
'${{ github.ref_name }}'
100+
--notes "$LATESTCHANGES"
101+
--title 'Multiparser ${{ github.ref_name }}'
102+
--repo '${{ github.repository }}'
103+
- name: Upload artifact signatures to GitHub Release
104+
env:
105+
GITHUB_TOKEN: ${{ github.token }}
106+
run: >-
107+
gh release upload
108+
'${{ github.ref_name }}' dist/**
109+
--repo '${{ github.repository }}'
110+

0 commit comments

Comments
 (0)