From 7d66fa0695b126f0007e06dfaef41ab4ae4a3f3d Mon Sep 17 00:00:00 2001 From: Abdulqadir Ahmad Date: Fri, 29 Dec 2023 18:10:26 +0100 Subject: [PATCH 1/4] Created release.yml - action file for automated release on push. --- .github/workflows/release.yml | 45 +++++++++++++++++++++++++++++++++++ scripts/build.ps1 | 15 ++++++++++++ scripts/twblue.nsi | 3 ++- 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml create mode 100644 scripts/build.ps1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..d4542b3d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,45 @@ +# Release a new TW Blue installer on github. +# This workflow runs on push. +name: Release +on: [push, workflow_dispatch] +jobs: + build: + # Builds an x64 binary and an installer of TW Blue. + runs-on: windows-2019 + steps: + - name: clone repo + uses: actions/checkout@v4 + with: + submodules: true + - name: Get python interpreter + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install python packages + run: python -m pip install -r requirements.txt + + - name: Get nsis + run: | + iwr -useb get.scoop.sh -outfile 'install.ps1' + .\install.ps1 -RunAsAdmin + scoop update + scoop bucket add extras + scoop install nsis + + - name: Build binary + run: | + .\scripts\build.ps1 + mv src/dist scripts\TWBlue64 + + - name: make installer + run: | + cd src + python write_version_data.py + cd ../scripts + makensis twblue.nsi + + - name: Create new release + env: + gh_token: ${{ github.token }} + run: gh release create snapshot -n "This release is a snapshot of the current development version of twblue." -p -t "Snapshot" scripts\TWBlue_setup.exe diff --git a/scripts/build.ps1 b/scripts/build.ps1 new file mode 100644 index 00000000..0f92d849 --- /dev/null +++ b/scripts/build.ps1 @@ -0,0 +1,15 @@ +# Build a TW Blue installer. +# Must be called from root of repo +echo "Generating documentation..." +cd doc +python documentation_importer.py +python generator.py +mv documentation ..\src +cd .. +echo "done." + +echo "Building binary..." +cd src +python setup.py build +cd .. +echo "done." diff --git a/scripts/twblue.nsi b/scripts/twblue.nsi index f0a37095..4ad0cfd2 100644 --- a/scripts/twblue.nsi +++ b/scripts/twblue.nsi @@ -58,7 +58,8 @@ SetOutPath "$INSTDIR" ${If} ${RunningX64} File /r TWBlue64\* ${Else} -File /r TWBlue\* +messagebox MB_ICONSTOP "Error: This TWBlue installer is only compatible with 64-bit systems. TWBlue does not support 32 bit systems any more." +Quit ${EndIf} CreateShortCut "$DESKTOP\TWBlue.lnk" "$INSTDIR\TWBlue.exe" !insertmacro MUI_STARTMENU_WRITE_BEGIN startmenu From 8d93c170e2e5259da3dc89f2e5028011cbbf594c Mon Sep 17 00:00:00 2001 From: Abdulqadir Ahmad Date: Fri, 29 Dec 2023 19:01:14 +0100 Subject: [PATCH 2/4] changed release.yml to run on pushes on next-gen branch --- .github/workflows/release.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d4542b3d..b39e3da8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,10 @@ # Release a new TW Blue installer on github. # This workflow runs on push. name: Release -on: [push, workflow_dispatch] +on: + push: + branches: + - next-gen jobs: build: # Builds an x64 binary and an installer of TW Blue. From 275f5e763bd25324a691b07af4b9a3ee1deed258 Mon Sep 17 00:00:00 2001 From: Abdulqadir Ahmad Date: Sat, 30 Dec 2023 16:40:19 +0100 Subject: [PATCH 3/4] changed release workflow from releasing snapshot versions to "stable" versions. More info at https://github.com/MCV-Software/TWBlue/pull/567 --- .github/workflows/release.yml | 25 ++++++++++--------------- .gitignore | 3 ++- scripts/build.ps1 | 1 + src/write_version_data.py | 11 +++++++++-- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b39e3da8..353b24eb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,12 +3,13 @@ name: Release on: push: - branches: - - next-gen + tags: ["release"] + workflow_dispatch: + jobs: build: # Builds an x64 binary and an installer of TW Blue. - runs-on: windows-2019 + runs-on: windows-latest steps: - name: clone repo uses: actions/checkout@v4 @@ -22,14 +23,6 @@ jobs: - name: Install python packages run: python -m pip install -r requirements.txt - - name: Get nsis - run: | - iwr -useb get.scoop.sh -outfile 'install.ps1' - .\install.ps1 -RunAsAdmin - scoop update - scoop bucket add extras - scoop install nsis - - name: Build binary run: | .\scripts\build.ps1 @@ -37,12 +30,14 @@ jobs: - name: make installer run: | - cd src - python write_version_data.py - cd ../scripts + cd scripts makensis twblue.nsi - name: Create new release env: gh_token: ${{ github.token }} - run: gh release create snapshot -n "This release is a snapshot of the current development version of twblue." -p -t "Snapshot" scripts\TWBlue_setup.exe + run: | + mkdir .release-assets + mv scripts\TWBlue_setup.exe .release-assets\TWBlue_setup_$(cat version.txt).exe + 7z a -tzip .release-assets\TWBlue_portable_$(cat version.txt).zip scripts\TWBlue64 + gh release create release -p -t "Version $(cat version.txt)" .release-assets\TWBlue_setup_$(cat version.txt).exe .release-assets\TWBlue_portable_$(cat version.txt).zip diff --git a/.gitignore b/.gitignore index b28d20b6..d769453c 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,5 @@ release-snapshot/ src/com_cache/ doc/strings.py doc/changelog.py -env/ \ No newline at end of file +env/ +version.txt diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 0f92d849..0c37577a 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -10,6 +10,7 @@ echo "done." echo "Building binary..." cd src +python write_version_data.py python setup.py build cd .. echo "done." diff --git a/src/write_version_data.py b/src/write_version_data.py index 2136c3a0..7d097372 100644 --- a/src/write_version_data.py +++ b/src/write_version_data.py @@ -10,9 +10,10 @@ commit_info = requests.get("https://gitlab.com/api/v4/projects/23482196/reposito commit_info = commit_info.json() commit = commit_info["short_id"] print("Got new version info: {commit}".format(commit=commit,)) +new_version = commit_info["created_at"][:10].replace("-", ".") file = open("application.py", "r", encoding="utf-8") lines = file.readlines() -lines[-1] = 'version = "{}"'.format(commit_info["created_at"][:10].replace("-", ".")) +lines[-1] = 'version = "{}"'.format(new_version) file.close() file2 = open("application.py", "w", encoding="utf-8") file2.writelines(lines) @@ -22,9 +23,15 @@ print("Wrote application.py with the new version info.") print("Updating next version on installer setup...") file = open("..\\scripts\\twblue.nsi", "r", encoding="utf-8") contents = file.read() -contents = contents.replace("0.95", commit_info["created_at"][:10].replace("-", ".")) +contents = contents.replace("0.95", new_version) file.close() file2 = open("..\\scripts\\twblue.nsi", "w", encoding="utf-8") file2.write(contents) file2.close() print("done") + +print("Writing new version to version.txt") +version_txt = open("../version.txt", "w", encoding="utf8") +version_txt.write(new_version) +version_txt.close() +print("Done.") From 6e91c6419cf6b91c65a18947f35174aea2ce785f Mon Sep 17 00:00:00 2001 From: Abdulqadir Ahmad Date: Sat, 30 Dec 2023 16:52:09 +0100 Subject: [PATCH 4/4] changed the command that creates a new release in the release workflow to create a general note and dropped the -p (pre release) flag. --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 353b24eb..2d023b7f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,4 +40,4 @@ jobs: mkdir .release-assets mv scripts\TWBlue_setup.exe .release-assets\TWBlue_setup_$(cat version.txt).exe 7z a -tzip .release-assets\TWBlue_portable_$(cat version.txt).zip scripts\TWBlue64 - gh release create release -p -t "Version $(cat version.txt)" .release-assets\TWBlue_setup_$(cat version.txt).exe .release-assets\TWBlue_portable_$(cat version.txt).zip + gh release create release -n "New version of TWBlue." -t "Version $(cat version.txt)" .release-assets\TWBlue_setup_$(cat version.txt).exe .release-assets\TWBlue_portable_$(cat version.txt).zip