diff --git a/.github/assets/get-version.py b/.github/assets/get-version.py new file mode 100644 index 0000000..9b1a734 --- /dev/null +++ b/.github/assets/get-version.py @@ -0,0 +1,21 @@ +import xml.etree.ElementTree as ET +import os +import sys + +if len(sys.argv) < 2: + print("Usage: python your_script.py path/to/your/file.xml") + sys.exit(1) + +xml_file = sys.argv[1] + +print(f"XML file name: {xml_file}") + +tree = ET.parse(xml_file) +root = tree.getroot() + +version = root.attrib.get('version') + +print(f"Version found: {version}") + +with open(os.getenv('GITHUB_OUTPUT'), 'a') as github_output: + github_output.write(f'version={version}\n') diff --git a/.github/workflows/build-new-release.yaml b/.github/workflows/build.yml similarity index 65% rename from .github/workflows/build-new-release.yaml rename to .github/workflows/build.yml index aa865e1..2194c87 100644 --- a/.github/workflows/build-new-release.yaml +++ b/.github/workflows/build.yml @@ -1,9 +1,11 @@ -name: Build TizenBrew Standalone Application and Release +name: Build TizenBrew on: push: - tags: - - 'v*.*.*' + branches: + - '**' + workflow_dispatch: + env: TIZEN_STUDIO_VER: 5.6 @@ -13,49 +15,77 @@ jobs: runs-on: ubuntu-latest steps: - name: Clone repo - uses: actions/checkout@v3 - - - name: Set env - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + uses: actions/checkout@v4 - - name: Install modules and transpile service - working-directory: tizenbrew-app/TizenBrew/service + - name: Set env and variables + id: variables + run: | + echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + echo "hash=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_OUTPUT + + - name: Install additional packages and npm modules run: | sudo apt install -y expect zip coreutils sudo curl -Lo /usr/bin/ldid https://github.com/ProcursusTeam/ldid/releases/download/v2.1.5-procursus7/ldid_linux_x86_64 sudo chmod a+rwx /usr/bin/ldid - npm install npm install -g @vercel/ncc wgt-to-usb pkg + + - name: Install modules for standalone service + working-directory: tizenbrew-app/TizenBrew/service + run: | + npm install + + - name: Install modules for updater service + working-directory: tizenbrew-updater/TizenBrewUpdater/service + run: | + npm install + + - name: Build transpiled service + working-directory: tizenbrew-app/TizenBrew/service + run: | npx babel . --out-dir transpiled --copy-files rm -r node_modules - - - name: Build service + + - name: Build standalone service working-directory: tizenbrew-app/TizenBrew/service/transpiled run: | ncc build service.js -o ../dist rm -r node_modules - + - name: Clean up transpiled files working-directory: tizenbrew-app/TizenBrew/service run: | rm -r transpiled - - - name: Install modules and build updater service + + - name: Build updater service working-directory: tizenbrew-updater/TizenBrewUpdater/service run: | - npm install ncc build service.js rm -r node_modules - - name: Download Tizen-Studio + - name: Cache Tizen Studio + id: cache-tizen-studio + uses: actions/cache@v4 + with: + path: | + tizen-studio + tizen-studio-data/profile + key: tizen-studio-v${{ env.TIZEN_STUDIO_VER }}-cache + + - name: Download Tizen Studio + if: steps.cache-tizen-studio.outputs.cache-hit != 'true' run: | curl -o tizen-installer "https://download.tizen.org/sdk/Installer/tizen-studio_${TIZEN_STUDIO_VER}/web-cli_Tizen_Studio_${TIZEN_STUDIO_VER}_ubuntu-64.bin" - - name: Install Tizen-Studio + - name: Install Tizen Studio + if: steps.cache-tizen-studio.outputs.cache-hit != 'true' run: | chmod +x tizen-installer ./tizen-installer --accept-license "${GITHUB_WORKSPACE}/tizen-studio" rm ./tizen-installer + + - name: Configure Tizen Studio + run: | echo 'export PATH=$PATH:${GITHUB_WORKSPACE}/tizen-studio/tools/ide/bin' >> .bashrc - name: Prepare Tizen Certificate @@ -131,25 +161,25 @@ jobs: pkg -C GZip . --no-bytecode --public - name: Upload TizenBrew package artifact for Old Tizen - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: app-${{ github.sha }}-old.wgt path: tizenbrew-app/TizenBrew/release/TizenBrewStandalone-Old.wgt - name: Upload TizenBrew package artifact for New Tizen - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: app-${{ github.sha }}-new.wgt path: tizenbrew-app/TizenBrew/release/TizenBrewStandalone-New.wgt - name: Upload TizenBrew Updater package artifact for Old Tizen - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: updater-${{ github.sha }}-old.wgt path: tizenbrew-updater/TizenBrewUpdater/release/TizenBrewUpdater-Old.wgt - name: Upload TizenBrew Updater package artifact for New Tizen - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: updater-${{ github.sha }}-new.wgt path: tizenbrew-updater/TizenBrewUpdater/release/TizenBrewUpdater-New.wgt @@ -164,11 +194,48 @@ jobs: run: | zip -r release/TizenBrewUpdaterUSBDemo.zip userwidget/ - - name: Release TizenBrew Build Results - uses: softprops/action-gh-release@v1 + - name: Rename Build Files + if: github.ref == 'refs/heads/improve-actions' + # ^^^^ TODO: put github.ref == 'refs/heads/main' above this line + run: | + DIRS=( + "tizenbrew-app/TizenBrew/release" + "tizenbrew-updater/TizenBrewUpdater/release" + "tizenbrew-updater/TizenBrewUpdater/dist" + ) + OUTDIR="all-build-files" + mkdir $OUTDIR + + for DIR in "${DIRS[@]}"; do + for FILE in "$DIR"/*; do + cp "$FILE" "$OUTDIR" + done + done + + for FILE in "$OUTDIR"/*; do + if [ -f "$FILE" ]; then + FILENAME=$(basename "$FILE") + BASENAME="${FILENAME%.*}" + if [[ "$FILE" == *".exe"* || "$FILE" == *".wgt"* || "$FILE" == *".zip"* || "$FILE" == *".tpk"* ]]; then + EXTENSION="${FILENAME##*.}" + NEWNAME="$OUTDIR/${BASENAME}-${{ steps.variables.outputs.hash }}.$EXTENSION" + else + NEWNAME="$OUTDIR/${BASENAME}-${{ steps.variables.outputs.hash }}" + fi + mv "$FILE" "$NEWNAME" + fi + done + + - name: Update Nightly Build + if: github.ref == 'refs/heads/improve-actions' + # ^^^^ TODO: put github.ref == 'refs/heads/main' above this line + uses: andelf/nightly-release@main + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag_name: ${{ env.RELEASE_VERSION }} + tag_name: nightly + name: 'TizenBrew Development Release' + body: | + Nightly TizenBrew build for commit ${{ github.sha }}. Recommended to not use the nightly build versions as these can be very unstable. Please use the latest release instead. files: | - tizenbrew-app/TizenBrew/release/* - tizenbrew-updater/TizenBrewUpdater/release/* - tizenbrew-updater/TizenBrewUpdater/dist/* \ No newline at end of file + all-build-files/* diff --git a/.github/workflows/draft.yml b/.github/workflows/draft.yml new file mode 100644 index 0000000..ef3afc9 --- /dev/null +++ b/.github/workflows/draft.yml @@ -0,0 +1,89 @@ +name: Draft Release + +on: + workflow_dispatch: + + +jobs: + draft: + name: Draft Release + runs-on: ubuntu-latest + steps: + - name: Download Development Release + uses: robinraju/release-downloader@v1.11 + with: + out-file-path: 'nightly' + fileName: '*' + tag: 'nightly' + tarBall: false + zipBall: true + + - name: Get Version + id: ver + shell: bash + run: | + # VERSION=$(unzip -p ${{ github.workspace }}/nightly/TizenBrew-nightly.zip ${{ github.repository_owner }}-TizenBrew-*/VERSION | xargs) + echo $(unzip -p ${{ github.workspace }}/nightly/TizenBrew-nightly.zip ${{ github.repository_owner }}-TizenBrew-*/tizenbrew-app/TizenBrew/config.xml) > config.xml + curl -o get-version.py https://raw.githubusercontent.com/${{ github.repository }}/${{ github.ref_name }}/.github/assets/get-version.py + python get-version.py config.xml + + - name: Check Version + shell: bash + run: | + set +e + curl --fail "https://api.github.com/repos/${{ github.repository }}/releases/tags/v${{ steps.ver.outputs.version }}" --silent --output /dev/null + RESULT=$? + set -e + + if [ $RESULT -eq 0 ]; then + echo "Release ${{ steps.ver.outputs.version }} exists, not touching it." + exit 1 + fi + + - name: Get Latest Commit + id: latest-commit + run: | + mkdir temp-TizenBrew + cd temp-TizenBrew + git init + git remote add origin https://github.com/${{ github.repository }}.git + git fetch --tags + latest_commit=$(git rev-list -n 1 nightly) + short=$(git rev-parse --short "$latest_commit") + echo "Latest commit SHA is: $short" + echo "Full SHA: $latest_commit" + echo "commit=$latest_commit" >> $GITHUB_OUTPUT + echo "reg=$latest_commit" >> $GITHUB_OUTPUT + echo "long=$latest_commit" >> $GITHUB_OUTPUT + echo "short=$short" >> $GITHUB_OUTPUT + cd ../ + rm -rf temp-TizenBrew + + - name: Rename Files + run: | + for FILE in "nightly"/*; do + if [[ -f "$FILE" && "$FILE" == *"${{ steps.latest-commit.outputs.short }}"* ]]; then + FILEDIR=$(dirname "$FILE") + FILENAME=$(basename "$FILE") + NEWNAME="${FILENAME//${{ steps.latest-commit.outputs.short }}/v${{ steps.ver.outputs.version }}}" + mv "$FILE" "$FILEDIR/$NEWNAME" + else + if [ -f "$FILE" ]; then + rm $FILE + fi + fi + done + + - name: Create Draft Release + uses: softprops/action-gh-release@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: v${{ steps.ver.outputs.version }} + name: TizenBrew v${{ steps.ver.outputs.version }} + draft: true + body: | + This release includes + - some changes! + files: | + nightly/* \ No newline at end of file