Skip to content

Commit 401e01c

Browse files
committed
Add workflows
1 parent 92abf26 commit 401e01c

2 files changed

Lines changed: 191 additions & 0 deletions

File tree

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Deploy Android
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Release version"
8+
required: true
9+
type: string
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
build:
16+
name: Signed release APK
17+
runs-on: ubuntu-latest
18+
defaults:
19+
run:
20+
working-directory: android
21+
steps:
22+
- uses: actions/checkout@v7
23+
24+
- name: Set up JDK 17
25+
uses: actions/setup-java@v5
26+
with:
27+
distribution: temurin
28+
java-version: "17"
29+
30+
- name: Set up Android SDK
31+
uses: android-actions/setup-android@v4
32+
33+
- name: Set up Gradle
34+
uses: gradle/actions/setup-gradle@v6
35+
36+
- name: Decode keystore
37+
run: echo "$KEYSTORE_BASE64" | base64 -d > "$RUNNER_TEMP/release.keystore"
38+
env:
39+
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
40+
41+
- name: Build signed release APK
42+
env:
43+
KEYSTORE_FILE: ${{ runner.temp }}/release.keystore
44+
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
45+
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
46+
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
47+
run: |
48+
./gradlew assembleRelease --no-daemon --stacktrace \
49+
-PversionName="${{ inputs.version }}" \
50+
-PversionCode="${{ github.run_number }}"
51+
52+
- name: Upload APK artifact
53+
uses: actions/upload-artifact@v7
54+
with:
55+
name: app-release-apk
56+
path: android/app/build/outputs/apk/release/app-release.apk
57+
if-no-files-found: error
58+
59+
release:
60+
needs: build
61+
runs-on: ubuntu-latest
62+
permissions:
63+
contents: write
64+
steps:
65+
- uses: actions/checkout@v7
66+
67+
- name: Download APK artifact
68+
uses: actions/download-artifact@v8.0.1
69+
with:
70+
name: app-release-apk
71+
path: dist
72+
73+
- name: Rename APK
74+
run: mv dist/app-release.apk "dist/TCOAAL-Player-v${{ inputs.version }}.apk"
75+
76+
- name: Publish release and tag the build commit
77+
uses: softprops/action-gh-release@v3.0.1
78+
with:
79+
tag_name: android/v${{ inputs.version }}
80+
name: Android v${{ inputs.version }}
81+
target_commitish: ${{ github.sha }}
82+
files: dist/TCOAAL-Player-v${{ inputs.version }}.apk

.github/workflows/deploy-web.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Deploy Web
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Release version"
8+
required: true
9+
type: string
10+
11+
permissions:
12+
contents: write
13+
pages: write
14+
id-token: write
15+
16+
concurrency:
17+
group: pages
18+
cancel-in-progress: true
19+
20+
jobs:
21+
deploy:
22+
runs-on: ubuntu-latest
23+
environment:
24+
name: github-pages
25+
url: ${{ steps.deployment.outputs.page_url }}
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v7.0.0
29+
- name: Setup site
30+
env:
31+
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
32+
run: |
33+
mkdir -p ~/.ssh
34+
echo "$DEPLOY_KEY" > ~/.ssh/id_key
35+
chmod 600 ~/.ssh/id_key
36+
ssh-keyscan github.com >> ~/.ssh/known_hosts 2>/dev/null
37+
GIT_SSH_COMMAND="ssh -i ~/.ssh/id_key -o StrictHostKeyChecking=no" \
38+
git clone --recursive git@github.com:cal-mods/basics.git _mods_src
39+
for mod_dir in _mods_src/*/; do
40+
mod_name=$(basename "$mod_dir")
41+
[ -d "$mod_dir" ] || continue
42+
if [ -d "mods/$mod_name" ] && [[ "$mod_name" == _* ]]; then
43+
continue
44+
fi
45+
rm -rf "mods/$mod_name"
46+
cp -r "$mod_dir" "mods/$mod_name"
47+
done
48+
rm -rf _mods_src ~/.ssh/id_key
49+
mkdir _site
50+
cp -r app/* _site/
51+
cp -r mods _site/mods
52+
cp mods.json _site/mods.json
53+
# /notice.html fetches and renders this; it is the single source of
54+
# truth for the project's statement of purpose (see server.js).
55+
cp NOTICE.md _site/NOTICE.md
56+
mkdir -p _site/img
57+
curl -fsSL -o _site/img/achievement-unlocked.jpg \
58+
https://cdn.fastly.steamstatic.com/steamcommunity/public/images/apps/2378900/55f956539371a92bd5d24a0a72d84cf983eb4b82.jpg
59+
curl -fsSL -o _site/img/achievement-locked.jpg \
60+
https://cdn.fastly.steamstatic.com/steamcommunity/public/images/apps/2378900/8909a9950e3deb1c38afce9a4b427d5f7dfb461b.jpg
61+
curl -fsSL -o _site/img/tcoaal-steam-header.jpg \
62+
https://shared.fastly.steamstatic.com/store_item_assets/steam/apps/2378900/0badd5423ec8cb36d543b7b156121ac2d38ef330/header.jpg
63+
64+
- name: Setup Node
65+
uses: actions/setup-node@v6.4.0
66+
with:
67+
node-version: 20
68+
69+
- name: Minify and stamp
70+
run: |
71+
for f in _site/*.html; do
72+
npx --yes html-minifier-terser@7 \
73+
--collapse-whitespace --remove-comments \
74+
--minify-css true \
75+
--minify-js '{"compress":true,"mangle":false}' \
76+
-o "$f.tmp" "$f"
77+
mv "$f.tmp" "$f"
78+
done
79+
while IFS= read -r f; do
80+
npx --yes terser@5 "$f" --compress --comments false -o "$f.tmp"
81+
mv "$f.tmp" "$f"
82+
done < <(find _site/js _site/sw.js -name '*.js' ! -name '*.min.js')
83+
BUILD_TS=$(TZ=UTC date '+%d/%m/%Y %H:%M:%S')
84+
printf '\n<!-- %s -->\n' "$BUILD_TS" >> _site/index.html
85+
printf '\n<!-- %s -->\n' "$BUILD_TS" >> _site/loader.html
86+
87+
- name: Upload artifact
88+
uses: actions/upload-pages-artifact@v5
89+
with:
90+
path: _site
91+
retention-days: 1
92+
93+
- name: Deploy to GitHub Pages
94+
id: deployment
95+
uses: actions/deploy-pages@v5
96+
97+
- name: Delete artifact
98+
uses: geekyeggo/delete-artifact@v6
99+
with:
100+
name: github-pages
101+
102+
- name: Tag the build commit
103+
env:
104+
TAG: web/v${{ inputs.version }}
105+
run: |
106+
git config user.name "github-actions[bot]"
107+
git config user.email "github-actions[bot]@users.noreply.github.com"
108+
git tag -a "$TAG" -m "$TAG" "$GITHUB_SHA"
109+
git push origin "refs/tags/$TAG"

0 commit comments

Comments
 (0)