Skip to content

Commit 9221267

Browse files
committed
Implemented ci-workflow
1 parent 57aaea9 commit 9221267

File tree

4 files changed

+283
-0
lines changed

4 files changed

+283
-0
lines changed

.github/workflows/ci.yml

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
name: CI - test, build, release
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
7+
permissions:
8+
contents: write # needed for releases
9+
10+
env:
11+
APP_NAME: "Asante Typing"
12+
APP_ID: "com.asante.typing" # change if you have a bundle id
13+
APP_VERSION: "${{ github.run_number }}" # simple rolling version
14+
RELEASE_TAG: "continuous"
15+
16+
jobs:
17+
test:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: subosito/flutter-action@v2
22+
with:
23+
channel: stable
24+
cache: true
25+
- run: flutter --version
26+
- run: flutter pub get
27+
- run: flutter test
28+
29+
linux:
30+
needs: test
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v4
34+
- uses: subosito/flutter-action@v2
35+
with:
36+
channel: stable
37+
cache: true
38+
- name: Install Linux desktop deps
39+
run: |
40+
sudo apt-get update
41+
sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev
42+
- run: flutter config --enable-linux-desktop
43+
- run: flutter pub get
44+
- run: flutter build linux --release
45+
- name: Package .deb
46+
run: bash scripts/package_deb.sh "$APP_VERSION"
47+
- name: Tar bundle
48+
run: |
49+
mkdir -p dist/linux
50+
tar -C build/linux/x64/release -czf dist/linux/asante-typing-linux-x64-bundle.tar.gz bundle
51+
- uses: actions/upload-artifact@v4
52+
with:
53+
name: linux
54+
path: |
55+
dist/linux/*.deb
56+
dist/linux/*.tar.gz
57+
58+
windows:
59+
needs: test
60+
runs-on: windows-latest
61+
steps:
62+
- uses: actions/checkout@v4
63+
- uses: subosito/flutter-action@v2
64+
with:
65+
channel: stable
66+
cache: true
67+
- run: flutter config --enable-windows-desktop
68+
- run: flutter pub get
69+
- run: flutter build windows --release
70+
- name: Install Inno Setup
71+
run: choco install innosetup -y
72+
- name: Build installer (.exe)
73+
run: |
74+
iscc /DAppVersion=%APP_VERSION% installer/windows/AsanteTyping.iss
75+
shell: cmd
76+
- uses: actions/upload-artifact@v4
77+
with:
78+
name: windows
79+
path: dist/windows/*.exe
80+
81+
macos:
82+
needs: test
83+
runs-on: macos-latest
84+
steps:
85+
- uses: actions/checkout@v4
86+
- uses: subosito/flutter-action@v2
87+
with:
88+
channel: stable
89+
cache: true
90+
- run: flutter config --enable-macos-desktop
91+
- run: flutter pub get
92+
- run: flutter build macos --release
93+
- name: Brew create-dmg
94+
run: brew install create-dmg
95+
- name: Package .dmg
96+
run: bash scripts/package_dmg.sh "$APP_VERSION"
97+
- name: Zip .app (alt format)
98+
run: |
99+
mkdir -p dist/macos
100+
ditto -c -k --keepParent "build/macos/Build/Products/Release/${{ env.APP_NAME }}.app" "dist/macos/asante-typing-macos-${{ env.APP_VERSION }}.zip"
101+
- uses: actions/upload-artifact@v4
102+
with:
103+
name: macos
104+
path: |
105+
dist/macos/*.dmg
106+
dist/macos/*.zip
107+
108+
android:
109+
needs: test
110+
runs-on: ubuntu-latest
111+
steps:
112+
- uses: actions/checkout@v4
113+
- uses: subosito/flutter-action@v2
114+
with:
115+
channel: stable
116+
cache: true
117+
android: true
118+
- uses: actions/setup-java@v4
119+
with:
120+
distribution: temurin
121+
java-version: "17"
122+
- run: flutter pub get
123+
124+
# Optional signing (set these repo secrets to enable)
125+
- name: Setup Android keystore (optional)
126+
if: ${{ secrets.ANDROID_KEYSTORE_BASE64 != '' }}
127+
run: |
128+
echo "${ANDROID_KEYSTORE_BASE64}" | base64 -d > android/keystore.jks
129+
{
130+
echo "storeFile=keystore.jks"
131+
echo "storePassword=${ANDROID_KEYSTORE_PASSWORD}"
132+
echo "keyAlias=${ANDROID_KEY_ALIAS}"
133+
echo "keyPassword=${ANDROID_KEY_PASSWORD}"
134+
} >> android/key.properties
135+
env:
136+
ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
137+
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
138+
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
139+
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
140+
141+
- name: Build APK (release)
142+
run: flutter build apk --release
143+
- name: Build App Bundle (release)
144+
run: flutter build appbundle --release
145+
- uses: actions/upload-artifact@v4
146+
with:
147+
name: android
148+
path: |
149+
build/app/outputs/flutter-apk/app-release.apk
150+
build/app/outputs/bundle/release/app-release.aab
151+
152+
release:
153+
needs: [linux, windows, macos, android]
154+
runs-on: ubuntu-latest
155+
steps:
156+
- uses: actions/checkout@v4
157+
- uses: actions/download-artifact@v4
158+
with:
159+
path: dist
160+
- name: List files going to release
161+
run: find dist -type f -maxdepth 3 -print
162+
- name: Publish/Update "continuous" release
163+
uses: marvinpinto/action-automatic-releases@latest
164+
with:
165+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
166+
automatic_release_tag: "${{ env.RELEASE_TAG }}"
167+
prerelease: true
168+
title: "Continuous build"
169+
files: |
170+
dist/**/*

