-
Notifications
You must be signed in to change notification settings - Fork 1
89 lines (82 loc) · 2.82 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
---
# this file is *not* meant to cover or endorse the use of GitHub Actions, but
# rather to help make automated releases for this project
name: Upload Python Package
on:
push:
branches:
- main
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# all history is needed to crawl it properly
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.9'
- name: Install build and deploy dependencies
run: |
python -m pip install -U poetry twine
poetry self add "poetry-dynamic-versioning[plugin]"
poetry install
- name: Parse changelog
id: parse_changelog
run: |
poetry run changelog-generator \
changelog changelog.md \
--snippets=.snippets \
--dry-run > latest-entry.json
echo "CHANGELOG_JSON=$(jq -c . < latest-entry.json)" >> $GITHUB_ENV
- name: Update changelog with snippets
id: update_changelog
run: |
poetry run changelog-generator \
changelog changelog.md \
--snippets=.snippets \
--in-place \
--no-internal
poetry run changelog2version \
--changelog_file changelog.md \
--output changelog.json \
--print \
--debug
jq -r ".info.description" changelog.json > latest_description.txt
sed -i '/^$/d' latest_description.txt
echo 'LATEST_DESCRIPTION<<"EOT"' >> $GITHUB_OUTPUT
cat latest_description.txt >> $GITHUB_OUTPUT
echo '"EOT"' >> $GITHUB_OUTPUT
echo "latest_version=$(jq -r '.info.version' changelog.json)" >> $GITHUB_ENV
- name: Build package
run: |
poetry run changelog2version \
--changelog_file changelog.md \
--version_file snippets2changelog/version.py \
--version_file_type py \
--debug
poetry build
- name: Publish package
if: ${{ !contains(fromJson(env.CHANGELOG_JSON).meta.scope, 'internal') }}
uses: pypa/gh-action-pypi-publish@release/v1.5
with:
password: ${{ secrets.PYPI_API_TOKEN }}
skip_existing: true
verbose: true
print_hash: true
- name: Create Release
if: ${{ !contains(fromJson(env.CHANGELOG_JSON).meta.scope, 'internal') }}
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.latest_version }}
release_name: ${{ env.latest_version }}
body: ${{ steps.update_changelog.outputs.LATEST_DESCRIPTION }}
draft: false
prerelease: false