From 19f997c4f805e145e2d6ae536dc3a95c6fa894ef Mon Sep 17 00:00:00 2001 From: Nathan Courtney Date: Wed, 22 May 2024 17:33:42 -0400 Subject: [PATCH] testing old packaging format --- .github/workflows/build.yaml | 68 +++++++++++++++------------- .github/workflows/staging.yaml | 1 + .gitignore | 4 +- .python-version | 2 +- package.py | 83 ++++++++++++++++++++++++++++++++++ 5 files changed, 125 insertions(+), 33 deletions(-) create mode 100644 package.py diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 0415cf2..a4316f9 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -17,7 +17,7 @@ on: jobs: build: - runs-on: macos-latest + runs-on: ubuntu-latest steps: ### Checking out our Repo - uses: actions/checkout@v3 @@ -35,46 +35,52 @@ jobs: run: echo "VERSION=$(echo $GITHUB_REF | cut -d / -f 3)" >> $GITHUB_OUTPUT ### Generating our staging version number if we are not production - - name: Get staging version - shell: bash - id: staging_version - run: echo "STAGING_VERSION=$(/bin/bash staging_versioning.sh)" >> $GITHUB_OUTPUT - if: inputs.deploy == false +# - name: Get staging version +# shell: bash +# id: staging_version +# run: echo "STAGING_VERSION=$(/bin/bash staging_versioning.sh)" >> $GITHUB_OUTPUT +# if: inputs.deploy == false ### Setting the version in the pyproject.toml for unix builds - - name: Set Version Shell Script - run: | - if [[ ${{ steps.get_version.outputs.VERSION }} =~ [0-9]+.[0-9]+.[0-9]+$ ]] - then - echo "This is a tagged build" - export RELEASE_VERSION='${{ steps.get_version.outputs.VERSION }}' - RELEASE_VERSION="${RELEASE_VERSION#v}" - echo $RELEASE_VERSION - sed -i 's/__version__ = .*/__version__ = "${RELEASE_VERSION}"/' _version.py - else - echo "This is not a tagged build" - export STAGING_VERSION='${{ steps.staging_version.outputs.STAGING_VERSION }}' - sed -i 's/__version__ = .*/__version__ = "${STAGING_VERSION}"/' _version.py - fi +# - name: Set Version Shell Script + # run: | + # if [[ ${{ steps.get_version.outputs.VERSION }} =~ [0-9]+.[0-9]+.[0-9]+$ ]] + # then + # echo "This is a tagged build" + # export RELEASE_VERSION='${{ steps.get_version.outputs.VERSION }}' + # RELEASE_VERSION="${RELEASE_VERSION#v}" + # echo $RELEASE_VERSION + # sed -i 's/__version__ = .*/__version__ = "${RELEASE_VERSION}"/' _version.py + # else + # echo "This is not a tagged build" + # export STAGING_VERSION='${{ steps.staging_version.outputs.STAGING_VERSION }}' + # sed -i 's/__version__ = .*/__version__ = "${STAGING_VERSION}"/' _version.py + # fi ### Uploading our staging version text file to be pulled down later - - uses: actions/upload-artifact@v3 - with: - name: staging_version - path: "*.txt" - if: inputs.deploy == false - - # Zip repository contents into Pieces.sublime-package - - name: Zip Repository +# - uses: actions/upload-artifact@v3 +# with: +# name: staging_version +# path: "*.txt" +# if: inputs.deploy == false + + # Compress repository contents into Pieces.sublime-package + - name: Compress Repository run: | - zip -r Pieces.sublime-package . + sudo rsync -av --iconv=utf-8 --progress ./* ./Pieces --exclude .gitignore --exclude .github --exclude .git --exclude artifacts + sudo cp ./.python-version Pieces/.python-version + sudo iconv -t utf-8 Pieces/.python-version + sudo python3 package.py Packing + + - name: List what is in here + run: ls -la ### Pushing the built packages to GCP and GitHub push-build: runs-on: ubuntu-latest needs: - - build + - not_now steps: ### Pulling down the previously built plugins @@ -167,7 +173,7 @@ jobs: uses: softprops/action-gh-release@v1 if: inputs.deploy == true with: - files: Pieces.sublime-package + files: Pieces.sublime-package fail_on_unmatched_files: true name: ${{ env.releasetag }} tag_name: ${{ env.releasetag }} diff --git a/.github/workflows/staging.yaml b/.github/workflows/staging.yaml index fea6e91..86ae650 100644 --- a/.github/workflows/staging.yaml +++ b/.github/workflows/staging.yaml @@ -4,6 +4,7 @@ on: push: branches: - main + - testing_ci jobs: build: diff --git a/.gitignore b/.gitignore index 68bc17f..f3ed42b 100644 --- a/.gitignore +++ b/.gitignore @@ -157,4 +157,6 @@ cython_debug/ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ +.idea/ +Pieces/ +Pieces.sublime-package diff --git a/.python-version b/.python-version index 98fccd6..512d523 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -3.8 \ No newline at end of file +3.12.1 \ No newline at end of file diff --git a/package.py b/package.py new file mode 100644 index 0000000..9f792f1 --- /dev/null +++ b/package.py @@ -0,0 +1,83 @@ +print("This script copyright nathan@pieces.app") + +import sys +import os +import re +import zipfile +import compileall +from fnmatch import fnmatch + +n = str(sys.argv[1]) +print(n) + +# The Package Name +package_name = "Pieces" + +# Stores Pieces.sublime-package in dir higher +package_destination = "../" + +# None ~ Uses Default Settings +profile=None + +# Referencing entire repo (where script lives) +package_dir = "." + +# Extension +package_filename = package_name + '.sublime-package' + +# Where the compiled package will live +package_path = os.path.join(package_destination, package_filename) + +if os.path.exists(package_path): + os.remove(package_path) + +# Real Important Zip compression logic +package_file = zipfile.ZipFile(package_path, "w", compression=zipfile.ZIP_DEFLATED) + +# This must be done exactly like this +# Refer to https://github.com/wbond/package_control/blob/cfaaeb57612023e3679ecb7f8cd7ceac9f57990d/package_control/package_manager.py#L886 +# (Hopefully the above file still exists) +compileall.compile_dir(package_dir, quiet=True, legacy=True, optimize=2) + +#Keeping these blank, can probs remove but will have to spend time figureing out if it will break code below +dirs_to_ignore = [] +files_to_ignore = [] +files_to_include = [] + +slash = '\\' if os.name == 'nt' else '/' +trailing_package_dir = package_dir + slash if package_dir[-1] != slash else package_dir +package_dir_regex = re.compile('^' + re.escape(trailing_package_dir)) +for root, dirs, files in os.walk(package_dir): + # add "dir" to "paths" list if "dir" is not in "dirs_to_ignore" + dirs[:] = [x for x in dirs if x not in dirs_to_ignore] + paths = dirs + paths.extend(files) + for path in paths: + full_path = os.path.join(root, path) + relative_path = re.sub(package_dir_regex, '', full_path) + + ignore_matches = [fnmatch(relative_path, p) for p in files_to_ignore] + + include_matches = [fnmatch(relative_path, p) for p in files_to_include] + + # This is probably done when Package Control rips settings from sublime.py (which references sublime_api.py which is closed sources) + if ".pyc" in relative_path: + continue + + # Don't include this script in the package + if "package.py" in relative_path: + continue + + #Probably Does what is mentioned above + if any(ignore_matches) and not any(include_matches): + continue + + # Ditto + if os.path.isdir(full_path): + continue + + # Yee'ol write + package_file.write(full_path, relative_path) + +# We done here +package_file.close()