This repository has been archived by the owner on Oct 12, 2024. It is now read-only.
check for new release, better release and more json files #14
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: Build and Release | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
paths-ignore: | |
- '.github/**' | |
- '.*' | |
- 'README.md' | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' # Always use the latest stable version of Python 3 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip setuptools | |
pip install -r requirements.txt | |
- name: Install PyInstaller | |
run: pip install pyinstaller | |
- name: Save build number | |
run: | | |
$BUILD_NUMBER = "$(Get-Date -Format 'yyyyMMddHHmmss')" | |
echo "__version__ = '$BUILD_NUMBER'" > src/utils/version.py | |
- name: Build executable | |
run: pyinstaller upload.spec | |
- name: Prepare files for zip | |
run: | | |
mkdir zip_content | |
mkdir zip_content/data | |
Copy-Item -Path dist/upload.exe -Destination zip_content/ | |
Copy-Item -Path data/config.example.json -Destination zip_content/data/config.json | |
Copy-Item -Path data/naming.json -Destination zip_content/data/ | |
Copy-Item -Path data/tags.json -Destination zip_content/data/ | |
Copy-Item -Path data/audio_config.json -Destination zip_content/data/ | |
Copy-Item -Path data/distribution.json -Destination zip_content/data/ | |
Copy-Item -Path data/regions.json -Destination zip_content/data/ | |
Copy-Item -Path data/services.json -Destination zip_content/data/ | |
Copy-Item -Path data/editions.json -Destination zip_content/data/ | |
Copy-Item -Path data/addons/description.txt -Destination zip_content/ | |
Copy-Item -Path data/addons/run.bat -Destination zip_content/ | |
- name: Create zip file | |
run: | | |
Compress-Archive -Path zip_content/* -DestinationPath utopia_ua.zip | |
- name: Archive executable | |
uses: actions/upload-artifact@v3 | |
with: | |
name: upload-executable | |
path: utopia_ua.zip | |
- name: Create Tag | |
id: create_tag | |
shell: pwsh | |
run: | | |
$TAG_NAME = "v${{ env.BUILD_NUMBER }}" | |
echo "TAG_NAME=$TAG_NAME" >> $env:GITHUB_ENV | |
git tag $TAG_NAME | |
git push origin $TAG_NAME | |
- name: Determine if Pre-release | |
id: prerelease_check | |
run: echo "IS_PRERELEASE=$([[ '${{ github.ref }}' != 'refs/heads/main' ]] && echo true || echo false)" >> $GITHUB_ENV | |
- name: Create GitHub Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }} | |
with: | |
tag_name: ${{ env.TAG_NAME }} | |
release_name: Release ${{ env.TAG_NAME }} | |
draft: false | |
prerelease: ${{ env.IS_PRERELEASE }} | |
- name: Upload Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: utopia_ua.zip | |
asset_name: utopia_ua.zip | |
asset_content_type: application/zip |