-
Notifications
You must be signed in to change notification settings - Fork 12
110 lines (90 loc) · 2.53 KB
/
release.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: Release
on:
workflow_dispatch:
jobs:
build-package:
name: Build package
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- id: check_ref
run: echo "::set-output name=match::$(echo '${{ github.ref }}' | grep -Pq '^refs/tags/v\d+\.\d+\.\d+$' && echo true || echo false)"
shell: bash
- name: Check if tag is valid
if: steps.check_ref.outputs.match != 'true'
run: exit 1
- name: Checkout repository contents
uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install poetry
run: |
pip install poetry
poetry install
- name: Build package
run: |
poetry build
- name: Cache built package artifacts
uses: actions/upload-artifact@v4
with:
name: package
path: |
dist/*
github-release:
name: Create GitHub release
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs:
- build-package
steps:
- uses: actions/checkout@v4
- name: Generate changelog
run: |
cat > CHANGELOG.md <<EOT
# CHANGELOG
**Release**: dt-cli (${GITHUB_REF#refs/tags/})
# Changes
EOT
git log --format=format:"%ad: %s" --date=short >> CHANGELOG.md
- name: Download cached built package
uses: actions/download-artifact@v4
with:
name: package
path: dist
- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
files: |
dist/*
LICENSE
body_path: CHANGELOG.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-to-pypi:
name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs:
- build-package
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install poetry
run: |
pip install poetry
poetry install
- name: Download cached built package
uses: actions/download-artifact@v4
with:
name: package
path: dist
- name: Publish to PyPI
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
poetry publish --username __token__ --password $PYPI_TOKEN