Fixed function that deletes old releases #8
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
name: Build | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- '**.py' | |
- '**.yml' | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: windows-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12.6 | |
cache: 'pip' | |
- name: Install requirements | |
run: | | |
pip install -r requirements.txt | |
- name: Make Build | |
run: | | |
python builder.py | |
- name: Set artifact path/name | |
run: | | |
$ARTIFACT_PATH=Get-ChildItem -Path .\ -Filter "CollapseUpdater*.exe" -Recurse | Select-Object -ExpandProperty Name | Split-Path -Leaf | |
echo "ARTIFACT_PATH=$ARTIFACT_PATH" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 | |
$ARTIFACT_HASH=git rev-parse --short HEAD | |
echo "ARTIFACT_HASH=$ARTIFACT_HASH" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 | |
$commitHash = git rev-parse --short HEAD | |
Get-ChildItem -Path .\ -Filter "CollapseUpdater*.exe" | ForEach-Object { | |
$ARTIFACT_PATH = "CollapseUpdater_$commitHash.exe" | |
echo "ARTIFACT_PATH=$ARTIFACT_PATH" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 | |
Rename-Item -Path $_.FullName -NewName $ARTIFACT_PATH | |
} | |
echo $ARTIFACT_PATH | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: CollapseUpdater | |
path: ${{ env.ARTIFACT_PATH }} | |
- name: Get MD5 Hash of build | |
run: | | |
$MD5_HASH=Get-FileHash ${{ env.ARTIFACT_PATH }} -Algorithm MD5 | |
echo "MD5 hash of build $($MD5_HASH.Hash) check it to make sure you downloaded a clean build without viruses." | |
echo "MD5_HASH=$($MD5_HASH.Hash)" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 | |
- name: Make release | |
uses: ncipollo/release-action@v1 | |
with: | |
body: "${{ env.ARTIFACT_PATH }}\nMD5 hash: ${{ env.MD5_HASH }}" | |
name: 'Github actions build: ${{ env.ARTIFACT_HASH }}' | |
tag: 'autorelease-${{ env.ARTIFACT_HASH }}' | |
prerelease: true | |
artifacts: '*.exe' |