-
Notifications
You must be signed in to change notification settings - Fork 6
150 lines (146 loc) · 4.68 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
# Whenever we have a prerelease, we want to:
# * Build the sdist and attach it to the release.
# * Ensure that the docs will build.
# This should be triggered from the cmdline with `just prerelease`.
# Could also be triggered from the release page.
name: release
on:
workflow_dispatch:
permissions:
contents: write
jobs:
# test-code:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-python@v4
# with:
# python-version: "3.10"
# cache: pip
# - run: python -m pip install ".[dev]"
# - run: pytest ${{ env.test-dir }}
# test-docs:
# needs: [test-code]
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-python@v4
# 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@v3
with:
fetch-tags: 1 # Essential to later commitizen
fetch-depth: 0 # Reccommended by the action
token: ${{ secrets.PUSH_ACCESS }}
- uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: pip
- 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
build:
needs: [bump]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
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@v4
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@v3
with:
name: build-output
path: dist
docs:
needs: [bump]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
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@v4
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 [email protected]
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@v3
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/download-artifact@v3
with:
name: build-output
path: dist
- run: ls -R dist
- 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 \
--prerelease \
--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@v3
with:
ref: "main" # Necessary to download the latest of main as this will have been updated on the step before
- uses: actions/download-artifact@v3
with:
name: build-output
path: dist
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1