Skip to content

Commit

Permalink
Add release_name support in action.yml (#16)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
syncom authored May 21, 2024
1 parent 8495559 commit 2bb10d0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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: |
Expand All @@ -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'
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 21 additions & 4 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
}
Expand All @@ -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() {
Expand Down

0 comments on commit 2bb10d0

Please sign in to comment.