From 4a2ee1cac0555d9855a41d6753538097330b4114 Mon Sep 17 00:00:00 2001 From: Viv Date: Mon, 26 Jun 2023 19:56:46 -0400 Subject: [PATCH] `create-release.yml`: Add release workflow --- .github/workflows/create_release.yml | 66 ++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .github/workflows/create_release.yml diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml new file mode 100644 index 0000000..e7d8674 --- /dev/null +++ b/.github/workflows/create_release.yml @@ -0,0 +1,66 @@ +name: "Create release" + +on: + workflow_dispatch: + inputs: + release_version: + description: 'Release version number' + required: true + +jobs: + create-release: + runs-on: windows-2019 + # Only create the release if workflow is run manually. (This allows the other steps in the workflow to test PRs.) + if: github.event_name == 'workflow_dispatch' + steps: + # 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 + run: | + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --global user.name "GitHub Actions Bot" + + - name: Checkout tja2fumen (main branch) + uses: actions/checkout@v3 + with: + ref: ${{ env.MAIN_BRANCH }} + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.8.x' + + - name: Install dependencies + run: pip install toml-cli build twine pyinstaller + + - name: Update pyproject.toml version (for release) + 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: Build pyinstaller executable + run: | + pyinstaller src\tja2fumen\__init__.py --name tja2fumen-${{ github.event.inputs.release_version }} --add-data="src\tja2fumen\soulgauge_LUTs\*.csv;tja2fumen\soulgauge_LUTs" --onefile + + - name: Push release changes + run: | + git tag ${{ github.event.inputs.release_version }} + git push --tags + + - uses: ncipollo/release-action@v1 + 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 + run: twine upload dist/*.whl dist/*.tar.gz --username __token__ --password ${{ secrets.PYPI_API_TOKEN }}