Skip to content

Deploy latest assets #121

Deploy latest assets

Deploy latest assets #121

Workflow file for this run

name: Deploy latest assets
on:
workflow_run:
workflows: ["Build installer"]
types:
- completed
workflow_dispatch:
inputs:
run_id:
description: "The ID of the workflow run to download artifacts from"
required: false
permissions:
contents: write
actions: write
jobs:
publish:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Create artifacts directory
run: |
mkdir artifacts/
- name: Determine run_id
id: set_run_id
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
if [ -n "${{ github.event.inputs.run_id }}" ]; then
echo "run_id=${{ github.event.inputs.run_id }}" >> $GITHUB_OUTPUT
echo "has_run_id=true" >> $GITHUB_OUTPUT
else
echo "has_run_id=false" >> $GITHUB_OUTPUT
fi
elif [ "${{ github.event_name }}" = "workflow_run" ]; then
echo "run_id=${{ github.event.workflow_run.id }}" >> $GITHUB_OUTPUT
echo "has_run_id=true" >> $GITHUB_OUTPUT
else
echo "has_run_id=false" >> $GITHUB_OUTPUT
fi
- name: Download artifacts
if: steps.set_run_id.outputs.has_run_id == 'true'
run: |
run_id=${{ steps.set_run_id.outputs.run_id }}
gh run download $run_id -D artifacts/
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Organize artifacts
if: steps.set_run_id.outputs.has_run_id == 'true'
run: |
for folder in artifacts/*/; do
[ -d "$folder" ] || continue
file=$(find "$folder" -maxdepth 1 -type f)
filename=$(basename "$file")
foldername=$(basename "$folder")
if [ "$filename" = "$foldername" ]; then
extension="${filename##*.}"
tempname="${foldername}_file.$extension"
mv "$file" "artifacts/$tempname"
rmdir "$folder"
mv "artifacts/$tempname" "artifacts/$filename"
else
mv "$file" artifacts/
rmdir "$folder"
fi
done
- name: Download updater scripts
run: |
curl -L -o artifacts/updater.bat https://raw.githubusercontent.com/sineorg/installer/main/updater.bat
curl -L -o artifacts/updater.sh https://raw.githubusercontent.com/sineorg/installer/main/updater.sh
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Generate packages
run: |
pip install -r scripts/requirements.txt
python scripts/package.py
mv engine.zip artifacts/engine.zip
mv locales.zip artifacts/locales.zip
- name: Get latest release
id: latest_release
run: |
latest=$(gh release list --limit 1 --json tagName,isPrerelease,publishedAt --jq '.[0].tagName')
echo "Latest release tag: $latest"
echo "release_tag=$latest" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifacts to latest release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.latest_release.outputs.release_tag }}
files: artifacts/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}