-
Notifications
You must be signed in to change notification settings - Fork 35
72 lines (64 loc) · 2.4 KB
/
python-publish.yml
File metadata and controls
72 lines (64 loc) · 2.4 KB
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
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Upload Python Package
on:
release:
types: [published]
jobs:
update-changelog:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Fetch Version Tag & Release Notes
id: get_release_info
run: |
echo "VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
echo "NOTES<<EOF" >> $GITHUB_ENV
gh release view ${{ github.event.release.tag_name }} --json body -q .body >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Insert Version Tag & Release Notes Below `# Changelog`
run: |
{ echo "# Changelog"; echo; echo "## $VERSION"; echo; echo "$NOTES"; echo; tail -n +2 CHANGELOG.md; } > temp.md && mv temp.md CHANGELOG.md
- name: Create Pull Request to push updated CHANGELOG.md
uses: peter-evans/create-pull-request@v7
with:
commit-message: update CHANGELOG
title: Update changelog with latest release notes
body: Update CHANGELOG.md to reflect release changes
branch: update-changelog
labels: |
automated-pr
delete-branch: true
base: main
deploy:
needs: update-changelog
runs-on: ubuntu-latest
steps:
- name: Pause for 5 minutes to merge update Changelog PR
run: |
echo "Wait for 5 minutes to merge PR..."
sleep 300
echo "Resuming workflow..."
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full history to include .git directory
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install build
python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}