-
Notifications
You must be signed in to change notification settings - Fork 0
158 lines (136 loc) · 4.74 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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Bump Version and Release
on:
push:
branches: [main]
jobs:
pytest:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Install dependencies for testing
run: pip install .
- name: Run tests
run: pytest
bump-version:
runs-on: ubuntu-latest
needs: pytest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Install dependencies for version bump
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Bump version with Poetry
id: bump-version
run: |
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
if [[ "$COMMIT_MESSAGE" =~ Merge\ pull\ request.* ]]; then
echo "Detected merge commit, bumping major version..."
poetry version major
else
echo "Detected direct push, bumping patch version..."
poetry version patch
fi
echo "PACKAGE_VERSION=$(poetry version -s)" >> $GITHUB_ENV
echo "::set-output name=PACKAGE_VERSION::$(poetry version -s)"
git add pyproject.toml
shell: bash
- name: Commit & Push changes
uses: actions-js/push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
message: "Bump version to v${{ steps.bump-version.outputs.PACKAGE_VERSION }}"
force: true
release:
runs-on: ubuntu-latest
needs: bump-version
environment:
name: pypi
url: https://pypi.org/p/lmax-python-sdk
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing OpenID Connect (OIDC) tokens
deployments: write
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Fetch the latest commits
run: |
git fetch origin main
git checkout origin/main
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Install dependencies for release
run: pip install toml build
- name: Build package
run: python -m build
- name: Get package info
id: package-info
run: |
echo "PACKAGE_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['tool']['poetry']['version'])")" >> $GITHUB_ENV
echo "PACKAGE_NAME=$(python -c "import toml; print(toml.load('pyproject.toml')['tool']['poetry']['name'])")" >> $GITHUB_ENV
echo "::set-output name=PACKAGE_VERSION::$(python -c "import toml; print(toml.load('pyproject.toml')['tool']['poetry']['version'])")"
echo "::set-output name=PACKAGE_NAME::$(python -c "import toml; print(toml.load('pyproject.toml')['tool']['poetry']['name'])")"
- name: Create release
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "v${{ steps.package-info.outputs.PACKAGE_VERSION }}"
prerelease: false
title: "Release ${{ steps.package-info.outputs.PACKAGE_NAME }} v${{ steps.package-info.outputs.PACKAGE_VERSION }}"
files: |
dist/*.whl
dist/*.tar.gz
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
verbose: true
# Build the documentation and upload the static HTML files as an artifact.
build-docs:
runs-on: ubuntu-latest
needs: release
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
# ADJUST THIS: install all dependencies (including pdoc)
- run: pip install -e .
# We use a custom build script for pdoc itself, ideally you just run `pdoc -o docs/ ...` here.
- run: pdoc --mermaid -o docs/ lmax_python_sdk/
- uses: actions/upload-pages-artifact@v3
with:
path: docs/
# Deploy the artifact to GitHub pages.
# This is a separate job so that only actions/deploy-pages has the necessary permissions.
deploy-docs:
needs: build-docs
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v4