Release #2
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: Release | |
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 --upgrade cx_Freeze | |
shell: pwsh | |
- name: Build MSI | |
run: | | |
.\venv\Scripts\Activate | |
cd app | |
python build.py bdist_msi | |
shell: pwsh | |
- name: Get App Info | |
id: get_version | |
run: | | |
.\venv\Scripts\Activate | |
$version = (Get-Content app/core/utils/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 app/dist/out/*.msi).Name | |
echo "FILENAME=$filename" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
shell: pwsh | |
- name: Create Portable ZIP | |
run: | | |
.\venv\Scripts\Activate | |
Remove-Item -Path app/dist/frozen_application_license.txt | |
$zipFilename = "$env:FILENAME".Replace('.msi', '-portable.zip') | |
$app_zip = "app/dist" | |
$app_out = "app/dist/out/$zipFilename" | |
$DirToExclude = @("out") | |
Get-ChildItem $app_zip | Where-Object { $_.PSIsContainer -and $_.Name -notin $DirToExclude -or -not $_.PSIsContainer } | Compress-Archive -DestinationPath $app_out -CompressionLevel Optimal -Update | |
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/tag-changelog@v1.3.0 | |
with: | |
token: ${{ secrets.PAT }} | |
config_file: .github/changelog/changelog.js | |
- name: Generate Checksum | |
run: | | |
.\venv\Scripts\Activate | |
$msi_checksum = Get-FileHash app/dist/out/*.msi -Algorithm SHA256 | |
$zip_checksum = Get-FileHash app/dist/out/*.zip -Algorithm SHA256 | |
$msi_filename = [System.IO.Path]::GetFileName($msi_checksum.Path) | |
$zip_filename = [System.IO.Path]::GetFileName($zip_checksum.Path) | |
"$($msi_checksum.Hash) $msi_filename" > app/dist/out/checksums.txt | |
"$($zip_checksum.Hash) $zip_filename" >> app/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: | | |
app/dist/out/*.zip | |
app/dist/out/*.msi | |
app/dist/out/checksums.txt | |
prerelease: false | |
generate_release_notes: true | |
draft: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT }} |