diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9dfd676..9728a65 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: Deploy-to-updater +name: Build-and-deploy on: pull_request: types: @@ -7,16 +7,58 @@ on: - main jobs: - - deploy: - if: github.event.pull_request.merged == true - runs-on: ubuntu-latest # windows-latest | macos-latest - name: Deploy to updater if files changed + build-exe: + runs-on: windows-latest + name: Build the executable steps: - uses: actions/checkout@v3 with: fetch-depth: 0 # OR "2" -> To retrieve the preceding commit. + - name: Set up Python 3.10.7 + uses: actions/setup-python@v3 + with: + python-version: "3.10.7" + + - name: Install requirements from requirements.txt + run: | + cd Generator + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Build UI resources + run: | + cd Generator + pyuic5 -x MissionGeneratorUI.ui -o MissionGeneratorUI.py + pyrcc5 -o resources.py resources.qrc + + - name: Build the executable + run: | + cd Generator + pyinstaller MissionGenerator.spec --clean --log-level=DEBUG + + - name: Archive the executable + uses: actions/upload-artifact@v4 + with: + name: MissionGenerator + path: Generator/dist/MissionGenerator.exe + if-no-files-found: error + + deploy: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + name: Deploy to updater + needs: build-exe + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # OR "2" -> To retrieve the preceding commit. + + - name: Retrieve the executable + uses: actions/download-artifact@v4 + with: + name: MissionGenerator + - name: Get monitored changed files id: changed-files uses: tj-actions/changed-files@v35 @@ -28,46 +70,32 @@ jobs: run: | echo "changed_files=${{ steps.changed-files.outputs.all_changed_files }}" >> $GITHUB_ENV for file in ${{ steps.changed-files.outputs.all_changed_files }}; do - echo "$file was changed" + echo "$file was changed and will be added to updater" done - - - name: Test env vars - run: | - echo "${{env.changed_files}}" - + - name: Set up Python 3.10 - if: steps.changed-files.outputs.any_changed == 'true' uses: actions/setup-python@v3 with: python-version: "3.10" - + - name: Install dependencies - if: steps.changed-files.outputs.any_changed == 'true' run: | python -m pip install --upgrade pip pip install PyYAML - + - name: Run release_script.py - if: steps.changed-files.outputs.any_changed == 'true' env: FTP_SERVER: ${{ secrets.FTP_SERVER }} FTP_USERNAME: ${{ secrets.FTP_USERNAME }} FTP_PASSWORD: ${{ secrets.FTP_PASSWORD }} run: | python release_script.py - - - - name: FTP-Deploy - if: steps.changed-files.outputs.any_changed == 'true' - uses: actions/checkout@v2.1.0 - with: - fetch-depth: 2 - name: FTP-Deploy-Action - if: steps.changed-files.outputs.any_changed == 'true' uses: SamKirkland/FTP-Deploy-Action@4.3.3 with: server: ${{ secrets.FTP_SERVER }} username: ${{ secrets.FTP_USERNAME }} password: ${{ secrets.FTP_PASSWORD }} server-dir: Updates/continuous/ + dry-run: false diff --git a/.github/workflows/pre-deploy.yml b/.github/workflows/pre-deploy.yml new file mode 100644 index 0000000..fadeb4a --- /dev/null +++ b/.github/workflows/pre-deploy.yml @@ -0,0 +1,85 @@ +name: Pre-deployment build check +on: + pull_request: + types: + - opened + - synchronize + - reopened + - edited + branches: + - main + +jobs: + version-increment-check: + runs-on: ubuntu-latest + name: Check if version number was incremented + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + + - name: Get the version string from the working directory + run: | + cd Generator + VERSION=$(python -c "from version import *; print(version_string)") + echo NEW_VERSION=$VERSION >> $GITHUB_ENV + + - name: Get the current version string from main branch + run: | + git fetch origin main + git checkout main + cd Generator + VERSION=$(python -c "from version import *; print(version_string)") + echo CURRENT_VERSION=$VERSION >> $GITHUB_ENV + + - name: Install packaging module + run: | + python -m pip install --upgrade pip + pip install packaging + + - name: Check if version number was incremented + run: | + python -c "from packaging import version as ver; assert ver.parse('${{env.NEW_VERSION}}') > ver.parse('${{env.CURRENT_VERSION}}'), 'Version number was not incremented'" + + build-exe: + needs: version-increment-check + runs-on: windows-latest + name: Build the executable + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # OR "2" -> To retrieve the preceding commit. + + - name: Set up Python 3.10.7 + uses: actions/setup-python@v3 + with: + python-version: "3.10.7" + + - name: Install requirements from requirements.txt + run: | + cd Generator + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Build UI resources + run: | + cd Generator + pyuic5 -x MissionGeneratorUI.ui -o MissionGeneratorUI.py + pyrcc5 -o resources.py resources.qrc + + - name: Build the executable + run: | + cd Generator + pyinstaller MissionGenerator.spec --clean --log-level=DEBUG + + - name: Archive the executable + uses: actions/upload-artifact@v4 + with: + name: MissionGenerator + path: Generator/dist/MissionGenerator.exe + if-no-files-found: error diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 1693355..14865b5 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -9,7 +9,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10"] + python-version: ["3.10"] steps: - uses: actions/checkout@v3 diff --git a/.gitignore b/.gitignore index b839060..57e7f8f 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,5 @@ MissionOutput/ *.env RotorOps_setup.exe Generator/resources.py -venv \ No newline at end of file +venv +MissionGenerator.exe \ No newline at end of file diff --git a/Generator/README.md b/Generator/README.md index cb700ee..c4f5155 100644 --- a/Generator/README.md +++ b/Generator/README.md @@ -96,6 +96,8 @@ example: # Building new RotorOps_setup.exe installer package +For a new release, the installer package must be built on your dev machine and attached to the release on GitHub. Installforge does not offer a CLI. + Uses https://installforge.net/ See install-config.ifp and installforge_constants.txt diff --git a/Generator/requirements.txt b/Generator/requirements.txt index 46e80cd..de741ec 100644 --- a/Generator/requirements.txt +++ b/Generator/requirements.txt @@ -1,4 +1,4 @@ --e git+https://github.com/spencershepard/dcs@48b32ae917b2a67d9409345a1f5c368e59e5229f#egg=pydcs +git+https://github.com/spencershepard/dcs@48b32ae917b2a67d9409345a1f5c368e59e5229f packaging==21.3 PyQt5==5.15.9 PyYAML==6.0 diff --git a/MissionGenerator.exe b/MissionGenerator.exe deleted file mode 100644 index 6def44e..0000000 Binary files a/MissionGenerator.exe and /dev/null differ