Merge pull request #54 from Hpero4/main #40
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 Seraphine | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
build-seraphine: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install dependencies | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.8' | |
cache: 'pip' | |
- name: Pack Seraphine | |
run: | | |
pip install -r requirements.txt | |
pip install pyinstaller | |
.\make.ps1 | |
echo "SUCCESS=true" >> $GITHUB_ENV | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
if: ${{ env.SUCCESS }} == 'true' | |
with: | |
name: Seraphine | |
path: .\Seraphine.zip | |
release: | |
needs: build-seraphine | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup environment variables | |
run: | | |
export VERSION_CHANGED_COMMIT_HASH=$(git blame app/common/config.py --root -l | grep -Po "([\w]+) (?=\(.*\) VERSION = )") | |
export HEAD_COMMIT_HASH=$(git log -1 --format='%H') | |
export UPDATED=$(python -c "import os; UPDATED = 'true' if os.environ['HEAD_COMMIT_HASH'].strip() == os.environ['VERSION_CHANGED_COMMIT_HASH'].strip() else 'false'; print(UPDATED)") | |
export VERSION=$(cat app/common/config.py | grep -Po "(?<=VERSION = \")(.*[^\"])") | |
echo "VERSION=v$VERSION" >> $GITHUB_ENV | |
echo "UPDATED=$UPDATED" >> $GITHUB_ENV | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
if: env.UPDATED == 'true' | |
with: | |
name: Seraphine | |
path: ./ | |
- name: Push to release | |
uses: ncipollo/release-action@v1 | |
if: env.UPDATED == 'true' | |
with: | |
name: ${{ env.VERSION }} | |
tag: ${{ env.VERSION }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
replacesArtifacts: false | |
artifacts: Seraphine.zip |