From f27616be1ae5522e0df9b57fb335cbba172f6762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B6rrle?= Date: Sun, 7 Jan 2024 22:03:26 +0100 Subject: [PATCH] Update release workflow --- .github/scripts/update_manifest.py | 39 --------------------- .github/workflows/release.yml | 54 +++++++++++++++++++----------- 2 files changed, 34 insertions(+), 59 deletions(-) delete mode 100644 .github/scripts/update_manifest.py diff --git a/.github/scripts/update_manifest.py b/.github/scripts/update_manifest.py deleted file mode 100644 index ac0b0ab..0000000 --- a/.github/scripts/update_manifest.py +++ /dev/null @@ -1,39 +0,0 @@ -"""Update the manifest file.""" - -# pylint: skip-file - -import json -import os -import sys - - -def update_manifest(): - """Update the manifest file.""" - version = "0" - for index, value in enumerate(sys.argv): - if value in ["--version", "-V"]: - version = sys.argv[index + 1] - - version_striped = version.replace("v", "") - - print(f"Version number being inserted: {version_striped!s}") - - print("Opening file...") - - with open(f"{os.getcwd()}/custom_components/qss/manifest.json") as manifestfile: - manifest = json.load(manifestfile) - - manifest["version"] = version_striped - - print("Manifest file after inserting new version number:") - print(manifest) - - print("Saving file...") - - with open(f"{os.getcwd()}/custom_components/qss/manifest.json", "w") as manifestfile: - manifestfile.write(json.dumps(manifest, indent=4, sort_keys=True)) - - print("Done!") - - -update_manifest() diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 89604c0..1aa99e1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,32 +2,46 @@ name: Release on: release: - types: [published] + types: + - published jobs: - release_zip_file: - name: Prepare release asset + release: + name: Release runs-on: ubuntu-latest + permissions: + contents: write + id-token: write steps: - - name: Check out repository - uses: actions/checkout@v4 - - - name: Get version - id: version - uses: home-assistant/actions/helpers/version@master + - name: ⤵️ Check out code from GitHub + uses: actions/checkout@v4.1.1 - - name: Set version number + - name: 🔢 Adjust version number + shell: bash run: | - python3 ${{ github.workspace }}/.github/scripts/update_manifest.py --version ${{ steps.version.outputs.version }} - - name: Create zip + version="${{ github.event.release.tag_name }}" + version="${version,,}" + version="${version#v}" + yq e -P -o=json \ + -i ".version = \"${version}\"" \ + "${{ github.workspace }}/custom_components/qss/manifest.json" + + - name: 📦 Created zipped release package + shell: bash run: | - cd custom_components/qss + cd "${{ github.workspace }}/custom_components/qss" zip qss.zip -r ./ - - name: Upload zip to release - uses: svenstaro/upload-release-action@2.7.0 + + - name: 🔏 Sign release package + uses: sigstore/gh-action-sigstore-python@v2.1.1 with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: ./custom_components/qss/qss.zip - asset_name: qss.zip - tag: ${{ github.ref }} - overwrite: true + inputs: ${{ github.workspace }}/custom_components/qss/qss.zip + + - name: ⬆️ Upload zip to release + uses: softprops/action-gh-release@v0.1.15 + with: + files: ${{ github.workspace }}/custom_components/qss/qss.zip + + # Upload this one in the future, currently problematic for HACS + # https://github.com/frenck/spook/issues/286 + # ${{ github.workspace }}/custom_components/spook/spook.zip.sigstore