-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (85 loc) · 2.81 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
# SPDX-FileCopyrightText: 2023 Raphaël Doursenaud <[email protected]>
#
# SPDX-License-Identifier: CC0-1.0
# This workflow needs access to 2 GitHub secrets:
# - TEST_PYPI_TOKEN: The API token to deploy on https://test.pypi.org
# - PROD_PYPI_TOKEN: The API token to deploy on https://pypi.org
#
# Both API tokens shall be generated from a user account with appropriate
# permissions on the target project and have their scope set to the project.
#
# The API tokens have then to be registered as secrets in the GitHub
# repository's configuration under the names specified above.
# See: https://docs.github.com/actions/security-guides/encrypted-secrets
# TODO: Allow the publishing of pre-releases (a, b, rc).
# The "Test installation" step requires a `--pre` argument to install
# pre-releases.
name: Release
on:
push:
tags:
- "*"
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version-file: 'pyproject.toml'
cache: 'pip'
- name: Upgrade pip
run: python3 -m pip install --upgrade pip setuptools wheel
- name: Install or upgrade build
run: python3 -m pip install --upgrade build
# Build dependencies are automatically installed from `pyproject.toml`.
- name: Build mido
run: python3 -m build
# Store build artifacts
- uses: actions/upload-artifact@v3
with:
name: mido-build
path: dist/
publish-test:
runs-on: ubuntu-latest
needs: build
steps:
# Retrieve build artifacts
- uses: actions/download-artifact@v3
with:
name: mido-build
- name: Install twine
run: python3 -m pip install --upgrade twine
- name: Check distribution name
run: twine check dist/*
- name: Publish to test.pypi.org
run: twine upload --repository testpypi dist/*
env:
TWINE_NON_INTERACTIVE: 1
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }}
- name: Test installation
run: |
python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps mido
- name: Test importing package
run: python3 -c "import mido; print(mido.version_info)"
publish-release:
runs-on: ubuntu-latest
needs:
- build
- publish-test
steps:
- uses: actions/download-artifact@v3
with:
name: mido-build
- name: Install twine
run: python3 -m pip install --upgrade twine
- name: Publish to pypi.org
run: twine upload dist/*
env:
TWINE_NON_INTERACTIVE: 1
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PROD_PYPI_TOKEN }}