Skip to content

Commit

Permalink
Added build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
HackingGate committed Dec 18, 2023
1 parent dcf0cd2 commit 5594893
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build
on:
- "push"
- "workflow_dispatch"
jobs:
build:

runs-on: macos-13

strategy:
matrix:
platform: ['iOS', 'macOS', 'tvOS']

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- name: Fetch Commit Info
id: commitinfo
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Build ${{ matrix.platform }}
run: xcodebuild -workspace "MyAnimeList.xcoddproj" -scheme MyAnimeList -configuration Release -destination generic/platform=${{ matrix.platform }} archive -archivePath "build/MyAnimeList.${{ matrix.platform }}.xcarchive" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
- name: Package ${{ matrix.platform }}
run: ./Misc/scripts/package.sh "build/MyAnimeList.${{ matrix.platform }}.xcarchive" ${{ matrix.platform }} "MyAnimeList.${{ steps.commitinfo.outputs.sha_short }}.${{ matrix.platform }}"
- name: Upload ${{ matrix.platform }} Symbols
run: ./Misc/scripts/upload_symbols.sh ${{ secrets.APPCENTER_TOKEN }}
- name: Upload ${{ matrix.platform }} Artifacts
uses: actions/upload-artifact@v2
with:
name: MyAnimeList.${{ steps.commitinfo.outputs.sha_short }}.${{ matrix.platform }}
path: build/*
if-no-files-found: error
57 changes: 57 additions & 0 deletions .github/workflows/package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

XCARCHIVE="$(pwd)/$1"
PLATFORM="$2"
PROJ_DIR=`pwd`
PACKAGE_NAME="$3"
BIN_PKG_PATH=`find "${XCARCHIVE}" -name '*.app' -print0`
TMPDIR="$PROJ_DIR/build"
LICENSE_FILE="$PROJ_DIR/LICENSE"
APPNAME="MyAnimeList"

echo "[*] Packaging '${XCARCHIVE}' for platform ${PLATFORM} into package name '${PACKAGE_NAME}'..."

package_iOS() {
pushd "${TMPDIR}"

echo "[*] Generating .ipa archive..."

mkdir -p Payload
cp -R "${BIN_PKG_PATH}" "Payload/${APPNAME}.app"
echo "[*] Removing Non-MyAnimeList Dynamic Libraries:"
find "Payload/${APPNAME}.app/Frameworks" -depth 1 -type f \( \! -name 'MyAnimeList*' \) -exec echo "Removing: {}" \; -exec rm {} \;
zip -9 -r "${PACKAGE_NAME}.ipa" Payload
rm -rf Payload

echo "[*] Generating .dSYM archive..."

cp -R "${XCARCHIVE}/dSYMs" "dSYMs"
zip -9 -r "${PACKAGE_NAME}.dSYMs.zip" "dSYMs"
rm -rf dSYMs

popd
}

package_macOS() {
pushd "${TMPDIR}"

echo "[*] Generating .zip archive..."
cp -R "${BIN_PKG_PATH}" "${APPNAME}.app"
cp "${LICENSE_FILE}" "LICENSE"
codesign --force --deep --sign - "${APPNAME}.app"
zip -9 -r "${PACKAGE_NAME}.zip" "${APPNAME}.app" "LICENSE"
rm -rf "${APPNAME}.app" "LICENSE"

echo "[*] Generating .dSYM archive..."

cp -R "${XCARCHIVE}/dSYMs" "dSYMs"
zip -9 -r "${PACKAGE_NAME}.dSYMs.zip" "dSYMs"
rm -rf dSYMs

popd
}

"package_${PLATFORM}"

echo "[*] Removing xcarchive..."
rm -rf "${XCARCHIVE}"
26 changes: 26 additions & 0 deletions Misc/scripts/upload_symbols.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

APPCENTER_TOKEN="$1"

pushd build

for sym_archive in *.dSYMs.zip ; do
echo "[*] Obtaining symbols upload URL for '${sym_archive}'..."

UPLOAD_REQUEST_RES="$(curl -X POST "https://api.appcenter.ms/v0.1/apps/i-hackinggate.com/MyAnimeList/symbol_uploads" -H "X-API-Token: ${APPCENTER_TOKEN}" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"symbol_type\": \"Apple\", \"file_name\": \"${sym_archive}\" }")"
UPLOAD_URL=`osascript -l JavaScript -e "function run(o){return JSON.parse(o[0]).upload_url}" "${UPLOAD_REQUEST_RES}"`
UPLOAD_ID=`osascript -l JavaScript -e "function run(o){return JSON.parse(o[0]).symbol_upload_id}" "${UPLOAD_REQUEST_RES}"`

echo "[*] Uploading symbols in '${sym_archive}' (${UPLOAD_ID})..."
curl -X PUT "${UPLOAD_URL}" -H 'x-ms-blob-type: BlockBlob' --upload-file "${sym_archive}"

echo "[*] Committing ${UPLOAD_ID}..."
curl -X PATCH "https://api.appcenter.ms/v0.1/apps/i-hackinggate.com/MyAnimeList/symbol_uploads/${UPLOAD_ID}" \
-H 'accept: application/json' \
-H "X-API-Token: ${APPCENTER_TOKEN}" \
-H 'Content-Type: application/json' \
-d '{ "status": "committed" }'

done

popd

0 comments on commit 5594893

Please sign in to comment.