Release #140
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: Release | |
on: | |
workflow_dispatch: | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
ANDROID_NDK_VERSION: '27.0.12077973' | |
jobs: | |
ci-pass: | |
name: CI is green | |
runs-on: ubuntu-latest | |
needs: | |
- check_release | |
- build_release_assets | |
- send_to_community | |
steps: | |
- run: exit 0 | |
check_release: | |
name: Check release | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
repository: ${{ github.event.inputs.repo }} | |
ref: 'master' | |
- uses: actions/setup-go@v2 | |
with: | |
go-version: ${{ env.go_version }} | |
- name: Cache go modules | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ubuntu-latest-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
ubuntu-latest-go- | |
- name: Check release | |
run: | | |
cd ci | |
go run ./cmd/check_release | |
build_release_assets: | |
name: Build release assets | |
needs: | |
- check_release | |
strategy: | |
fail-fast: false | |
matrix: | |
sources: | |
- branch: master | |
config: | |
- target: windows | |
host: windows-latest | |
flutter_version: '2.10.3' | |
go_version: '1.17' | |
- target: macos | |
host: macos-latest | |
flutter_version: '2.10.3' | |
go_version: '1.17' | |
- target: linux | |
host: ubuntu-latest | |
flutter_version: '2.10.3' | |
go_version: '1.17' | |
- target: ios | |
host: macos-12 | |
flutter_version: '2.10.5' | |
go_version: '1.19' | |
- target: ios | |
host: macos-latest | |
flutter_version: '3.7.3' | |
go_version: '1.19' | |
- target: android-arm32 | |
host: ubuntu-latest | |
flutter_version: '2.10.5' | |
go_version: '1.19' | |
- target: android-arm64 | |
host: ubuntu-latest | |
flutter_version: '2.10.5' | |
go_version: '1.19' | |
- target: android-x86_64 | |
host: ubuntu-latest | |
flutter_version: '2.10.5' | |
go_version: '1.19' | |
- target: android-arm32 | |
host: ubuntu-latest | |
flutter_version: '3.7.3' | |
go_version: '1.19' | |
- target: android-arm64 | |
host: ubuntu-latest | |
flutter_version: '3.7.3' | |
go_version: '1.19' | |
- target: android-x86_64 | |
host: ubuntu-latest | |
flutter_version: '3.7.3' | |
go_version: '1.19' | |
- target: ios | |
host: macos-latest | |
flutter_version: '3.22.3' | |
go_version: '1.19' | |
- target: android-arm64 | |
host: ubuntu-latest | |
flutter_version: '3.22.3' | |
go_version: '1.19' | |
runs-on: ${{ matrix.config.host }} | |
env: | |
TARGET: ${{ matrix.config.target }} | |
FLUTTER_VERSION: ${{ matrix.config.flutter_version }} | |
BRANCH: ${{ matrix.sources.branch }} | |
go_version: ${{ matrix.config.go_version }} | |
steps: | |
# Setup golang env and cache go module | |
- name: Setup golang | |
uses: actions/setup-go@v2 | |
with: | |
go-version: ${{ env.go_version }} | |
- name: Cache go modules (Windows) | |
if: matrix.config.host == 'windows-latest' | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~\AppData\Local\go-build | |
~\go\pkg\mod | |
key: ${{ matrix.config.host }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ matrix.config.host }}-go- | |
- name: Cache go modules (Linux) | |
if: matrix.config.host == 'ubuntu-latest' | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ matrix.config.host }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ matrix.config.host }}-go- | |
- name: Cache go modules (macOS) | |
if: matrix.config.host == 'macos-latest' | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/Library/Caches/go-build | |
~/go/pkg/mod | |
key: ${{ matrix.config.host }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ matrix.config.host }}-go- | |
# checkout | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ env.BRANCH }} | |
# check_access | |
- id: check_asset | |
name: Check asset | |
run: | | |
cd ci | |
go run ./cmd/check_asset | |
# | |
- name: Setup flutter | |
if: steps.check_asset.outputs.skip_build != 'true' | |
uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: ${{ env.FLUTTER_VERSION }} | |
architecture: x64 | |
- name: Check core | |
if: steps.check_asset.outputs.skip_build != 'true' | |
uses: actions/checkout@v3 | |
with: | |
repository: 'niuhuan/pikapika-go-core' | |
token: ${{ secrets.GH_TOKEN }} | |
path: 'go' | |
- name: Cache Flutter dependencies (Linux/Android) | |
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'android-arm32' || matrix.config.target == 'android-arm64' || matrix.config.target == 'android-x86_64' || matrix.config.target == 'linux' ) | |
uses: actions/cache@v3 | |
with: | |
path: /opt/hostedtoolcache/flutter | |
key: ${{ runner.os }}-flutter | |
- name: Cache Flutter dependencies (Mac host) | |
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'ios' || matrix.config.target == 'macos' ) | |
uses: actions/cache@v3 | |
with: | |
path: /Users/runner/hostedtoolcache/flutter | |
key: ${{ runner.os }}-flutter | |
- name: Cache Gradle dependencies (Android) | |
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'android-arm32' || matrix.config.target == 'android-arm64' || matrix.config.target == 'android-x86_64' ) | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Setup java (Android) | |
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'android-arm32' || matrix.config.target == 'android-arm64' || matrix.config.target == 'android-x86_64' ) && startsWith(matrix.config.flutter_version, '3.22.3') == false | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
- name: Setup java (Android) | |
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'android-arm32' || matrix.config.target == 'android-arm64' || matrix.config.target == 'android-x86_64' ) && startsWith(matrix.config.flutter_version, '3.22.3') | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Setup android tools (Android) | |
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'android-arm32' || matrix.config.target == 'android-arm64' || matrix.config.target == 'android-x86_64' ) | |
uses: android-actions/setup-android@v3 | |
with: | |
cmdline-tools-version: 8512546 | |
packages: 'platform-tools platforms;android-32 build-tools;30.0.2 ndk;${{ env.ANDROID_NDK_VERSION }}' | |
- name: Setup msys2 (Windows) | |
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.target == 'windows' | |
uses: msys2/setup-msys2@v2 | |
with: | |
install: gcc make | |
- name: Install dependencies (Linux) | |
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.target == 'linux' | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' | |
run: | | |
curl -JOL https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage | |
chmod a+x appimagetool-x86_64.AppImage | |
mkdir -p ${GITHUB_WORKSPACE}/bin | |
mv appimagetool-x86_64.AppImage ${GITHUB_WORKSPACE}/bin/appimagetool | |
echo ::add-path::${GITHUB_WORKSPACE}/bin | |
sudo apt-get update | |
sudo apt-get install -y libgl1-mesa-dev xorg-dev libfuse2 | |
- name: Install hover (desktop) | |
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'linux' || matrix.config.target == 'windows' || matrix.config.target == 'macos') | |
run: | | |
go install github.com/go-flutter-desktop/hover@latest | |
- name: Install go mobile (mobile) | |
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'ios' || matrix.config.target == 'android-arm64' || matrix.config.target == 'android-arm32' || matrix.config.target == 'android-x86_64' ) | |
run: | | |
go install golang.org/x/mobile/cmd/gomobile@latest | |
- name: Set-Version (All) | |
if: steps.check_asset.outputs.skip_build != 'true' | |
run: | | |
cd ci | |
cp version.code.txt ../lib/assets/version.txt | |
- name: Upgrade deps version (flutter2 non-mac) | |
if: steps.check_asset.outputs.skip_build != 'true' && startsWith(matrix.config.host, 'macos-') == false && startsWith(matrix.config.flutter_version, '2') | |
run: | | |
sed -i "s/another_xlider: ^1.0.1+2/another_xlider: 1.0.1+2/g" pubspec.yaml | |
sed -i "s/flutter_styled_toast: ^2.0.0/flutter_styled_toast: 2.0.0/g" pubspec.yaml | |
sed -i "s/filesystem_picker: ^3.0.0-beta.1/filesystem_picker: 2.0.0/g" pubspec.yaml | |
sed -i "s/file_picker: ^5.2.1/file_picker: 4.6.1/g" pubspec.yaml | |
sed -i "s/multi_select_flutter: ^4.0.0/multi_select_flutter: 4.1.2/g" pubspec.yaml | |
sed -i "s/modal_bottom_sheet: ^3.0.0-pre/modal_bottom_sheet: 2.0.1/g" pubspec.yaml | |
sed -i "s/Icons.energy_savings_leaf/Icons.ad_units/g" lib/screens/SettingsScreen.dart | |
flutter pub get | |
- name: Upgrade deps version (flutter2 mac) | |
if: steps.check_asset.outputs.skip_build != 'true' && startsWith(matrix.config.host, 'macos-') && startsWith(matrix.config.flutter_version, '2') | |
run: | | |
brew install gnu-sed | |
gsed -i "s/another_xlider: ^1.0.1+2/another_xlider: 1.0.1+2/g" pubspec.yaml | |
gsed -i "s/flutter_styled_toast: ^2.0.0/flutter_styled_toast: 2.0.0/g" pubspec.yaml | |
gsed -i "s/filesystem_picker: ^3.0.0-beta.1/filesystem_picker: 2.0.0/g" pubspec.yaml | |
gsed -i "s/file_picker: ^5.2.1/file_picker: 4.6.1/g" pubspec.yaml | |
gsed -i "s/multi_select_flutter: ^4.0.0/multi_select_flutter: 4.1.2/g" pubspec.yaml | |
gsed -i "s/modal_bottom_sheet: ^3.0.0-pre/modal_bottom_sheet: 2.0.1/g" pubspec.yaml | |
gsed -i "s/Icons.energy_savings_leaf/Icons.ad_units/g" lib/screens/SettingsScreen.dart | |
flutter pub get | |
- name: Upgrade deps version (flutter3 non-mac) | |
if: steps.check_asset.outputs.skip_build != 'true' && startsWith(matrix.config.host, 'macos-') == false && startsWith(matrix.config.flutter_version, '3.22.3') | |
run: | | |
sed -i "s/flutter_datetime_picker: ^1.5.1/flutter_datetime_picker_plus: ^2.2.0/g" pubspec.yaml | |
sed -i "s/filesystem_picker: ^3.0.0-beta.1/filesystem_picker: ^4.1.0/g" pubspec.yaml | |
sed -i "s/flutter_styled_toast: ^2.0.0/flutter_styled_toast: ^2.2.1/g" pubspec.yaml | |
sed -i "s/intl: ^0.17.0/intl: ^0.19.0/g" pubspec.yaml | |
sed -i "s/flutter_datetime_picker/flutter_datetime_picker_plus/g" lib/screens/RegisterScreen.dart | |
sed -i "s/file_picker: ^5.2.1/file_picker: ^8.1.2/g" pubspec.yaml | |
sed -i "s/photo_view: ^0.13.0/photo_view: ^0.15.0/g" pubspec.yaml | |
sed -i "s/dividerColor: Colors.grey.shade200/DividerThemeData(color: Colors.grey.shade200)/g" lib/basic/config/Themes.dart | |
sed -i "s/AppBarTheme(/AppBarTheme(titleTextStyle: const TextStyle(color: Colors.white),/g" lib/basic/config/Themes.dart | |
find lib -type f -name "*.dart" -exec sed -i "s/.headline4/.headlineMedium/g" {} \; | |
find lib -type f -name "*.dart" -exec sed -i "s/.bodyText1/.bodyMedium/g" {} \; | |
find lib -type f -name "*.dart" -exec sed -i "s/ImageStreamCompleter load(/ImageStreamCompleter loadImage(/g" {} \; | |
find lib -type f -name "*.dart" -exec sed -i "s/DecoderCallback decode/ImageDecoderCallback decode/g" {} \; | |
find lib -type f -name "*.dart" -exec sed -i "s/PaintingBinding.instance\!.instantiateImageCodec/ui.instantiateImageCodec/g" {} \; | |
find lib -type f -name "*.dart" -exec sed -i "s/as ui show Codec/as ui/g" {} \; | |
flutter pub upgrade | |
flutter pub get | |
cp -rf compatible/* ./ | |
- name: Upgrade deps version (flutter3 mac) | |
if: steps.check_asset.outputs.skip_build != 'true' && startsWith(matrix.config.host, 'macos-') && startsWith(matrix.config.flutter_version, '3.22.3') | |
run: | | |
brew install gnu-sed | |
gsed -i "s/flutter_datetime_picker: ^1.5.1/flutter_datetime_picker_plus: ^2.2.0/g" pubspec.yaml | |
gsed -i "s/intl: ^0.17.0/intl: ^0.19.0/g" pubspec.yaml | |
gsed -i "s/filesystem_picker: ^3.0.0-beta.1/filesystem_picker: ^4.1.0/g" pubspec.yaml | |
gsed -i "s/flutter_styled_toast: ^2.0.0/flutter_styled_toast: ^2.2.1/g" pubspec.yaml | |
gsed -i "s/intl: ^0.17.0/intl: ^0.19.0/g" pubspec.yaml | |
gsed -i "s/flutter_datetime_picker/flutter_datetime_picker_plus/g" lib/screens/RegisterScreen.dart | |
gsed -i "s/file_picker: ^5.2.1/file_picker: ^8.1.2/g" pubspec.yaml | |
gsed -i "s/photo_view: ^0.13.0/photo_view: ^0.15.0/g" pubspec.yaml | |
gsed -i "s/dividerColor: Colors.grey.shade200/DividerThemeData(color: Colors.grey.shade200)/g" lib/basic/config/Themes.dart | |
gsed -i "s/AppBarTheme(/AppBarTheme(titleTextStyle: const TextStyle(color: Colors.white),/g" lib/basic/config/Themes.dart | |
find lib -type f -name "*.dart" -exec gsed -i "s/.headline4/.headlineMedium/g" {} \; | |
find lib -type f -name "*.dart" -exec gsed -i "s/.bodyText1/.bodyMedium/g" {} \; | |
find lib -type f -name "*.dart" -exec gsed -i "s/ImageStreamCompleter load(/ImageStreamCompleter loadImage(/g" {} \; | |
find lib -type f -name "*.dart" -exec gsed -i "s/DecoderCallback decode/ImageDecoderCallback decode/g" {} \; | |
find lib -type f -name "*.dart" -exec gsed -i "s/PaintingBinding.instance\!.instantiateImageCodec/ui.instantiateImageCodec/g" {} \; | |
find lib -type f -name "*.dart" -exec gsed -i "s/as ui show Codec/as ui/g" {} \; | |
flutter pub upgrade | |
flutter pub get | |
- name: Build (windows) | |
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.target == 'windows' | |
run: | | |
hover build windows | |
curl -JOL https://github.com/niuhuan/static-resources/releases/download/windows_build_tools/Resource_Hacker_5.1.8.zip | |
Expand-Archive .\Resource_Hacker_5.1.8.zip | |
cmd /c "Resource_Hacker_5.1.8\ResourceHacker.exe" -open go\build\outputs\windows-release\pikapika.exe -save go\build\outputs\windows-release\pikapika.exe -action addskip -res go/assets/icon.ico -mask ICONGROUP,MAINICON,0 | |
cd go\build\outputs\windows-release | |
DEL flutter_engine.pdb | |
DEL flutter_engine.exp | |
DEL flutter_engine.lib | |
Compress-Archive * ../../../../build/build.zip | |
- name: Build (macos) | |
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.target == 'macos' | |
run: | | |
hover build darwin-dmg | |
mv go/build/outputs/darwin-dmg-release/*.dmg build/build.dmg | |
- name: Build (linux) | |
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.target == 'linux' | |
run: | | |
curl -JOL https://github.com/junmer/source-han-serif-ttf/raw/master/SubsetTTF/CN/SourceHanSerifCN-Regular.ttf | |
mkdir -p fonts | |
mv SourceHanSerifCN-Regular.ttf fonts/Roboto.ttf | |
cat ci/linux_font.yaml >> pubspec.yaml | |
hover build linux-appimage | |
mv go/build/outputs/linux-appimage-release/*.AppImage build/build.AppImage | |
- name: Append application-identifier (ios) | |
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.target == 'ios' | |
run: | | |
/usr/libexec/PlistBuddy -c 'Add :application-identifier string opensource.pikapika' ios/Runner/Info.plist | |
- name: Build (ios) | |
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.target == 'ios' | |
run: | | |
sh scripts/build-ipa.sh | |
- name: Build (android-arm32) | |
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.target == 'android-arm32' | |
run: | | |
sh scripts/build-apk-arm.sh | |
- name: Build (android-arm64) | |
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.target == 'android-arm64' | |
run: | | |
sh scripts/build-apk-arm64.sh | |
- name: Build (android-x86_64) | |
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.target == 'android-x86_64' | |
run: | | |
sh scripts/build-apk-x64.sh | |
- name: Sign APK (Android) | |
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'android-arm32' || matrix.config.target == 'android-arm64' || matrix.config.target == 'android-x86_64' ) | |
env: | |
KEY_FILE_BASE64: ${{ secrets.KEY_FILE_BASE64 }} | |
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
run: | | |
sh scripts/sign-apk-github-actions.sh | |
- name: Upload Asset (All) | |
if: steps.check_asset.outputs.skip_build != 'true' | |
run: | | |
cd ci | |
go run ./cmd/upload_asset | |
send_to_community: | |
needs: | |
- check_release | |
- build_release_assets | |
name: Send message to community | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
repository: ${{ github.event.inputs.repo }} | |
ref: 'master' | |
- uses: actions/setup-go@v2 | |
with: | |
go-version: ${{ env.go_version }} | |
- name: Cache go modules | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Send to community | |
env: | |
TG_BOT_TOKEN: ${{ secrets.TG_BOT_TOKEN }} | |
TG_CHAT_IDS: ${{ secrets.TG_CHAT_IDS }} | |
DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_BOT_TOKEN }} | |
DISCORD_CHAT_IDS: ${{ secrets.DISCORD_CHAT_IDS }} | |
run: | | |
cd ci | |
go run ./cmd/send_to_community | |