ci: Improve actions #45
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build TizenBrew | ||
on: | ||
push: | ||
branches: | ||
- '**' | ||
workflow_dispatch: | ||
env: | ||
TIZEN_STUDIO_VER: 5.6 | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone repo | ||
uses: actions/checkout@v4 | ||
- 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 -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 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: Build updater service | ||
working-directory: tizenbrew-updater/TizenBrewUpdater/service | ||
run: | | ||
ncc build service.js | ||
rm -r node_modules | ||
- 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 | ||
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 | ||
run: | | ||
mkdir -p "${GITHUB_WORKSPACE}/tizen-studio-data/keystore/author/" | ||
echo "${{ secrets.TIZEN_AUTHOR_KEY }}" | base64 -d > "${GITHUB_WORKSPACE}/tizen-studio-data/keystore/author/tizenbrew-author.p12" | ||
./tizen-studio/tools/ide/bin/tizen cli-config "profiles.path=${GITHUB_WORKSPACE}/tizen-studio-data/profile/profiles.xml" | ||
cp .github/assets/profiles.xml "${GITHUB_WORKSPACE}/tizen-studio-data/profile/profiles.xml" | ||
sed -i "s|\$GITHUB_WORKSPACE|${GITHUB_WORKSPACE}|g" "${GITHUB_WORKSPACE}/tizen-studio-data/profile/profiles.xml" | ||
sed -i "s|\$KEY_PW|${{ secrets.TIZEN_AUTHOR_KEY_PW }}|g" "${GITHUB_WORKSPACE}/tizen-studio-data/profile/profiles.xml" | ||
chmod 755 "./tizen-studio-data/profile/profiles.xml" | ||
- name: Build TizenBrew | ||
working-directory: tizenbrew-app/TizenBrew | ||
run: | | ||
${GITHUB_WORKSPACE}/tizen-studio/tools/ide/bin/tizen build-web -e ".*" -e "node_modules/*" -e "package*.json" -e "yarn.lock" | ||
- name: Build TizenBrew Updater | ||
working-directory: tizenbrew-updater/TizenBrewUpdater | ||
run: | | ||
${GITHUB_WORKSPACE}/tizen-studio/tools/ide/bin/tizen build-web -e ".*" -e "node_modules/*" -e "package*.json" -e "yarn.lock" | ||
- name: Package TizenBrew for Old Tizen | ||
env: | ||
PASSWORD: ${{ secrets.TIZEN_AUTHOR_KEY_PW }} | ||
APP_PATH: tizenbrew-app/TizenBrew | ||
CERT: TizenBrew-Old | ||
run: | | ||
expect ./package.exp | ||
cat "${GITHUB_WORKSPACE}/tizen-studio-data/cli/logs/cli.log" | ||
mv tizenbrew-app/TizenBrew/release/TizenBrewStandalone.wgt tizenbrew-app/TizenBrew/release/TizenBrewStandalone-Old.wgt | ||
- name: Package TizenBrew for New Tizen | ||
env: | ||
PASSWORD: ${{ secrets.TIZEN_AUTHOR_KEY_PW }} | ||
APP_PATH: tizenbrew-app/TizenBrew | ||
CERT: TizenBrew-New | ||
run: | | ||
expect ./package.exp | ||
mv tizenbrew-app/TizenBrew/release/TizenBrewStandalone.wgt tizenbrew-app/TizenBrew/release/TizenBrewStandalone-New.wgt | ||
- name: Package TizenBrew Updater for Old Tizen | ||
env: | ||
PASSWORD: ${{ secrets.TIZEN_AUTHOR_KEY_PW }} | ||
APP_PATH: tizenbrew-updater/TizenBrewUpdater | ||
CERT: TizenBrew-Old | ||
run: | | ||
expect ./package.exp | ||
mv "tizenbrew-updater/TizenBrewUpdater/release/TizenBrew Updater.wgt" tizenbrew-updater/TizenBrewUpdater/release/TizenBrewUpdater-Old.wgt | ||
- name: Package TizenBrew Updater for New Tizen | ||
env: | ||
PASSWORD: ${{ secrets.TIZEN_AUTHOR_KEY_PW }} | ||
APP_PATH: tizenbrew-updater/TizenBrewUpdater | ||
CERT: TizenBrew-New | ||
run: | | ||
expect ./package.exp | ||
mv "tizenbrew-updater/TizenBrewUpdater/release/TizenBrew Updater.wgt" tizenbrew-updater/TizenBrewUpdater/release/TizenBrewUpdater-New.wgt | ||
- name: Package TizenBrew as USB Demo Package | ||
working-directory: tizenbrew-app/TizenBrew | ||
run: | | ||
wgt-to-usb release/TizenBrewStandalone-Old.wgt | ||
- name: Package Updater as USB Demo Package | ||
working-directory: tizenbrew-updater/TizenBrewUpdater | ||
run: | | ||
wgt-to-usb release/TizenBrewUpdater-Old.wgt | ||
- name: Package Updater for Desktop | ||
working-directory: tizenbrew-updater/TizenBrewUpdater | ||
run: | | ||
pkg -C GZip . --no-bytecode --public | ||
- name: Upload TizenBrew package artifact for Old Tizen | ||
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@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@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@v4 | ||
with: | ||
name: updater-${{ github.sha }}-new.wgt | ||
path: tizenbrew-updater/TizenBrewUpdater/release/TizenBrewUpdater-New.wgt | ||
- name: Zip USB Demo Package | ||
working-directory: tizenbrew-app/TizenBrew | ||
run: | | ||
zip -r release/TizenBrewStandaloneUSBDemo.zip userwidget/ | ||
- name: Zip Updater USB Demo Package | ||
working-directory: tizenbrew-updater/TizenBrewUpdater | ||
run: | | ||
zip -r release/TizenBrewUpdaterUSBDemo.zip userwidget/ | ||
- 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: 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: | | ||
all-build-files/* |