-
Notifications
You must be signed in to change notification settings - Fork 6
160 lines (156 loc) · 5.02 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
159
160
name: release
on:
workflow_dispatch:
permissions:
contents: write
jobs:
test-code:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: pip
- run: python -m pip install ".[dev]"
- run: pytest ${{ env.test-dir }}
test-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: pip
- run: python -m pip install ".[dev]"
- run: mkdocs build --clean --strict
# Need to ensure we bump before we create any artifacts
bump:
runs-on: ubuntu-latest
needs: [test-code, test-docs]
steps:
- uses: actions/checkout@v4
with:
fetch-tags: 1 # Essential to later commitizen
fetch-depth: 0 # Recommended by the action
token: ${{ secrets.PUSH_ACCESS }}
- run: git tag # Debug statement
- name: Create bump and changelog
uses: commitizen-tools/commitizen-action@master
id: cz
with:
github_token: ${{ secrets.PUSH_ACCESS }}
debug: true
changelog_increment_filename: changelog-increment.md
- run: |
mkdir changelog-output
mv changelog-increment.md changelog-output/changelog-increment.md
cat changelog-output/changelog-increment.md
- name: Upload the changelog
uses: actions/upload-artifact@v4
with:
name: changelog
path: changelog-output
build:
needs: [bump]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: "main" # Necessary to download the latest of main as this will have been updated on the step before
fetch-tags: 1
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: pip
- run: python -m pip install build
- run: python -m build --sdist
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: build-output
path: dist
docs:
needs: [bump]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: "main" # Necessary to download the latest of main as this will have been updated on the step before
fetch-tags: 1
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: pip
- run: python -m pip install ".[dev]"
- name: "Deploy Docs"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name doc-bot
git config user.email doc-bot@amltk.com
current_version=$(git tag | sort --version-sort | tail -n 1)
# This block will rename previous retitled versions
retitled_versions=$(mike list -j | jq ".[] | select(.title != .version) | .version" | tr -d '"')
for version in $retitled_versions; do
mike retitle "${version}" "${version}"
done
echo "Deploying docs for ${current_version}"
mike deploy \
--push \
--title "${current_version} (latest)" \
--update-aliases \
"${current_version}" \
"latest"
release:
needs: [docs, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: "main" # Necessary to download the latest of main as this will have been updated on the step before
fetch-tags: 1
fetch-depth: 0
- name: Download the build artifiact
uses: actions/download-artifact@v4
with:
name: build-output
path: dist
- run: ls -R dist
- name: Download the changelog
uses: actions/download-artifact@v4
with:
name: changelog
path: changelog-output
- run: |
ls -R changelog-output
mv changelog-output/changelog-increment.md changelog-increment.md
cat changelog-increment.md
- name: "Create Github Release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
current_version=$(git tag | sort --version-sort | tail -n 1)
echo "Release for ${current_version}"
gh release create \
--generate-notes \
--notes-file changelog-increment.md \
--verify-tag \
"${current_version}" "dist/amltk-${current_version}.tar.gz"
publish:
needs: [release]
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
with:
ref: "main" # Necessary to download the latest of main as this will have been updated on the step before
- uses: actions/download-artifact@v4
with:
name: build-output
path: dist
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1