From 7194a335dd3ebb642da749daf7119df7479bc210 Mon Sep 17 00:00:00 2001 From: infeeeee Date: Tue, 28 Mar 2023 00:12:32 +0200 Subject: [PATCH] Windows installer, reorganize workflows --- .github/workflows/build-exe.yml | 28 +++++++++++++++ .github/workflows/build-installer.yml | 35 +++++++++++++++++++ .github/workflows/release.yml | 49 +++++++++++++-------------- .github/workflows/test.yml | 8 +++-- .github/workflows/unittests.yml | 1 + .github/workflows/website.yml | 14 +++++--- .github/workflows/windows-build.yml | 17 ++++++++++ README.md | 11 +++--- TODO.md | 2 +- dyn2py-installer.iss | 2 +- 10 files changed, 127 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/build-exe.yml create mode 100644 .github/workflows/build-installer.yml create mode 100644 .github/workflows/windows-build.yml diff --git a/.github/workflows/build-exe.yml b/.github/workflows/build-exe.yml new file mode 100644 index 0000000..92067c4 --- /dev/null +++ b/.github/workflows/build-exe.yml @@ -0,0 +1,28 @@ +on: + workflow_call: + +name: Workflow - Build exe + +jobs: + build: + runs-on: windows-latest + name: Build Windows exe + + steps: + - uses: actions/checkout@v3 + name: Checkout + - uses: actions/setup-python@v4 + name: Setup Python + with: + python-version: ${{ vars.PYTHON_VERSION}} + - name: Install deps + run: | + python -m pip install --upgrade pip + pip install .[build] + - name: Build + run: pyinstaller dyn2py.spec + - uses: actions/upload-artifact@v3 + name: Upload artifact + with: + name: dyn2py.exe + path: dist/dyn2py.exe diff --git a/.github/workflows/build-installer.yml b/.github/workflows/build-installer.yml new file mode 100644 index 0000000..6e5b56e --- /dev/null +++ b/.github/workflows/build-installer.yml @@ -0,0 +1,35 @@ +on: + workflow_call: + +name: Workflow - Build installer + +jobs: + build-installer: + runs-on: windows-latest + name: Build Windows installer + + steps: + - uses: actions/checkout@v3 + name: Checkout + - name: Install Inno Setup + run: | + Invoke-WebRequest -Uri https://jrsoftware.org/download.php/is.exe -OutFile is.exe + .\is.exe /verysilent + - name: Download artifact + uses: actions/download-artifact@v3 + with: + name: dyn2py.exe + path: dist/dyn2py.exe + - name: Update version number + run: | + $regex = Select-String -Path pyproject.toml -Pattern '^version = "((?:\d\.){2}\d)"$' + $version = $regex.Matches.Groups[1].Value + (Get-Content dyn2py-installer.iss).Replace("x.x.x",$version) | Set-Content dyn2py-installer.iss + - name: Build installer + run: | + & "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" -Qp $(Join-Path $PWD.Path dyn2py-installer.iss) + - uses: actions/upload-artifact@v3 + name: Upload artifact + with: + name: dyn2py-installer.exe + path: Output/dyn2py-installer.exe diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ea2bfc7..5916e1e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,39 +10,29 @@ permissions: jobs: test: + name: Test strategy: matrix: os: [ubuntu-latest, windows-latest] uses: ./.github/workflows/test.yml with: - python-version: ${{ vars.PYTHON_VERSION}} + python-version: ${{ vars.PYTHON_VERSION }} os: ${{ matrix.os }} - build: - runs-on: windows-latest + build-exe: + name: Build Windows exe needs: test - steps: - - uses: actions/checkout@v3 - name: Checkout - - uses: actions/setup-python@v4 - name: Setup Python - with: - python-version: ${{ vars.PYTHON_VERSION}} - - name: Install deps - run: | - python -m pip install --upgrade pip - pip install .[build] - - name: Build - run: pyinstaller dyn2py.spec - - uses: actions/upload-artifact@v3 - name: Upload artifact - with: - name: dyn2py.exe - path: dist/dyn2py.exe + uses: ./.github/workflows/build-exe.yml + + build-installer: + name: Build Windows installer + needs: build-exe + uses: ./.github/workflows/build-installer.yml release: + name: Create Github release runs-on: ubuntu-latest - needs: build + needs: build-installer steps: - uses: actions/checkout@v3 name: Checkout @@ -51,17 +41,24 @@ jobs: uses: metcalfc/changelog-generator@v4.1.0 with: myToken: ${{ secrets.GITHUB_TOKEN }} - - name: Download artifact + - name: Download exe uses: actions/download-artifact@v3 with: name: dyn2py.exe + - name: Download installer + uses: actions/download-artifact@v3 + with: + name: dyn2py-installer.exe - name: Release uses: softprops/action-gh-release@v1 with: - files: dyn2py.exe - body: ${{ steps.modified.outputs.log }} + files: | + dyn2py.exe + dyn2py-installer.exe + body: ${{ steps.changelog.outputs.changelog }} pip: + name: Publish to PyPI runs-on: ubuntu-latest needs: release steps: @@ -70,7 +67,7 @@ jobs: - uses: actions/setup-python@v4 name: Setup Python with: - python-version: ${{ vars.PYTHON_VERSION}} + python-version: ${{ vars.PYTHON_VERSION }} - name: Install deps run: | python -m pip install --upgrade pip diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aa2849f..72052f7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,11 +8,15 @@ on: required: true type: string +name: Workflow - Test + jobs: test: + name: Run tests runs-on: ${{ inputs.os }} steps: - uses: actions/checkout@v3 + name: Checkout - name: Set up Python ${{ inputs.python-version }} uses: actions/setup-python@v4 with: @@ -21,5 +25,5 @@ jobs: run: | python -m pip install --upgrade pip pip install . - - name: Test - run: python -m unittest discover -v -s ./tests -p "test_*.py" \ No newline at end of file + - name: Run tests + run: python -m unittest discover -v -s ./tests -p "test_*.py" diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index 5f7b548..eccefca 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -11,6 +11,7 @@ permissions: jobs: tests: + name: Unit tests strategy: matrix: os: [ubuntu-latest, windows-latest] diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index 61b5dc9..65d5f83 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -5,7 +5,6 @@ on: branches: - main - # Allows you to run this workflow manually from the Actions tab workflow_dispatch: # security: restrict permissions for CI jobs. @@ -18,19 +17,22 @@ concurrency: cancel-in-progress: true jobs: - # Build the documentation and upload the static HTML files as an artifact. build: + name: Build documentation runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + name: Checkout - uses: actions/setup-python@v4 + name: Setup Python with: - python-version: "3.11" - + python-version: ${{ vars.PYTHON_VERSION }} - run: pip install -e .[doc] + name: Install deps - run: pdoc -d google -o docs dyn2py - + name: Generate docs - uses: actions/upload-pages-artifact@v1 + name: Upload artifact with: path: docs/ @@ -38,6 +40,7 @@ jobs: # This is a separate job so that only actions/deploy-pages has the necessary permissions. deploy: needs: build + name: Publish documentation runs-on: ubuntu-latest permissions: pages: write @@ -47,4 +50,5 @@ jobs: url: ${{ steps.deployment.outputs.page_url }} steps: - id: deployment + name: Deploy page uses: actions/deploy-pages@v1 diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml new file mode 100644 index 0000000..9c2f1fb --- /dev/null +++ b/.github/workflows/windows-build.yml @@ -0,0 +1,17 @@ +name: Build Windows exe and installer + +on: + workflow_dispatch: + pull_request: + branches: ["main"] + # push: + +jobs: + build-exe: + uses: ./.github/workflows/build-exe.yml + name: Build Windows exe + + build-installer: + name: Build Windows installer + needs: build-exe + uses: ./.github/workflows/build-installer.yml diff --git a/README.md b/README.md index e6464df..07b4f7a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ [![GitHub Release Date](https://img.shields.io/github/release-date/infeeeee/dyn2py?style=flat-square)](https://github.com/infeeeee/dyn2py/releases/latest) [![GitHub last commit (branch)](https://img.shields.io/github/last-commit/infeeeee/dyn2py/main?style=flat-square)](https://github.com/infeeeee/dyn2py/commits/main) [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/infeeeee/dyn2py/unittests.yml?label=tests&style=flat-square)](https://github.com/infeeeee/dyn2py/actions/workflows/unittests.yml) -![GitHub top language](https://img.shields.io/github/languages/top/infeeeee/dyn2py?style=flat-square) [![GitHub](https://img.shields.io/github/license/infeeeee/dyn2py?style=flat-square)](https://github.com/infeeeee/dyn2py/blob/main/LICENSE) # dyn2py @@ -17,14 +16,16 @@ Use cases: ## Installation -### Windows portable +### Windows portable and installer -Prebuilt exe available from github releases. +Prebuilt portable exe and installer available from github releases. -No requirements, just download `dyn2py.exe` from release assets: +No requirements, just download `dyn2py.exe` or `dyn2py-installer.exe` from release assets: https://github.com/infeeeee/dyn2py/releases/latest +Installer automatically adds the install folder to the path, so simply `dyn2py` can be called from anywhere. + ### With pip For usage as a module or as a command line program @@ -178,8 +179,8 @@ pyinstaller dyn2py.spec ### Create installer for Windows -- The already built exe should be in `dist\dyn2py.exe` - Install Inno Setup: https://jrsoftware.org/isdl.php +- The already built exe should be in `dist\dyn2py.exe` - Run this in powershell: ```powershell diff --git a/TODO.md b/TODO.md index 7a1a584..0eb4df3 100644 --- a/TODO.md +++ b/TODO.md @@ -15,6 +15,7 @@ - [x] Tests on Windows - [x] Windows Build - [x] Pip +- [x] Windows Installer ## Documentation @@ -25,6 +26,5 @@ ## Extra features maybe later -- [ ] Windows Installer - [ ] Autocomplete - [ ] Winget \ No newline at end of file diff --git a/dyn2py-installer.iss b/dyn2py-installer.iss index 076e3ec..807dc0a 100644 --- a/dyn2py-installer.iss +++ b/dyn2py-installer.iss @@ -20,7 +20,7 @@ ChangesEnvironment=yes Name: "english"; MessagesFile: "compiler:Default.isl" [Files] -Source: "dist\dyn2py.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "dist\dyn2py.exe"; DestDir: "{app}"; Flags: ignoreversion external [Code]