-
Notifications
You must be signed in to change notification settings - Fork 1
113 lines (96 loc) · 4.03 KB
/
test_and_publish_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
#file: noinspection LongLine
name: "Test and publish release"
on:
workflow_dispatch:
inputs:
release_version:
description: 'Release version number'
required: true
push:
branches:
- main
pull_request:
branches:
- '*'
env:
PY_COLORS: "1"
jobs:
test-and-publish-release:
runs-on: windows-2019
steps:
- name: Checkout tja2fumen (main branch)
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10.x'
- name: Install tja2fumen and its dev dependencies
run: |
pip install -e .[dev]
- name: Run tests (Python API)
run: |
pytest testing --entry-point python-api
# The GitHub Actions bot email was taken from: https://github.community/t/github-actions-bot-email-address/17204/6
- name: Set bot user data for commits
# Only set git user data if workflow is run manually. (This allows the other steps in the workflow to test PRs.)
if: github.event_name == 'workflow_dispatch'
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions Bot"
- name: Update pyproject.toml version (for release)
# Only update the version number if workflow is run manually. (This allows the other steps in the workflow to test PRs.)
if: github.event_name == 'workflow_dispatch'
run: |
toml set --toml-path pyproject.toml project.version "${{ github.event.inputs.release_version }}"
git add pyproject.toml
git commit -m "Update pyproject.toml version for ${{ github.event.inputs.release_version }}"
- name: Build wheel/sdist
run: python -m build
- name: Uninstall editable tja2fumen and install built wheel
shell: bash
run: |
pip uninstall tja2fumen -y
pip install dist/*.whl
- name: Run tests (installed wheel)
run: pytest testing --entry-point python-cli
- name: Add UPX to the PATH
uses: crazy-max/ghaction-upx@v2
with:
install-only: true
- name: Build pyinstaller executable
run: |
pyinstaller src\tja2fumen\__init__.py `
--name tja2fumen-${{ github.event.inputs.release_version }} `
--add-data="src\tja2fumen\hp_values.csv;tja2fumen\" `
--onefile `
--exclude-module bz2 `
--exclude-module hashlib `
--exclude-module lzma `
--exclude-module socket `
--exclude-module ssl `
--exclude-module unicodedata `
--exclude-module select
- name: Run tests (installed wheel)
run: pytest testing --entry-point exe
- name: Push release changes
# Only push the new tags if workflow is run manually. (This allows the other steps in the workflow to test PRs.)
if: github.event_name == 'workflow_dispatch'
run: |
git tag ${{ github.event.inputs.release_version }}
git push --tags
- uses: ncipollo/release-action@v1
# Only create release if workflow is run manually. (This allows the other steps in the workflow to test PRs.)
if: github.event_name == 'workflow_dispatch'
name: Create release
id: create_release
with:
tag: ${{ github.event.inputs.release_version }}
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: "dist/tja2fumen-${{ github.event.inputs.release_version }}.exe,\
dist/tja2fumen-${{ github.event.inputs.release_version }}.tar.gz,\
dist/tja2fumen-${{ github.event.inputs.release_version }}-py3-none-any.whl"
draft: true
- name: Publish distribution to PyPI
# Only publish distribution if workflow is run manually. (This allows the other steps in the workflow to test PRs.)
if: github.event_name == 'workflow_dispatch'
run: twine upload dist/*.whl dist/*.tar.gz --username __token__ --password ${{ secrets.PYPI_API_TOKEN }}