Skip to content

Update SHA256

Update SHA256 #22

name: Update Latest Release Assets
on:
push:
branches: [ main, master ]
permissions:
contents: write
jobs:
build-and-attach:
name: Build (${{ matrix.os }}) and attach to latest release
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ windows-latest ]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt pyinstaller pillow
- name: Build app (Windows)
if: startsWith(matrix.os, 'windows')
shell: pwsh
run: |
python build.py --name ChatMock --entry app_qt.py
if (Test-Path dist/ChatMock-windows.zip) { Remove-Item dist/ChatMock-windows.zip -Force }
Compress-Archive -Path "dist/ChatMock/*" -DestinationPath "dist/ChatMock-windows.zip"
- name: Set asset variables
id: asset
shell: bash
run: |
echo "name=ChatMock-windows.zip" >> $GITHUB_OUTPUT
echo "path=dist/ChatMock-windows.zip" >> $GITHUB_OUTPUT
- name: Get latest release
id: latest_release
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
try {
const latest = await github.rest.repos.getLatestRelease({ owner, repo });
core.setOutput('id', latest.data.id.toString());
core.setOutput('tag', latest.data.tag_name);
core.setOutput('upload_url', latest.data.upload_url);
} catch (e) {
core.warning(`No releases found or error fetching latest release: ${e.message}`);
core.setOutput('id', '');
core.setOutput('tag', '');
core.setOutput('upload_url', '');
}
- name: Delete prior asset for this platform
if: steps.latest_release.outputs.tag != ''
uses: actions/github-script@v7
env:
RELEASE_ID: ${{ steps.latest_release.outputs.id }}
ASSET_NAME: ${{ steps.asset.outputs.name }}
with:
script: |
const { owner, repo } = context.repo;
const release_id = Number(process.env.RELEASE_ID);
const assetName = process.env.ASSET_NAME;
const assets = await github.rest.repos.listReleaseAssets({ owner, repo, release_id, per_page: 100 });
const match = assets.data.find(a => a.name === assetName);
if (match) {
core.info(`Deleting existing asset: ${match.name} (id=${match.id})`);
await github.rest.repos.deleteReleaseAsset({ owner, repo, asset_id: match.id });
} else {
core.info(`No existing asset named ${assetName} found.`);
}
- name: Upload new asset to latest release
if: steps.latest_release.outputs.tag != ''
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.latest_release.outputs.tag }}
files: ${{ steps.asset.outputs.path }}