2023-06-29 07:20:46 +02:00
|
|
|
name: "Test and publish release"
|
2023-06-27 01:56:46 +02:00
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
release_version:
|
|
|
|
description: 'Release version number'
|
|
|
|
required: true
|
2023-06-29 07:20:46 +02:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- '*'
|
|
|
|
|
|
|
|
env:
|
|
|
|
PY_COLORS: "1"
|
2023-06-27 01:56:46 +02:00
|
|
|
|
|
|
|
jobs:
|
2023-06-29 07:20:46 +02:00
|
|
|
test-and-publish-release:
|
2023-06-27 01:56:46 +02:00
|
|
|
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.8.x'
|
|
|
|
|
2023-06-29 07:56:16 +02:00
|
|
|
- name: Install tja2fumen and its dev dependencies
|
2023-06-29 07:20:46 +02:00
|
|
|
run: |
|
2023-06-30 02:35:37 +02:00
|
|
|
pip install -e .[dev]
|
2023-06-29 07:20:46 +02:00
|
|
|
|
|
|
|
- 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"
|
|
|
|
|
2023-06-27 01:56:46 +02:00
|
|
|
- name: Update pyproject.toml version (for release)
|
2023-06-29 07:20:46 +02:00
|
|
|
# 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'
|
2023-06-27 01:56:46 +02:00
|
|
|
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
|
|
|
|
|
2023-06-29 07:20:46 +02:00
|
|
|
- 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
|
|
|
|
|
2023-07-10 05:56:27 +02:00
|
|
|
- name: Add UPX to the PATH
|
|
|
|
uses: crazy-max/ghaction-upx@v2
|
|
|
|
with:
|
|
|
|
install-only: true
|
|
|
|
|
2023-06-27 01:56:46 +02:00
|
|
|
- name: Build pyinstaller executable
|
|
|
|
run: |
|
2023-07-10 05:56:27 +02:00
|
|
|
pyinstaller src\tja2fumen\__init__.py `
|
|
|
|
--name tja2fumen-${{ github.event.inputs.release_version }} `
|
|
|
|
--add-data="src\tja2fumen\soulgauge_LUTs\*.csv;tja2fumen\soulgauge_LUTs" `
|
|
|
|
--onefile `
|
|
|
|
--exclude-module bz2 `
|
|
|
|
--exclude-module hashlib `
|
|
|
|
--exclude-module lzma `
|
|
|
|
--exclude-module socket `
|
|
|
|
--exclude-module ssl `
|
|
|
|
--exclude-module unicodedata `
|
|
|
|
--exclude-module select
|
2023-06-27 01:56:46 +02:00
|
|
|
|
2023-06-29 07:20:46 +02:00
|
|
|
- name: Run tests (installed wheel)
|
|
|
|
run: pytest testing --entry-point exe
|
|
|
|
|
2023-06-27 01:56:46 +02:00
|
|
|
- name: Push release changes
|
2023-06-29 07:20:46 +02:00
|
|
|
# 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'
|
2023-06-27 01:56:46 +02:00
|
|
|
run: |
|
|
|
|
git tag ${{ github.event.inputs.release_version }}
|
|
|
|
git push --tags
|
|
|
|
|
|
|
|
- uses: ncipollo/release-action@v1
|
2023-06-29 07:20:46 +02:00
|
|
|
# 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'
|
2023-06-27 01:56:46 +02:00
|
|
|
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
|
2023-06-29 07:20:46 +02:00
|
|
|
# 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'
|
2023-06-27 01:56:46 +02:00
|
|
|
run: twine upload dist/*.whl dist/*.tar.gz --username __token__ --password ${{ secrets.PYPI_API_TOKEN }}
|