Files
breeze/.github/workflows/release.yml
T

761 lines
26 KiB
YAML

name: Release
on:
push:
branches:
- master
workflow_dispatch:
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Test
runs-on: ubuntu-latest
env:
APT_CACHE_DIR: /tmp/apt-cache
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Cache Test apt packages
uses: actions/cache@v4
with:
path: ${{ env.APT_CACHE_DIR }}
key: test-apt-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.github/apt/test-packages.txt') }}
restore-keys: |
test-apt-${{ runner.os }}-${{ runner.arch }}-
- name: Install Test Dependencies
run: |
set -euo pipefail
mapfile -t packages < .github/apt/test-packages.txt
mkdir -p "$APT_CACHE_DIR/partial"
sudo apt-get update
sudo apt-get \
-o Dir::Cache::archives="$APT_CACHE_DIR" \
install -y "${packages[@]}"
sudo chown -R "$USER:$USER" "$APT_CACHE_DIR"
- name: Run Tests
run: make test
build-web:
name: Build Web
runs-on: ubuntu-latest
needs: test
env:
APT_CACHE_DIR: /tmp/apt-cache
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Cache Web apt packages
uses: actions/cache@v4
with:
path: ${{ env.APT_CACHE_DIR }}
key: web-apt-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.github/apt/web-packages.txt') }}
restore-keys: |
web-apt-${{ runner.os }}-${{ runner.arch }}-
- name: Install Web Dependencies
run: |
set -euo pipefail
mapfile -t packages < .github/apt/web-packages.txt
mkdir -p "$APT_CACHE_DIR/partial"
sudo apt-get update
sudo apt-get \
-o Dir::Cache::archives="$APT_CACHE_DIR" \
install -y "${packages[@]}"
sudo chown -R "$USER:$USER" "$APT_CACHE_DIR"
- name: Set up Emscripten
run: |
set -euo pipefail
git clone --depth 1 https://github.com/emscripten-core/emsdk.git "$HOME/emsdk"
"$HOME/emsdk/emsdk" install latest
"$HOME/emsdk/emsdk" activate latest
echo "EMSDK=$HOME/emsdk" >> "$GITHUB_ENV"
echo "EM_CONFIG=$HOME/emsdk/.emscripten" >> "$GITHUB_ENV"
echo "$HOME/emsdk" >> "$GITHUB_PATH"
echo "$HOME/emsdk/upstream/emscripten" >> "$GITHUB_PATH"
- name: Build Web ZIP
run: |
set -euo pipefail
make package-unpackaged-assets
make web
mkdir -p build/release/web
cp build/dist/inbe-web.zip build/release/web/
- name: Upload Web Artifact
uses: actions/upload-artifact@v4
with:
name: release-web
path: build/release/web/*
if-no-files-found: error
build-chrome-extension:
name: Build Chrome Extension
runs-on: ubuntu-latest
needs: test
env:
APT_CACHE_DIR: /tmp/apt-cache
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Cache Web apt packages
uses: actions/cache@v4
with:
path: ${{ env.APT_CACHE_DIR }}
key: web-apt-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.github/apt/web-packages.txt') }}
restore-keys: |
web-apt-${{ runner.os }}-${{ runner.arch }}-
- name: Install Web Dependencies
run: |
set -euo pipefail
mapfile -t packages < .github/apt/web-packages.txt
mkdir -p "$APT_CACHE_DIR/partial"
sudo apt-get update
sudo apt-get \
-o Dir::Cache::archives="$APT_CACHE_DIR" \
install -y "${packages[@]}"
sudo chown -R "$USER:$USER" "$APT_CACHE_DIR"
- name: Set up Emscripten
run: |
set -euo pipefail
git clone --depth 1 https://github.com/emscripten-core/emsdk.git "$HOME/emsdk"
"$HOME/emsdk/emsdk" install latest
"$HOME/emsdk/emsdk" activate latest
echo "EMSDK=$HOME/emsdk" >> "$GITHUB_ENV"
echo "EM_CONFIG=$HOME/emsdk/.emscripten" >> "$GITHUB_ENV"
echo "$HOME/emsdk" >> "$GITHUB_PATH"
echo "$HOME/emsdk/upstream/emscripten" >> "$GITHUB_PATH"
- name: Build Chrome Extension ZIP
run: |
set -euo pipefail
make package-unpackaged-assets
make chrome-web-store
mkdir -p build/release/chrome-web-store
cp build/dist/inbe-chrome-web-store.zip build/release/chrome-web-store/
- name: Upload Chrome Extension Artifact
uses: actions/upload-artifact@v4
with:
name: release-chrome-web-store
path: build/release/chrome-web-store/*
if-no-files-found: error
build-linux:
name: Build Linux
runs-on: ubuntu-22.04
needs: test
env:
APT_CACHE_DIR: /tmp/apt-cache
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Cache Linux apt packages
uses: actions/cache@v4
with:
path: ${{ env.APT_CACHE_DIR }}
key: linux-apt-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.github/apt/linux-packages.txt') }}
restore-keys: |
linux-apt-${{ runner.os }}-${{ runner.arch }}-
- name: Install Linux Dependencies
run: |
set -euo pipefail
mapfile -t packages < .github/apt/linux-packages.txt
mkdir -p "$APT_CACHE_DIR/partial"
sudo apt-get update
sudo apt-get \
-o Dir::Cache::archives="$APT_CACHE_DIR" \
install -y "${packages[@]}"
sudo chown -R "$USER:$USER" "$APT_CACHE_DIR"
- name: Install AppImage Tools
run: |
set -euo pipefail
mkdir -p "$HOME/.local/bin"
curl -L -o "$HOME/.local/bin/linuxdeploy" \
https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
curl -L -o "$HOME/.local/bin/linuxdeploy-plugin-appimage" \
https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/1-alpha-20250213-1/linuxdeploy-plugin-appimage-x86_64.AppImage
curl -L -o "$HOME/.local/bin/appimagetool" \
https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage
chmod +x "$HOME/.local/bin/linuxdeploy" "$HOME/.local/bin/linuxdeploy-plugin-appimage" "$HOME/.local/bin/appimagetool"
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Build Linux AppImage
env:
APPIMAGE_EXTRACT_AND_RUN: "1"
RAY_RAYLIB_CONFIG: -DSUPPORT_SCREEN_CAPTURE=0 -DSUPPORT_COMPRESSION_API=0 -DSUPPORT_AUTOMATION_EVENTS=0 -DSUPPORT_CLIPBOARD_IMAGE=0 -DSUPPORT_FILEFORMAT_BMP=0 -DSUPPORT_FILEFORMAT_GIF=0 -DSUPPORT_FILEFORMAT_QOI=0 -DSUPPORT_FILEFORMAT_DDS=0 -DSUPPORT_FILEFORMAT_TTF=0
run: |
set -euo pipefail
RAY_SDL_INCLUDE_DIR="$(pkg-config --variable=includedir sdl2 | sed 's,/SDL2$,,')"
RAY_CFLAGS="$(pkg-config --cflags sdl2 libdrm gbm egl glesv2)"
RAY_LDLIBS="$(pkg-config --libs sdl2 libdrm gbm egl glesv2)"
RAY_SDL_LDLIBS="$(pkg-config --libs sdl2)"
export RAY_SDL_INCLUDE_DIR RAY_CFLAGS RAY_LDLIBS RAY_SDL_LDLIBS
make appimage
mkdir -p build/release/linux
find build/dist/linux -maxdepth 1 -type f -name '*.AppImage' -exec cp {} build/release/linux/ \;
test -n "$(find build/release/linux -type f -print -quit)"
- name: Smoke Test Linux AppImage
env:
APPIMAGE_EXTRACT_AND_RUN: "1"
DISPLAY: ":99"
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y xvfb x11-utils
appimage="$(find build/release/linux -maxdepth 1 -type f -name '*.AppImage' | head -n 1)"
chmod +x "$appimage"
Xvfb "$DISPLAY" -screen 0 800x600x24 >/tmp/inbe-xvfb.log 2>&1 &
xvfb_pid=$!
trap 'kill "$app_pid" "$xvfb_pid" >/dev/null 2>&1 || true' EXIT
sleep 2
"$appimage" >/tmp/inbe-appimage.log 2>&1 &
app_pid=$!
for _ in $(seq 1 30); do
if xwininfo -tree -root | grep -q 'Inner Breeze'; then
exit 0
fi
if ! kill -0 "$app_pid" >/dev/null 2>&1; then
echo "AppImage exited before opening a window"
cat /tmp/inbe-appimage.log || true
exit 1
fi
sleep 1
done
echo "AppImage did not open an X11 window within 30 seconds"
cat /tmp/inbe-appimage.log || true
exit 1
- name: Upload Linux Artifact
uses: actions/upload-artifact@v4
with:
name: release-linux
path: build/release/linux/*
if-no-files-found: error
build-windows:
name: Build Windows
runs-on: ubuntu-latest
needs: test
env:
APT_CACHE_DIR: /tmp/apt-cache
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Cache Windows apt packages
uses: actions/cache@v4
with:
path: ${{ env.APT_CACHE_DIR }}
key: windows-apt-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.github/apt/windows-packages.txt') }}
restore-keys: |
windows-apt-${{ runner.os }}-${{ runner.arch }}-
- name: Cache Windows vendor builds
uses: actions/cache@v4
with:
path: |
vendor-builds/windows
vendor-builds/sqlite
key: windows-vendor-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Makefile', 'vendor/flint/vendor/raylib/src/**', 'vendor/curl/**', 'vendor/sqlite/**') }}
restore-keys: |
windows-vendor-${{ runner.os }}-${{ runner.arch }}-
- name: Install Windows Dependencies
run: |
set -euo pipefail
mapfile -t packages < .github/apt/windows-packages.txt
mkdir -p "$APT_CACHE_DIR/partial"
sudo apt-get update
sudo apt-get \
-o Dir::Cache::archives="$APT_CACHE_DIR" \
install -y "${packages[@]}"
sudo chown -R "$USER:$USER" "$APT_CACHE_DIR"
if [ -x /usr/bin/x86_64-w64-mingw32-gcc-win32 ]; then
sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-win32
fi
if [ -x /usr/bin/i686-w64-mingw32-gcc-win32 ]; then
sudo update-alternatives --set i686-w64-mingw32-gcc /usr/bin/i686-w64-mingw32-gcc-win32
fi
- name: Build Windows ZIP
run: |
set -euo pipefail
make windows
mkdir -p build/release/windows
find build/dist/windows -maxdepth 1 -type f -name '*.zip' -exec cp {} build/release/windows/ \;
test -n "$(find build/release/windows -type f -print -quit)"
- name: Upload Windows Artifact
uses: actions/upload-artifact@v4
with:
name: release-windows
path: build/release/windows/*
if-no-files-found: error
build-android:
name: Build Android
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Cache Android SDK packages
uses: actions/cache@v4
with:
path: |
${{ env.ANDROID_HOME }}/platforms/android-35
${{ env.ANDROID_HOME }}/build-tools/34.0.0
${{ env.ANDROID_HOME }}/ndk/25.1.8937393
${{ env.ANDROID_HOME }}/ndk/28.2.13676358
${{ env.ANDROID_HOME }}/cmake/3.22.1
key: android-sdk-${{ runner.os }}-${{ runner.arch }}-api35-bt34-ndk25-ndk28-cmake322
restore-keys: |
android-sdk-${{ runner.os }}-${{ runner.arch }}-
- name: Cache Android native build
uses: actions/cache@v4
with:
path: |
droid/app/.cxx
droid/app/build/intermediates/cxx
key: android-native-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('droid/app/src/main/cpp/CMakeLists.txt', 'droid/app/build.gradle', 'src/**/*.c', 'src/**/*.h', 'flint/src/**/*.c', 'flint/include/**/*.h', 'vendor/flint/vendor/raylib/src/**') }}
restore-keys: |
android-native-${{ runner.os }}-${{ runner.arch }}-
- name: Install Android SDK Components
run: |
set -euo pipefail
SDKMANAGER="$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager"
yes | "$SDKMANAGER" --licenses >/dev/null || true
"$SDKMANAGER" "platforms;android-35" "build-tools;34.0.0" "ndk;25.1.8937393" "cmake;3.22.1"
- name: Prepare Android signing key
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
run: |
set -euo pipefail
mkdir -p ~/.android
echo "$KEYSTORE_BASE64" | base64 -d > ~/.android/inbe-release.keystore
- name: Copy Android Assets
run: ./scripts/copy-android-assets.sh
- name: Build Android APK and AAB
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
run: |
set -euo pipefail
chmod +x droid/gradlew
./droid/gradlew -p droid assembleRelease \
-Pkeystore.path="$HOME/.android/inbe-release.keystore" \
-Pkeystore.alias="$KEY_ALIAS" \
-Pkeystore.password="$KEYSTORE_PASSWORD" \
--stacktrace
./droid/gradlew -p droid bundleRelease \
-Pkeystore.path="$HOME/.android/inbe-release.keystore" \
-Pkeystore.alias="$KEY_ALIAS" \
-Pkeystore.password="$KEYSTORE_PASSWORD" \
--stacktrace
make android-copy-release-apks
make android-copy-bundle
- name: Collect Android Release Files
run: |
set -euo pipefail
mkdir -p build/release/android
VERSION=$(sed -n 's/^#define INBE_VERSION_STRING "\([^"]*\)".*/\1/p' src/core/version.h)
if [ -z "$VERSION" ]; then
echo "Could not read INBE_VERSION_STRING"
exit 1
fi
cp "build/android/inbe-$VERSION.apk" build/release/android/
aab="$(find droid/app/build/outputs/bundle/release build/android -type f -name '*.aab' | head -n 1)"
if [ -z "$aab" ]; then
echo "No release AAB was produced"
exit 1
fi
cp "$aab" "build/release/android/inbe-$VERSION.aab"
- name: Upload Android Artifacts
uses: actions/upload-artifact@v4
with:
name: release-android
path: build/release/android/*
if-no-files-found: error
release:
name: Release
runs-on: ubuntu-latest
needs:
- build-web
- build-chrome-extension
- build-linux
- build-windows
- build-android
outputs:
tag_pushed: ${{ steps.tag_version.outputs.tag_pushed }}
tag_name: ${{ steps.tag_version.outputs.tag_name }}
version: ${{ steps.tag_version.outputs.version }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download Release Artifacts
uses: actions/download-artifact@v4
with:
pattern: release-*
path: build/release
merge-multiple: true
- name: Verify Release Artifacts
run: |
set -euo pipefail
test -n "$(find build/release -type f -print -quit)"
- name: Create and Push Tag If Version Is New
id: tag_version
run: |
set -euo pipefail
VERSION=$(sed -n 's/^#define INBE_VERSION_STRING "\([^"]*\)".*/\1/p' src/core/version.h)
if [ -z "$VERSION" ]; then
echo "Could not read INBE_VERSION_STRING"
exit 1
fi
TAG="v$VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag_name=$TAG" >> "$GITHUB_OUTPUT"
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG exists, skipping release"
echo "tag_pushed=false" >> "$GITHUB_OUTPUT"
else
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "$TAG" -m "Release $VERSION"
git push origin "$TAG"
echo "tag_pushed=true" >> "$GITHUB_OUTPUT"
fi
- name: Create GitHub Release
if: steps.tag_version.outputs.tag_pushed == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag_version.outputs.tag_name }}
files: build/release/*
generate_release_notes: true
draft: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-itch:
name: Publish itch.io
runs-on: ubuntu-latest
needs:
- build-web
- release
if: needs.release.outputs.tag_pushed == 'true'
env:
BUTLER_API_KEY: ${{ secrets.ITCH_API_KEY }}
steps:
- name: Check itch.io Secret
run: |
set -euo pipefail
if [ -z "${BUTLER_API_KEY:-}" ]; then
echo "ITCH_API_KEY secret is required to publish itch.io"
exit 1
fi
- name: Download Release Artifacts
uses: actions/download-artifact@v4
with:
pattern: release-*
path: build/release
merge-multiple: true
- name: Install Butler
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y unzip
curl -fsSL \
https://broth.itch.zone/butler/linux-amd64/LATEST/archive/default \
-o "$RUNNER_TEMP/butler.zip"
mkdir -p "$RUNNER_TEMP/butler"
unzip -q "$RUNNER_TEMP/butler.zip" -d "$RUNNER_TEMP/butler"
chmod +x "$RUNNER_TEMP/butler/butler"
echo "$RUNNER_TEMP/butler" >> "$GITHUB_PATH"
- name: Check Butler
run: |
set -euo pipefail
butler version
- name: Publish Release Builds to itch.io
run: |
set -euo pipefail
VERSION="${{ needs.release.outputs.version }}"
web_zip="build/release/inbe-web.zip"
android_apk="build/release/inbe-$VERSION.apk"
windows_zip="build/release/inbe-windows.zip"
linux_appimage="build/release/inbe-linux-x86_64.AppImage"
test -f "$web_zip"
test -f "$android_apk"
test -f "$windows_zip"
test -f "$linux_appimage"
mkdir -p build/itch/inbe-web
unzip -q "$web_zip" -d build/itch/inbe-web
butler_push() {
local target="$1"
local channel="$2"
local attempt
local log_file
log_file="$(mktemp)"
for attempt in 1 2 3 4 5 6; do
if butler push "$target" "waozi/inbe:$channel" --userversion "$VERSION" 2>&1 | tee "$log_file"; then
rm -f "$log_file"
return 0
fi
if ! grep -q "latest build is still processing" "$log_file"; then
rm -f "$log_file"
return 1
fi
echo "itch.io channel $channel is still processing; retrying in 60s ($attempt/6)"
sleep 60
done
rm -f "$log_file"
echo "itch.io channel $channel was still processing after retries"
return 1
}
butler_push build/itch/inbe-web html5
butler_push "$android_apk" android
butler_push "$windows_zip" windows
butler_push "$linux_appimage" linux
publish-google-play:
name: Publish Google Play Production
runs-on: ubuntu-latest
needs:
- build-android
- release
if: needs.release.outputs.tag_pushed == 'true'
steps:
- name: Check Google Play Secret
env:
PLAY_STORE_JSON_KEY: ${{ secrets.PLAY_STORE_JSON_KEY }}
run: |
set -euo pipefail
if [ -z "${PLAY_STORE_JSON_KEY:-}" ]; then
echo "PLAY_STORE_JSON_KEY secret is required to publish Google Play"
exit 1
fi
- name: Download Android Release Artifact
uses: actions/download-artifact@v4
with:
name: release-android
path: build/release/android
- name: Publish AAB to Google Play Production
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.PLAY_STORE_JSON_KEY }}
packageName: xyz.waozi.inbe
releaseFiles: build/release/android/*.aab
track: production
status: completed
publish-amazon:
name: Publish Amazon Appstore
runs-on: ubuntu-latest
needs:
- build-android
- release
if: needs.release.outputs.tag_pushed == 'true'
env:
AMAZON_CLIENT_ID: ${{ secrets.AMAZON_CLIENT_ID }}
AMAZON_CLIENT_SECRET: ${{ secrets.AMAZON_CLIENT_SECRET }}
AMAZON_APP_ID: ${{ secrets.AMAZON_APP_ID }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check Amazon Appstore Secrets
run: |
set -euo pipefail
for name in AMAZON_CLIENT_ID AMAZON_CLIENT_SECRET AMAZON_APP_ID; do
if [ -z "${!name:-}" ]; then
echo "$name secret is required to publish Amazon Appstore"
exit 1
fi
done
- name: Download Android Release Artifact
uses: actions/download-artifact@v4
with:
name: release-android
path: build/release/android
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '24'
- name: Upload AAB to Amazon Appstore
env:
AMAZON_RELEASE_FILE: build/release/android/inbe-${{ needs.release.outputs.version }}.aab
run: node scripts/upload-amazon-appstore.mjs
publish-chrome-web-store:
name: Publish Chrome Web Store
runs-on: ubuntu-latest
needs:
- build-chrome-extension
- release
if: needs.release.outputs.tag_pushed == 'true'
steps:
- name: Check Chrome Web Store Secrets
env:
CHROME_CLIENT_ID: ${{ secrets.CHROME_CLIENT_ID }}
CHROME_CLIENT_SECRET: ${{ secrets.CHROME_CLIENT_SECRET }}
CHROME_REFRESH_TOKEN: ${{ secrets.CHROME_REFRESH_TOKEN }}
run: |
set -euo pipefail
if [ -z "${CHROME_CLIENT_ID:-}" ]; then
echo "CHROME_CLIENT_ID secret is required to publish Chrome Web Store"
exit 1
fi
if [ -z "${CHROME_CLIENT_SECRET:-}" ]; then
echo "CHROME_CLIENT_SECRET secret is required to publish Chrome Web Store"
exit 1
fi
if [ -z "${CHROME_REFRESH_TOKEN:-}" ]; then
echo "CHROME_REFRESH_TOKEN secret is required to publish Chrome Web Store"
exit 1
fi
- name: Download Chrome Extension Artifact
uses: actions/download-artifact@v4
with:
name: release-chrome-web-store
path: build/release/chrome-web-store
- name: Publish Chrome Extension
env:
CHROME_CLIENT_ID: ${{ secrets.CHROME_CLIENT_ID }}
CHROME_CLIENT_SECRET: ${{ secrets.CHROME_CLIENT_SECRET }}
CHROME_REFRESH_TOKEN: ${{ secrets.CHROME_REFRESH_TOKEN }}
CHROME_EXTENSION_ID: lballhghblaenelehneigekpofgcaifa
CHROME_EXTENSION_ZIP: build/release/chrome-web-store/inbe-chrome-web-store.zip
run: |
set -euo pipefail
token_response="$(curl --fail --silent --show-error \
--request POST \
--data-urlencode "client_id=${CHROME_CLIENT_ID}" \
--data-urlencode "client_secret=${CHROME_CLIENT_SECRET}" \
--data-urlencode "refresh_token=${CHROME_REFRESH_TOKEN}" \
--data-urlencode "grant_type=refresh_token" \
https://oauth2.googleapis.com/token)"
access_token="$(python3 -c 'import json, sys; print(json.load(sys.stdin)["access_token"])' <<< "$token_response")"
upload_response="$(curl --fail --silent --show-error \
--request PUT \
--header "Authorization: Bearer ${access_token}" \
--header "x-goog-api-version: 2" \
--upload-file "${CHROME_EXTENSION_ZIP}" \
"https://www.googleapis.com/upload/chromewebstore/v1.1/items/${CHROME_EXTENSION_ID}")"
python3 - "$upload_response" <<'PY'
import json
import sys
response = json.loads(sys.argv[1])
if response.get("uploadState") != "SUCCESS":
print(json.dumps(response, indent=2), file=sys.stderr)
raise SystemExit("Chrome Web Store upload failed")
PY
publish_response="$(curl --fail --silent --show-error \
--request POST \
--header "Authorization: Bearer ${access_token}" \
--header "x-goog-api-version: 2" \
"https://www.googleapis.com/chromewebstore/v1.1/items/${CHROME_EXTENSION_ID}/publish")"
python3 - "$publish_response" <<'PY'
import json
import sys
response = json.loads(sys.argv[1])
if "OK" not in response.get("status", []):
print(json.dumps(response, indent=2), file=sys.stderr)
raise SystemExit("Chrome Web Store publish failed")
PY