From b2a191b15036a1ac1c1c75b334d0b8a267c346dc Mon Sep 17 00:00:00 2001 From: seiya-git Date: Wed, 29 Nov 2023 11:01:49 +0300 Subject: [PATCH] v1.1.8: fix VerifyTools --- .github/workflows/publish-to-pypi.yml | 97 ++++++++++++++++++++++ .github/workflows/publish-to-test-pypi.yml | 70 +--------------- build/setup.py | 2 +- py/nstools/lib/VerifyTools.py | 9 +- 4 files changed, 103 insertions(+), 75 deletions(-) create mode 100644 .github/workflows/publish-to-pypi.yml diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml new file mode 100644 index 0000000..e737dbb --- /dev/null +++ b/.github/workflows/publish-to-pypi.yml @@ -0,0 +1,97 @@ +name: Publish Python 🐍 distribution 📦 to PyPI + +on: push + +jobs: + build: + name: Build distribution 📦 + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + - name: Install pypa/build + run: | + python3 -m pip install build --user + - name: Build a binary wheel and a source tarball + run: | + cp -r ./py/* ./build + cp LICENSE.md ./build + cp README.md ./build + python3 -m build build + - name: Store the distribution packages + uses: actions/upload-artifact@v3 + with: + name: python-package-distributions + path: build/dist/ + + publish-to-pypi: + name: >- + Publish Python 🐍 distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + needs: + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/nstools # Replace with your PyPI project name + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - name: Download all the dists + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: build/dist/ + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.TOKEN }} + packages-dir: build/dist + + github-release: + name: >- + Sign the Python 🐍 distribution 📦 with Sigstore + and upload them to GitHub Release + needs: + - publish-to-pypi + runs-on: ubuntu-latest + + permissions: + contents: write # IMPORTANT: mandatory for making GitHub Releases + id-token: write # IMPORTANT: mandatory for sigstore + + steps: + - name: Download all the dists + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: build/dist/ + - name: Sign the dists with Sigstore + uses: sigstore/gh-action-sigstore-python@v1.2.3 + with: + inputs: >- + ./build/dist/*.tar.gz + ./build/dist/*.whl + - name: Create GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + run: >- + gh release create + '${{ github.ref_name }}' + --repo '${{ github.repository }}' + --notes "" + - name: Upload artifact signatures to GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + # Upload to GitHub Release using the `gh` CLI. + # `dist/` contains the built packages, and the + # sigstore-produced signatures and certificates. + run: >- + gh release upload + '${{ github.ref_name }}' build/dist/** + --repo '${{ github.repository }}' diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml index f2804ce..046eb68 100644 --- a/.github/workflows/publish-to-test-pypi.yml +++ b/.github/workflows/publish-to-test-pypi.yml @@ -1,4 +1,4 @@ -name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI +name: Publish Python 🐍 distribution 📦 to TestPyPI on: push @@ -28,74 +28,6 @@ jobs: name: python-package-distributions path: build/dist/ - publish-to-pypi: - name: >- - Publish Python 🐍 distribution 📦 to PyPI - if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes - needs: - - build - runs-on: ubuntu-latest - environment: - name: pypi - url: https://pypi.org/p/nstools # Replace with your PyPI project name - permissions: - id-token: write # IMPORTANT: mandatory for trusted publishing - - steps: - - name: Download all the dists - uses: actions/download-artifact@v3 - with: - name: python-package-distributions - path: build/dist/ - - name: Publish distribution 📦 to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.TOKEN }} - packages-dir: build/dist - - github-release: - name: >- - Sign the Python 🐍 distribution 📦 with Sigstore - and upload them to GitHub Release - needs: - - publish-to-pypi - runs-on: ubuntu-latest - - permissions: - contents: write # IMPORTANT: mandatory for making GitHub Releases - id-token: write # IMPORTANT: mandatory for sigstore - - steps: - - name: Download all the dists - uses: actions/download-artifact@v3 - with: - name: python-package-distributions - path: build/dist/ - - name: Sign the dists with Sigstore - uses: sigstore/gh-action-sigstore-python@v1.2.3 - with: - inputs: >- - ./build/dist/*.tar.gz - ./build/dist/*.whl - - name: Create GitHub Release - env: - GITHUB_TOKEN: ${{ github.token }} - run: >- - gh release create - '${{ github.ref_name }}' - --repo '${{ github.repository }}' - --notes "" - - name: Upload artifact signatures to GitHub Release - env: - GITHUB_TOKEN: ${{ github.token }} - # Upload to GitHub Release using the `gh` CLI. - # `dist/` contains the built packages, and the - # sigstore-produced signatures and certificates. - run: >- - gh release upload - '${{ github.ref_name }}' build/dist/** - --repo '${{ github.repository }}' - publish-to-testpypi: name: Publish Python 🐍 distribution 📦 to TestPyPI needs: diff --git a/build/setup.py b/build/setup.py index 226e41c..9559fd5 100644 --- a/build/setup.py +++ b/build/setup.py @@ -16,7 +16,7 @@ setuptools.setup( name = 'nstools', - version = '1.1.7', + version = '1.1.8', url = 'https://github.com/seiya-dev/NSTools', long_description = long_description, long_description_content_type = 'text/markdown', diff --git a/py/nstools/lib/VerifyTools.py b/py/nstools/lib/VerifyTools.py index fbc7839..1944e5b 100644 --- a/py/nstools/lib/VerifyTools.py +++ b/py/nstools/lib/VerifyTools.py @@ -189,7 +189,7 @@ def verify_key(self, nca, ticket): f.seek(0) ncaHeader = Nca.NcaHeader() - ncaHeader.open(Fs.File.MemoryFile(f.read(0x400), Type.Crypto.XTS, uhx(Keys.get('header_key')))) + ncaHeader.open(File.MemoryFile(f.read(0x400), Type.Crypto.XTS, uhx(Keys.get('header_key')))) pfs0 = fs @@ -218,7 +218,7 @@ def verify_key(self, nca, ticket): f.seek(0) ncaHeader = Nca.NcaHeader() - ncaHeader.open(Fs.File.MemoryFile(f.read(0x400), Type.Crypto.XTS, uhx(Keys.get('header_key')))) + ncaHeader.open(File.MemoryFile(f.read(0x400), Type.Crypto.XTS, uhx(Keys.get('header_key')))) ncaHeader = f.read(0x400) pfs0 = fs @@ -250,7 +250,7 @@ def verify_key(self, nca, ticket): f.seek(0) ncaHeader = Nca.NcaHeader() - ncaHeader.open(Fs.File.MemoryFile(f.read(0x400), Type.Crypto.XTS, uhx(Keys.get('header_key')))) + ncaHeader.open(File.MemoryFile(f.read(0x400), Type.Crypto.XTS, uhx(Keys.get('header_key')))) ncaHeader = f.read(0x400) pfs0 = fs @@ -375,6 +375,5 @@ def verify_nca_sig_simple(self): return verify_data def verify_nca_sig(self, verify_data): - # this just useless additional checks, don't bother for now... + # this is just useless additional checks, don't bother for now... return verify_data - \ No newline at end of file