Debian Codegraph @

.github/workflows/release.yml

raw symbols SCIP
1 # SPDX-FileCopyrightText: 2023 Raphaël Doursenaud <[email protected]>
2 #
3 # SPDX-License-Identifier: CC0-1.0
4
5 # This workflow needs access to 2 GitHub secrets:
6 # - TEST_PYPI_TOKEN: The API token to deploy on https://test.pypi.org
7 # - PROD_PYPI_TOKEN: The API token to deploy on https://pypi.org
8 #
9 # Both API tokens shall be generated from a user account with appropriate
10 # permissions on the target project and have their scope set to the project.
11 #
12 # The API tokens have then to be registered as secrets in the GitHub
13 # repository's configuration under the names specified above.
14 # See: https://docs.github.com/actions/security-guides/encrypted-secrets
15
16 # TODO: Allow the publishing of pre-releases (a, b, rc).
17 # The "Test installation" step requires a `--pre` argument to install
18 # pre-releases.
19
20 name: Release
21
22 on:
23 push:
24 tags:
25 - "*"
26 workflow_dispatch:
27
28 jobs:
29 build:
30 runs-on: ubuntu-latest
31
32 steps:
33 - name: Checkout
34 uses: actions/checkout@v3
35 - name: Set up Python
36 uses: actions/setup-python@v4
37 with:
38 python-version-file: 'pyproject.toml'
39 cache: 'pip'
40 - name: Upgrade pip
41 run: python3 -m pip install --upgrade pip setuptools wheel
42 - name: Install or upgrade build
43 run: python3 -m pip install --upgrade build
44 # Build dependencies are automatically installed from `pyproject.toml`.
45 - name: Build mido
46 run: python3 -m build
47 # Store build artifacts
48 - uses: actions/upload-artifact@v3
49 with:
50 name: mido-build
51 path: dist/
52
53 publish-test:
54 runs-on: ubuntu-latest
55 needs: build
56 steps:
57 # Retrieve build artifacts
58 - uses: actions/download-artifact@v3
59 with:
60 name: mido-build
61 path: dist/
62 - name: Install twine
63 run: python3 -m pip install --upgrade twine
64 - name: Check distribution name
65 run: twine check dist/*
66 - name: Publish to test.pypi.org
67 run: twine upload --repository testpypi dist/*
68 env:
69 TWINE_NON_INTERACTIVE: 1
70 TWINE_USERNAME: __token__
71 TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }}
72 - name: Test installation
73 run: |
74 python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps mido
75 - name: Test importing package
76 run: python3 -c "import mido; print(mido.version_info)"
77
78 publish-release:
79 runs-on: ubuntu-latest
80 needs:
81 - build
82 - publish-test
83 steps:
84 - uses: actions/download-artifact@v3
85 with:
86 name: mido-build
87 path: dist/
88 - name: Install twine
89 run: python3 -m pip install --upgrade twine
90 - name: Publish to pypi.org
91 run: twine upload dist/*
92 env:
93 TWINE_NON_INTERACTIVE: 1
94 TWINE_USERNAME: __token__
95 TWINE_PASSWORD: ${{ secrets.PROD_PYPI_TOKEN }}