-
Notifications
You must be signed in to change notification settings - Fork 17
112 lines (95 loc) · 4.18 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
name: hordelib build and publish
on:
push:
branches:
- releases
permissions:
contents: write
pull-requests: read
jobs:
build-n-publish:
name: hordelib build and publish
runs-on: ubuntu-latest
steps:
# Version bumps the project and creates a tag by creating
# a github release. The github release itself is not so
# interesting, as it's incomplete because we haven't finished
# the build. The important goal here is a pypi release and this
# get us our version number.
- name: "📣 Release on push"
id: release
uses: rymndhng/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
bump_version_scheme: patch
use_github_release_notes: true
- name: "✔️ Checkout"
uses: actions/checkout@v3
with:
fetch-depth: 0
# Pass the version number in an env var to the below steps
- name: Set build version env var
run: echo "SETUPTOOLS_SCM_PRETEND_VERSION=${{ steps.release.outputs.version }}" >> $GITHUB_ENV
# We need python...
- name: "🐍 Set up Python 3.10"
if: ${{ steps.release.outputs.version != '' }}
uses: actions/setup-python@v4
with:
python-version: "3.10"
# Install build deps
# NOTE If any hordelib imports used by build_helper.py are changed, or the specific modules
# imported from hordelib depend on a package not included here, running build_helper.py later on will fail.
# See `build_helper.py` for more information.
- name: "🛠 Install pypa/build"
if: ${{ steps.release.outputs.version != '' }}
run: |
python -m pip install --upgrade pip
python -m pip install build psutil typing-extensions loguru strenum python-dotenv --user
- name: "✏️ Install changelog dependencies"
if: ${{ steps.release.outputs.version != '' }}
uses: actions/setup-node@v3
- name: "✏️ Generate release changelog"
if: ${{ steps.release.outputs.version != '' }}
run: |
npm -g install auto-changelog
auto-changelog --template=.changelog --ignore-commit-pattern="update changelog|version bump|Merge pull"
# Try to add the changelog back to the releases branch
- uses: EndBug/add-and-commit@v9
with:
add: 'CHANGELOG.md'
message: 'ci: update changelog'
committer_name: GitHub Actions
committer_email: [email protected]
# Patches our requirements.txt and pyproject.toml
# Build a changelog
- name: "🔧 Prepare our build for release"
if: ${{ steps.release.outputs.version != '' }}
run: >-
python build_helper.py
# Build a pypi distribution using the env var version number
- name: "🔧 Build a binary wheel and a source tarball"
if: ${{ steps.release.outputs.version != '' }}
run: >-
python -m build --sdist --wheel --outdir dist/ .
# Publish the package
- name: "📦 Publish distribution to PyPI"
if: ${{ steps.release.outputs.version != '' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
# Update the badges (maybe, if we're lucky)
- name: "📦 Refresh pypi badge cache"
run: >-
curl -X PURGE
https://camo.githubusercontent.com/42307cf23a47bc021a97a6da572ce61568aa29b7d23ccfbbc89bf15168d23ce0/68747470733a2f2f62616467652e667572792e696f2f70792f686f7264656c69622e7376673f6272616e63683d6d61696e266b696c6c5f63616368653d31
- name: "📦 Refresh downloads badge cache"
run: >-
curl -X PURGE
https://camo.githubusercontent.com/769edfb1778d4cbc3f93bc5ad0be9597bbd2d9c162cc1e9fb44172a5b660af01/68747470733a2f2f706570792e746563682f62616467652f686f7264656c6962
# - name: "Inform with Discord Webhook"
# if: ${{ steps.release.outputs.version != '' }}
# uses: tsickert/[email protected]
# with:
# webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
# content: "New version of hordelib has been published to pypi: ${{ steps.release.outputs.version }}. You can update your worker by running `./update-runtime.sh --hordelib` (Linux) or `update-runtime.cmd --hordelib` (Windows). Changelog: https://t.ly/z2vQ"