installer/windows/AsanteTyping.iss

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#define AppName "Asante Typing"
2+
#define AppExe "asante_typing.exe"
3+
#define AppVersion GetEnv("AppVersion")
4+
#define SourceDir "build\windows\x64\runner\Release"
5+
#define OutputDir "dist\windows"
6+
7+
[Setup]
8+
AppId={{C92C9E0C-6A39-4D2C-9E4C-1A9C3E5A7F11}
9+
AppName={#AppName}
10+
AppVersion={#AppVersion}
11+
DefaultDirName={pf}\{#AppName}
12+
DefaultGroupName={#AppName}
13+
DisableDirPage=yes
14+
DisableProgramGroupPage=yes
15+
OutputBaseFilename=AsanteTyping-Setup-{#AppVersion}
16+
Compression=lzma
17+
SolidCompression=yes
18+
OutputDir={#OutputDir}
19+
ArchitecturesInstallIn64BitMode=x64
20+
21+
[Files]
22+
Source: "{#SourceDir}\*"; DestDir: "{app}"; Flags: recursesubdirs ignoreversion
23+
24+
[Icons]
25+
Name: "{group}\{#AppName}"; Filename: "{app}\{#AppExe}"
26+
Name: "{commondesktop}\{#AppName}"; Filename: "{app}\{#AppExe}"; Tasks: desktopicon
27+
28+
[Tasks]
29+
Name: "desktopicon"; Description: "Create a &desktop icon"; GroupDescription: "Additional icons:"; Flags: unchecked
30+
31+
[Run]
32+
Filename: "{app}\{#AppExe}"; Description: "Launch {#AppName}"; Flags: nowait postinstall skipifsilent

scripts/package_deb.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
VERSION="${1:-0.0.0}"
5+
APP_NAME="Asante Typing"
6+
APP_BIN_NAME="asante-typing" # launcher name
7+
BUNDLE_DIR="build/linux/x64/release/bundle"
8+
9+
if [[ ! -d "$BUNDLE_DIR" ]]; then
10+
echo "Bundle not found: $BUNDLE_DIR" >&2
11+
exit 1
12+
fi
13+
14+
WORK="dist/linux/pkg"
15+
DEB_OUT="dist/linux"
16+
mkdir -p "$WORK/DEBIAN" "$WORK/usr/bin" "$WORK/opt/$APP_BIN_NAME" "$WORK/usr/share/applications"
17+
18+
# copy built files
19+
cp -a "$BUNDLE_DIR/." "$WORK/opt/$APP_BIN_NAME/"
20+
21+
# simple launcher wrapper
22+
cat > "$WORK/usr/bin/$APP_BIN_NAME" <<'EOF'
23+
#!/usr/bin/env bash
24+
DIR="/opt/asante-typing"
25+
exec "$DIR/${APPIMAGE:-}/asante_typing" "$@"
26+
EOF
27+
chmod +x "$WORK/usr/bin/$APP_BIN_NAME"
28+
29+
# .desktop entry
30+
cat > "$WORK/usr/share/applications/${APP_BIN_NAME}.desktop" <<EOF
31+
[Desktop Entry]
32+
Name=$APP_NAME
33+
Exec=$APP_BIN_NAME
34+
Icon=
35+
Type=Application
36+
Categories=Utility;Education;
37+
Terminal=false
38+
EOF
39+
40+
# control file
41+
cat > "$WORK/DEBIAN/control" <<EOF
42+
Package: ${APP_BIN_NAME}
43+
Version: ${VERSION}
44+
Section: utils
45+
Priority: optional
46+
Architecture: amd64
47+
Maintainer: Asante <noreply@example.com>
48+
Description: $APP_NAME - typing tutor
49+
A Flutter-based typing tutor.
50+
EOF
51+
52+
mkdir -p "$DEB_OUT"
53+
dpkg-deb --build "$WORK" "${DEB_OUT}/${APP_BIN_NAME}_${VERSION}_amd64.deb"
54+
echo "Built ${DEB_OUT}/${APP_BIN_NAME}_${VERSION}_amd64.deb"

scripts/package_dmg.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
VERSION="${1:-0.0.0}"
5+
APP_NAME="Asante Typing"
6+
APP_PATH="build/macos/Build/Products/Release/${APP_NAME}.app"
7+
OUT_DIR="dist/macos"
8+
DMG="${OUT_DIR}/asante-typing-macos-${VERSION}.dmg"
9+
10+
mkdir -p "$OUT_DIR"
11+
12+
if [[ ! -d "$APP_PATH" ]]; then
13+
echo "App not found: $APP_PATH" >&2
14+
exit 1
15+
fi
16+
17+
create-dmg \
18+
--volname "${APP_NAME}" \
19+
--window-pos 200 120 \
20+
--window-size 540 380 \
21+
--icon-size 96 \
22+
--app-drop-link 380 205 \
23+
--icon "${APP_NAME}.app" 140 205 \
24+
"$DMG" \
25+
"$(dirname "$APP_PATH")"
26+
27+
echo "Built $DMG"

0 commit comments

Comments
 (0)