clean out cruft from release #57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This workflow will upload a Python Package using Twine when a release is created | |
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries | |
| # This workflow uses actions that are not certified by GitHub. | |
| # They are provided by a third-party and are governed by | |
| # separate terms of service, privacy policy, and support | |
| # documentation. | |
| name: Publish | |
| on: | |
| push: | |
| branches: | |
| - 'develop' | |
| tags: | |
| - 'v*.*.*' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| id-token: write # Required for PyPI Trusted Publishing | |
| jobs: | |
| build-and-publish-python: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| package-version: ${{ steps.get_version.outputs.version }} | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Ensure full Git history is available for versioning | |
| fetch-tags: true | |
| - name: Set Up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| - name: Set Environment Variables | |
| run: | | |
| if [ "${{ github.ref }}" == "refs/heads/develop" ]; then | |
| echo "REDFETCH_BASE_URL=https://www.redguides.com/devtestbaby" >> $GITHUB_ENV | |
| # NOTE: to update an .exe that's pre-release, as we do on develop, PYAPP requires you to pass --pre: | |
| # .\redfetch.exe self update --pre | |
| fi | |
| - name: Install Hatch | |
| uses: pypa/hatch@install | |
| - name: Run Tests | |
| run: | | |
| hatch test | |
| - name: Clean workspace (remove test artifacts) | |
| run: | | |
| git clean -xfd | |
| - name: Build Package | |
| run: | | |
| hatch build | |
| - name: Get Version | |
| id: get_version | |
| run: | | |
| VERSION=$(hatch version) | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| echo "Set version to: ${VERSION}" | |
| - name: Publish to TestPyPI | |
| if: github.ref == 'refs/heads/develop' | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ | |
| - name: Publish to PyPI | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| build-and-publish-exe: | |
| needs: build-and-publish-python | |
| if: needs.build-and-publish-python.result == 'success' | |
| runs-on: windows-latest | |
| outputs: | |
| project-version: ${{ steps.set_version.outputs.version }} | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Ensure full Git history is available for versioning | |
| - name: Set Environment Variables | |
| id: set_env_vars | |
| shell: pwsh | |
| run: | | |
| # Set static environment variables | |
| "PYAPP_PROJECT_NAME=redfetch" >> $env:GITHUB_ENV | |
| "PYAPP_EXEC_MODULE=redfetch.main" >> $env:GITHUB_ENV | |
| "PYAPP_PASS_LOCATION=1" >> $env:GITHUB_ENV | |
| # Conditionally set PYAPP_PIP_EXTRA_ARGS based on the branch or tag | |
| if ($env:GITHUB_REF -eq 'refs/heads/develop') { | |
| $pipArgs = "--index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/" | |
| } else { | |
| $pipArgs = "" | |
| } | |
| "PYAPP_PIP_EXTRA_ARGS=$pipArgs" >> $env:GITHUB_ENV | |
| # Output the values for verification | |
| Get-Content $env:GITHUB_ENV | |
| - name: Set Up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| - name: Install Hatch | |
| run: pip install hatch | |
| - name: Set PYAPP_PROJECT_VERSION | |
| id: set_version | |
| run: | | |
| $version = "${{ needs.build-and-publish-python.outputs.package-version }}" | |
| echo "Setting version to: $version" | |
| "PYAPP_PROJECT_VERSION=$version" >> $env:GITHUB_ENV | |
| "version=$version" >> $env:GITHUB_OUTPUT | |
| shell: pwsh | |
| - name: Set Up Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: stable | |
| components: rustfmt, clippy | |
| - name: Install 7-Zip | |
| run: choco install 7zip --no-progress -y | |
| - name: Download PyApp Source | |
| shell: pwsh | |
| run: | | |
| Invoke-WebRequest https://github.com/ofek/pyapp/releases/latest/download/source.zip -OutFile pyapp-source.zip | |
| 7z x pyapp-source.zip -o"./pyapp-source" | |
| $dir = Get-ChildItem -Path .\pyapp-source\ -Directory | Select-Object -First 1 | |
| Move-Item -Path $dir.FullName -Destination pyapp-latest | |
| - name: Build PyApp Executable | |
| run: | | |
| $env:PYAPP_PROJECT_NAME = "${{ env.PYAPP_PROJECT_NAME }}" | |
| $env:PYAPP_EXEC_MODULE = "${{ env.PYAPP_EXEC_MODULE }}" | |
| $env:PYAPP_PASS_LOCATION = "${{ env.PYAPP_PASS_LOCATION }}" | |
| $env:PYAPP_PIP_EXTRA_ARGS = "${{ env.PYAPP_PIP_EXTRA_ARGS }}" | |
| $env:PYAPP_PROJECT_VERSION = "${{ env.PYAPP_PROJECT_VERSION }}" | |
| Write-Host "PYAPP_PROJECT_NAME: $env:PYAPP_PROJECT_NAME" | |
| Write-Host "PYAPP_EXEC_MODULE: $env:PYAPP_EXEC_MODULE" | |
| Write-Host "PYAPP_PASS_LOCATION: $env:PYAPP_PASS_LOCATION" | |
| Write-Host "PYAPP_PIP_EXTRA_ARGS: $env:PYAPP_PIP_EXTRA_ARGS" | |
| Write-Host "PYAPP_PROJECT_VERSION: $env:PYAPP_PROJECT_VERSION" | |
| cargo build --release | |
| working-directory: .\pyapp-latest | |
| shell: pwsh | |
| - name: Rename and Move Executable | |
| shell: pwsh | |
| run: | | |
| Move-Item .\pyapp-latest\target\release\pyapp.exe redfetch.exe | |
| - name: Download rcedit | |
| shell: pwsh | |
| run: | | |
| Invoke-WebRequest https://github.com/electron/rcedit/releases/latest/download/rcedit-x64.exe -OutFile rcedit.exe | |
| - name: Modify Executable Properties | |
| shell: pwsh | |
| run: | | |
| .\rcedit.exe redfetch.exe ` | |
| --set-version-string "ProductName" "redfetch" ` | |
| --set-version-string "FileDescription" "Download and publish EverQuest scripts and software using the RedGuides API" ` | |
| --set-file-version "${{ env.PYAPP_PROJECT_VERSION }}" ` | |
| --set-product-version "${{ env.PYAPP_PROJECT_VERSION }}" ` | |
| --set-version-string "LegalCopyright" "© RedGuides, LLC" ` | |
| --set-version-string "OriginalFilename" "redfetch.exe" ` | |
| --set-version-string "InternalName" "redfetch" ` | |
| --set-icon "redfetch.ico" | |
| - name: Sign Executable | |
| uses: dlemstra/code-sign-action@v1 | |
| with: | |
| certificate: '${{ secrets.CERTIFICATE_PFX }}' | |
| password: '${{ secrets.CERTIFICATE_PFX_PASSWORD }}' | |
| files: | | |
| redfetch.exe | |
| description: 'redfetch executable' | |
| - name: Upload Executable Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: redfetch.exe | |
| path: redfetch.exe | |
| publish-to-redguides: | |
| needs: build-and-publish-exe | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Download Executable Artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: redfetch.exe | |
| - name: Redguides Publish | |
| uses: RedGuides/redguides-publish@v1 | |
| env: | |
| REDGUIDES_API_KEY: ${{ secrets.REDGUIDES_API_KEY }} | |
| with: | |
| resource_id: '3177' | |
| description: 'README.md' | |
| version: ${{ needs.build-and-publish-exe.outputs.project-version }} | |
| message: 'CHANGELOG.md' | |
| file: 'redfetch.exe' | |
| domain: 'https://raw.githubusercontent.com/RedGuides/redfetch/main/' |