From 741e0f5978f685c687706dfa293ce545cf71d98c Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 1 Mar 2023 16:11:12 -0500 Subject: [PATCH] add release workflow (#21) Signed-off-by: Tiger Wang --- .github/workflows/release.yml | 35 +++++++++++++++++++ .../setup/script.d/99-setup-appstore.sh | 30 ++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 build/scripts/setup/script.d/99-setup-appstore.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..f6f3e0407 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,35 @@ +name: release + +on: + push: + tags: + - v*.*.* + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: remove all screenshots + run: find . -name "screenshot*" | xargs rm -f + - name: remove all thumbnails + run: find . -name "thumbnail*" | xargs rm -f + - name: create a build with sysroot + id: build + run: | + rm -rf /tmp/build + mkdir -p /tmp/build/sysroot/var/lib/casaos/appstore/default.new + cp -rv build/* /tmp/build/ + cp -rv Apps /tmp/build/sysroot/var/lib/casaos/appstore/default.new/ + cp -v category-list.json /tmp/build/sysroot/var/lib/casaos/appstore/default.new/ + cp -v recommend-list.json /tmp/build/sysroot/var/lib/casaos/appstore/default.new/ + cp -v README.md /tmp/build/sysroot/var/lib/casaos/appstore/default.new/ + pushd /tmp + tar zcvf linux-all-appstore-${{ github.ref_name }}.tar.gz build + - uses: softprops/action-gh-release@v1 + if: steps.build.outcome == 'success' + with: + files: /tmp/linux-all-appstore-${{ github.ref_name }}.tar.gz + draft: true + prerelease: true + fail_on_unmatched_files: true diff --git a/build/scripts/setup/script.d/99-setup-appstore.sh b/build/scripts/setup/script.d/99-setup-appstore.sh new file mode 100644 index 000000000..b82aad631 --- /dev/null +++ b/build/scripts/setup/script.d/99-setup-appstore.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +set -e + +DEFAULT_APPSTORE_PATH="/var/lib/casaos/appstore/default" + +if [ -d "${DEFAULT_APPSTORE_PATH}" ]; then + echo "🟩 Backup existing default appstore..." + mv -f "${DEFAULT_APPSTORE_PATH}" "${DEFAULT_APPSTORE_PATH}.old" || { + echo "🟥 Failed to backup existing default appstore" + exit 1 + } +fi + +echo "🟩 Updating default appstore..." + +if [ -d "${DEFAULT_APPSTORE_PATH}.new" ]; then + mv -vf "${DEFAULT_APPSTORE_PATH}.new" "${DEFAULT_APPSTORE_PATH}" || { + echo "🟥 Failed to update default appstore... restoring backup..." + rm -vf "${DEFAULT_APPSTORE_PATH}" + mv -vf "${DEFAULT_APPSTORE_PATH}.old" "${DEFAULT_APPSTORE_PATH}" + rm -rvf "${DEFAULT_APPSTORE_PATH}.new" + exit 1 + } + rm -rvf "${DEFAULT_APPSTORE_PATH}.old" || { + echo "🟨 Failed to remove old default appstore backup" + } +else + echo "🟨 New default appstore does not exist" +fi \ No newline at end of file