Windows #40
This file contains 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
name: Windows | |
on: | |
workflow_dispatch: | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Create virtual environment | |
run: | | |
python -m venv venv | |
shell: pwsh | |
- name: Activate virtual environment and install dependencies | |
run: | | |
.\venv\Scripts\Activate | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install colorama | |
pip install --upgrade cx_Freeze | |
# pip install --force --no-cache --pre --extra-index-url https://marcelotduarte.github.io/packages/ cx_Freeze | |
shell: pwsh | |
- name: Build MSI | |
run: | | |
.\venv\Scripts\Activate | |
cd src | |
python build.py bdist_msi | |
shell: pwsh | |
- name: Get App Info | |
id: get_version | |
run: | | |
.\venv\Scripts\Activate | |
$version = (Get-Content src/settings.py | Select-String -Pattern 'BUILD_VERSION\s*=\s*"([^"]+)"').Matches.Groups[1].Value | |
echo "VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
$filename = (Get-ChildItem -Path src/dist/out/*.msi).Name | |
echo "FILENAME=$filename" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
shell: pwsh | |
- name: Create Tag | |
id: create_tag | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.PAT }} | |
script: | | |
const version = `v${process.env.VERSION}`; | |
const { owner, repo } = context.repo; | |
const sha = context.sha; | |
try { | |
const { data: tags } = await github.rest.repos.listTags({ | |
owner, | |
repo, | |
}); | |
const tagExists = tags.some(tag => tag.name === version); | |
if (!tagExists) { | |
console.log(`Creating tag ${version}`); | |
await github.rest.git.createRef({ | |
owner, | |
repo, | |
ref: `refs/tags/${version}`, | |
sha, | |
}); | |
} else { | |
console.log(`Tag ${version} already exists, skipping tag creation`); | |
} | |
} catch (error) { | |
console.error(`Error fetching tags: ${error.message}`); | |
throw error; | |
} | |
- name: Fetch all tags | |
run: git fetch --tags | |
shell: pwsh | |
- name: Create Changelog | |
id: changelog | |
uses: loopwerk/[email protected] | |
with: | |
token: ${{ secrets.PAT }} | |
config_file: .github/changelog/changelog.js | |
- name: Generate Checksum | |
run: | | |
.\venv\Scripts\Activate | |
$checksum = Get-FileHash src/dist/out/*.msi -Algorithm SHA256 | |
$filename = [System.IO.Path]::GetFileName($checksum.Path) | |
"$($checksum.Hash) $filename" > src/dist/out/checksums.txt | |
shell: pwsh | |
- name: Create and Upload Release | |
id: create_release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: v${{ env.VERSION }} | |
name: v${{ env.VERSION }} | |
body: | | |
${{ steps.changelog.outputs.changes }} | |
append_body: true | |
files: | | |
src/dist/out/*.msi | |
src/dist/out/checksums.txt | |
prerelease: false | |
generate_release_notes: true | |
draft: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT }} |