-
Notifications
You must be signed in to change notification settings - Fork 12
79 lines (69 loc) · 2.35 KB
/
cd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Publish to PyPI and GitHub
on:
workflow_dispatch:
inputs:
tag:
description: New version tag
required: true
jobs:
final-linting:
uses: ./.github/workflows/ci.yml
build-publish:
name: Build and publish to PyPI
runs-on: ubuntu-latest
needs: final-linting
environment:
name: release
url: https://pypi.org/p/airthings-ble
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
contents: write
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Update pyproject.toml Version
run: |
pip install tomlkit
python -c "
import tomlkit
tag = '${{ github.event.inputs.tag }}'
with open('pyproject.toml', 'r') as file:
content = tomlkit.parse(file.read())
content['tool']['poetry']['version'] = tag
with open('pyproject.toml', 'w') as file:
file.write(tomlkit.dumps(content))
"
- name: Update __init__.py version
run: |
version="${{ github.event.inputs.tag }}"
file="airthings_ble/__init__.py"
sed -i "s/__version__\\s*=\\s*[\"'].*[\"']/__version__ = \"$version\"/" $file
- name: Commit and Push Changes
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions"
git add pyproject.toml airthings_ble/__init__.py
git commit -m "Update version to ${{ github.event.inputs.tag }}"
git push
git tag ${{ github.event.inputs.tag }}
git push --tags
- name: Build source and wheel distributions
run: |
python -m pip install --upgrade build twine
python -m build
twine check --strict dist/*
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Release
uses: softprops/action-gh-release@v1
with:
files: dist/${{ env.name }}/*
tag_name: ${{ github.event.inputs.tag }}
generate_release_notes: true