From 2bb10d00917a4523aca0191629051b5328dfa567 Mon Sep 17 00:00:00 2001 From: Ning Shang Date: Tue, 21 May 2024 10:57:43 -0700 Subject: [PATCH] Add release_name support in action.yml (#16) * Add `release_name` support in `action.yml` Support optional `release_name`. * Add a comment about testing empty release_name To indicate that we test the default behavior/value. --- .github/workflows/test.yml | 6 ++++++ action.yml | 3 +++ entrypoint.sh | 25 +++++++++++++++++++++---- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 561df9b..c0cd4be 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,6 +28,7 @@ jobs: - name: 'Test OTA Release' uses: './' # Use an action in the root directory with: + # Not setting release_name to test the default behavior release_type: 'file' persist_dir: '/tmp/persist' artifacts_dir: 'artifacts' @@ -44,6 +45,10 @@ jobs: steps: - name: 'Checkout' uses: 'actions/checkout@v4' + + - name: 'Set up environment' + run: | + echo "TIMESTAMP=$(date +'%Y-%m-%dT%H:%M:%S%z')" >> $GITHUB_ENV - name: 'Create artifacts for test' run: | @@ -57,6 +62,7 @@ jobs: - name: 'Test OTA Release' uses: './' # Use an action in the root directory with: + release_name: 'archive-release ${{ env.TIMESTAMP }}' release_type: 'zip_archive' persist_dir: '/tmp/persist' zip_archive_dir: 'artifacts' diff --git a/action.yml b/action.yml index f496820..7c61657 100644 --- a/action.yml +++ b/action.yml @@ -2,6 +2,9 @@ name: 'Create OTA Release' description: 'Creates OTA update releases' author: 'Ning Shang (Thistle Technologies)' inputs: + release_name: + description: 'Display name of the release. If not provided or empty, the unique manifest ID will be used' + required: false release_type: description: 'Release type ("file", "zip_archive", or "rootfs")' required: true diff --git a/entrypoint.sh b/entrypoint.sh index 2c4e411..e8ab020 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -8,6 +8,7 @@ # The following environment variables correspond to the input identifiers in # action.yml. # +# INPUT_RELEASE_NAME # INPUT_RELEASE_TYPE # INPUT_PERSIST_DIR # INPUT_ARTIFACTS_DIR @@ -56,14 +57,21 @@ get_manifest_template_hack() { file_release() { get_manifest_template_hack + local release_name="${INPUT_RELEASE_NAME:-}" + local artifacts_dir="${INPUT_ARTIFACTS_DIR:-}" - local base_install_path="${INPUT_BASE_INSTALL_PATH_ON_DEVICE:-}" [ -z "${artifacts_dir}" ] && err "No artifacts directory provided" + + local base_install_path="${INPUT_BASE_INSTALL_PATH_ON_DEVICE:-}" [ -z "${base_install_path}" ] && err "No base install path provided" "${TRH_BINARY_PATH}" prepare --target="${artifacts_dir}" --file-base-path="${base_install_path}" - "${TRH_BINARY_PATH}" release + if [ -n "${release_name}" ]; then + "${TRH_BINARY_PATH}" release --name="${release_name}" + else + "${TRH_BINARY_PATH}" release + fi echo "done" } @@ -76,14 +84,23 @@ rootfs_release() { zip_archive_release() { get_manifest_template_hack + local release_name="${INPUT_RELEASE_NAME:-}" + local zip_archive_dir="${INPUT_ZIP_ARCHIVE_DIR:-}" - local base_install_path="${INPUT_BASE_INSTALL_PATH_ON_DEVICE:-}" [ -z "${zip_archive_dir}" ] && err "No zip archive directory provided" + + local base_install_path="${INPUT_BASE_INSTALL_PATH_ON_DEVICE:-}" [ -z "${base_install_path}" ] && err "No base install path provided" "${TRH_BINARY_PATH}" prepare --zip-target --target="${zip_archive_dir}" --file-base-path="${base_install_path}" - "${TRH_BINARY_PATH}" release + if [ -n "${release_name}" ]; then + "${TRH_BINARY_PATH}" release --name="${release_name}" + else + "${TRH_BINARY_PATH}" release + fi + + echo "done" } do_it() {