-
Notifications
You must be signed in to change notification settings - Fork 7
140 lines (135 loc) · 4.91 KB
/
publish.yaml
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: Publish
on: workflow_dispatch
env:
POETRY_VERSION: 1.8.2
CONVCO_VERSION: v0.4.2
GITCLIFF_VERSION: 2.0.4
CHANGELOG_FILE: CHANGELOG.md
FULL_CHANGELOG_FILE: FULL_CHANGELOG.md
# Do not allow more than one publish job to run at a time
concurrency:
group: "publish"
cancel-in-progress: false
jobs:
publish-python:
runs-on: ubuntu-22.04 # convco needs GLIBC_2.32 which is not in 20.04
environment: publish
# Trusted publishing requires permission: id-token: write
# contents: read to access the repository's contents is set by default,
# however when permissions are explicitly set, the default is overridden.
permissions:
id-token: write
contents: write
outputs:
new_version: ${{ steps.set-vars.outputs.new_version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install poetry
run: curl -sSL https://install.python-poetry.org | python3 - --version ${{ env.POETRY_VERSION }}
- name: Install convco
run: |
curl -sSfL "https://github.com/convco/convco/releases/download/${{ env.CONVCO_VERSION }}/convco-ubuntu.zip" | zcat > /usr/local/bin/convco
chmod +x /usr/local/bin/convco
- name: Set variables
id: set-vars
run: |
base_version_command="
convco
version
--prefix=v
"
old_version=$($base_version_command)
new_version=$($base_version_command --bump)
new_tag=v"$new_version"
echo "OLD_VERSION=$old_version" >> $GITHUB_ENV
echo "NEW_VERSION=$new_version" >> $GITHUB_ENV
echo "new_version=$new_version" >> $GITHUB_OUTPUT
echo "NEW_MAJOR_VERSION=$(echo $new_version | cut -d'.' -f1)" >> $GITHUB_ENV
echo "NEW_TAG=$new_tag" >> $GITHUB_ENV
echo "old version: $old_version"
echo "new version: $new_version"
echo "new tag: $new_tag"
- name: Release
# Only run if the version has changed.
# Only start publishing automatically when the major version is 1 or higher.
if: ${{ env.OLD_VERSION != env.NEW_VERSION && env.NEW_MAJOR_VERSION >= 1 }}
env:
GH_TOKEN: ${{ github.token }}
run: |
########################################
# Generate changelogs
########################################
git_cliff_command="npx git-cliff@${{ env.GITCLIFF_VERSION }} --tag=${{ env.NEW_TAG }}"
$git_cliff_command --unreleased > ${{ env.CHANGELOG_FILE }}
$git_cliff_command > ${{ env.FULL_CHANGELOG_FILE }}
########################################
# Create GitHub Release
########################################
gh release create \
${{ env.NEW_TAG }} \
--title ${{ env.NEW_TAG }} \
--notes-file ${{ env.CHANGELOG_FILE }} \
${{ env.FULL_CHANGELOG_FILE }}
########################################
# Build package
########################################
poetry version ${{ env.NEW_VERSION }}
poetry build
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
build-docs:
runs-on: ubuntu-22.04
needs: publish-python
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install poetry
run: curl -sSL https://install.python-poetry.org | python3 - --version ${{ env.POETRY_VERSION }}
- uses: actions/cache@v4
with:
path: .venv/
key: ${{ runner.os }}-python-3.11-poetry-${{ hashFiles('pyproject.toml') }}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
poetry config --local virtualenvs.in-project true
poetry install -E all
- name: Build docs
run: |
poetry version ${{ needs.publish-python.outputs.new_version }}
poetry run sphinx-apidoc -o docs/source/ edvart
poetry run make -C docs html
- name: Upload HTML
uses: actions/upload-artifact@v4
with:
name: html
path: docs/build/html
retention-days: 1
deploy-pages:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
needs:
- build-docs
runs-on: ubuntu-22.04
steps:
- name: Setup Pages
uses: actions/configure-pages@v4
- uses: actions/download-artifact@v4
with:
name: html
path: docs/build/html
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/build/html
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4