pikapika/.github/workflows/Release.yml

386 lines
14 KiB
YAML
Raw Normal View History

2022-03-22 09:12:48 +00:00
name: Release
on:
workflow_dispatch:
env:
2023-07-07 06:27:02 +00:00
GH_TOKEN: ${{ secrets.GH_TOKEN }}
2022-03-22 09:12:48 +00:00
jobs:
ci-pass:
name: CI is green
2023-07-09 23:16:43 +00:00
runs-on: ubuntu-latest
2022-03-22 09:12:48 +00:00
needs:
- check_release
- build_release_assets
- send_to_community
2022-03-22 09:12:48 +00:00
steps:
- run: exit 0
check_release:
name: Check release
2023-07-09 23:16:43 +00:00
runs-on: ubuntu-latest
2022-03-22 09:12:48 +00:00
steps:
- uses: actions/checkout@v3
with:
repository: ${{ github.event.inputs.repo }}
ref: 'master'
- uses: actions/setup-go@v2
with:
go-version: ${{ env.go_version }}
2022-04-18 02:55:08 +00:00
- name: Cache go modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
2023-07-09 23:16:43 +00:00
key: ubuntu-latest-go-${{ hashFiles('**/go.sum') }}
2022-04-18 02:55:08 +00:00
restore-keys: |
2023-07-09 23:16:43 +00:00
ubuntu-latest-go-
2022-03-22 09:12:48 +00:00
- 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:
2023-07-07 06:27:02 +00:00
sources:
- branch: master
2022-03-22 09:12:48 +00:00
config:
- target: windows
2023-07-09 23:16:43 +00:00
host: windows-latest
2022-05-18 03:57:38 +00:00
flutter_version: '2.10.3'
go_version: '1.17'
2022-03-22 09:12:48 +00:00
- target: macos
2023-07-09 23:16:43 +00:00
host: macos-latest
2022-05-18 03:57:38 +00:00
flutter_version: '2.10.3'
go_version: '1.17'
2022-10-27 07:21:46 +00:00
- target: linux
2023-07-09 23:16:43 +00:00
host: ubuntu-latest
2022-10-27 07:21:46 +00:00
flutter_version: '2.10.3'
go_version: '1.17'
2023-11-17 02:09:16 +00:00
- target: ios
host: macos-latest
flutter_version: '2.10.5'
go_version: '1.18'
2022-03-22 09:12:48 +00:00
- target: ios
2023-07-09 23:16:43 +00:00
host: macos-latest
2023-02-11 01:26:33 +00:00
flutter_version: '3.7.3'
go_version: '1.18'
2022-03-22 09:12:48 +00:00
- target: android-arm32
2023-07-09 23:16:43 +00:00
host: ubuntu-latest
2022-07-05 13:26:56 +00:00
flutter_version: '2.10.5'
go_version: '1.18'
2022-03-22 09:12:48 +00:00
- target: android-arm64
2023-07-09 23:16:43 +00:00
host: ubuntu-latest
2022-07-05 13:26:56 +00:00
flutter_version: '2.10.5'
go_version: '1.18'
2022-03-22 09:12:48 +00:00
- target: android-x86_64
2023-07-09 23:16:43 +00:00
host: ubuntu-latest
2022-07-05 13:26:56 +00:00
flutter_version: '2.10.5'
go_version: '1.18'
2022-05-18 03:49:21 +00:00
- target: android-arm32
2023-07-09 23:16:43 +00:00
host: ubuntu-latest
2023-02-11 01:26:33 +00:00
flutter_version: '3.7.3'
go_version: '1.18'
2022-05-18 03:49:21 +00:00
- target: android-arm64
2023-07-09 23:16:43 +00:00
host: ubuntu-latest
2023-02-11 01:26:33 +00:00
flutter_version: '3.7.3'
go_version: '1.18'
2022-05-18 03:49:21 +00:00
- target: android-x86_64
2023-07-09 23:16:43 +00:00
host: ubuntu-latest
2023-02-11 01:26:33 +00:00
flutter_version: '3.7.3'
go_version: '1.18'
2022-03-22 09:12:48 +00:00
runs-on: ${{ matrix.config.host }}
env:
TARGET: ${{ matrix.config.target }}
2023-07-07 06:27:02 +00:00
FLUTTER_VERSION: ${{ matrix.config.flutter_version }}
BRANCH: ${{ matrix.sources.branch }}
go_version: ${{ matrix.config.go_version }}
2022-03-22 09:12:48 +00:00
steps:
2023-07-07 06:27:02 +00:00
# Setup golang env and cache go module
2022-03-22 09:12:48 +00:00
- name: Setup golang
uses: actions/setup-go@v2
with:
go-version: ${{ env.go_version }}
2023-07-07 06:27:02 +00:00
- name: Cache go modules (Windows)
2023-07-09 23:19:04 +00:00
if: matrix.config.host == 'windows-latest'
2022-04-18 02:55:08 +00:00
uses: actions/cache@v3
with:
path: |
2023-07-07 06:27:02 +00:00
~\AppData\Local\go-build
~\go\pkg\mod
key: ${{ matrix.config.host }}-go-${{ hashFiles('**/go.sum') }}
2022-04-18 02:55:08 +00:00
restore-keys: |
2023-07-07 06:27:02 +00:00
${{ matrix.config.host }}-go-
2022-04-18 02:55:08 +00:00
2023-07-07 06:27:02 +00:00
- name: Cache go modules (Linux)
2023-07-09 23:19:04 +00:00
if: matrix.config.host == 'ubuntu-latest'
2022-04-18 02:55:08 +00:00
uses: actions/cache@v3
with:
path: |
2023-07-07 06:27:02 +00:00
~/.cache/go-build
2022-04-18 02:55:08 +00:00
~/go/pkg/mod
2023-07-07 06:27:02 +00:00
key: ${{ matrix.config.host }}-go-${{ hashFiles('**/go.sum') }}
2022-04-18 02:55:08 +00:00
restore-keys: |
2023-07-07 06:27:02 +00:00
${{ matrix.config.host }}-go-
2022-04-18 02:55:08 +00:00
2023-07-07 06:27:02 +00:00
- name: Cache go modules (macOS)
2023-07-09 23:19:04 +00:00
if: matrix.config.host == 'macos-latest'
2022-04-18 02:55:08 +00:00
uses: actions/cache@v3
with:
path: |
2023-07-07 06:27:02 +00:00
~/Library/Caches/go-build
~/go/pkg/mod
key: ${{ matrix.config.host }}-go-${{ hashFiles('**/go.sum') }}
2022-04-18 02:55:08 +00:00
restore-keys: |
2023-07-07 06:27:02 +00:00
${{ matrix.config.host }}-go-
# checkout
- name: Checkout
uses: actions/checkout@v3
with:
2023-07-09 23:16:43 +00:00
ref: ${{ env.BRANCH }}
2023-07-07 06:27:02 +00:00
# check_access
2022-04-18 02:55:08 +00:00
2022-03-22 09:12:48 +00:00
- id: check_asset
name: Check asset
run: |
cd ci
go run ./cmd/check_asset
2023-07-07 06:27:02 +00:00
#
2022-03-22 09:12:48 +00:00
- name: Setup flutter
if: steps.check_asset.outputs.skip_build != 'true'
2022-07-25 04:49:24 +00:00
uses: subosito/flutter-action@v2
2022-03-22 09:12:48 +00:00
with:
2023-07-10 00:42:26 +00:00
flutter-version: ${{ env.FLUTTER_VERSION }}
2022-07-25 04:23:31 +00:00
architecture: x64
2022-03-22 09:12:48 +00:00
2022-04-18 02:55:08 +00:00
- name: Check core
2022-05-18 03:57:38 +00:00
if: steps.check_asset.outputs.skip_build != 'true'
2022-04-18 02:55:08 +00:00
uses: actions/checkout@v3
2022-04-18 04:30:45 +00:00
with:
repository: 'niuhuan/pikapika-go-core'
token: ${{ secrets.GH_TOKEN }}
path: 'go'
2022-04-18 02:55:08 +00:00
- 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
2022-09-05 03:36:25 +00:00
- 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-
2022-03-22 09:12:48 +00:00
- 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' )
uses: actions/setup-java@v3
with:
2024-04-02 10:41:48 +00:00
java-version: '11'
distribution: 'temurin'
2022-03-22 09:12:48 +00:00
- 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
2022-03-22 09:12:48 +00:00
with:
2024-04-02 10:41:48 +00:00
cmdline-tools-version: 8512546
2024-04-02 07:14:43 +00:00
packages: 'platform-tools platforms;android-32 build-tools;30.0.2 ndk;23.1.7779620'
2022-03-22 09:12:48 +00:00
- 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
2022-10-27 07:21:46 +00:00
sudo apt-get install -y libgl1-mesa-dev xorg-dev libfuse2
2022-03-22 09:12:48 +00:00
- 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
2022-07-01 07:08:28 +00:00
- name: Upgrade deps version (flutter2 non-mac)
2023-07-09 23:16:43 +00:00
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.host != 'macos-latest' && startsWith(matrix.config.flutter_version, '2')
2022-06-03 06:58:25 +00:00
run: |
2022-07-01 07:08:28 +00:00
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
2022-07-01 08:34:19 +00:00
sed -i "s/filesystem_picker: ^3.0.0-beta.1/filesystem_picker: 2.0.0/g" pubspec.yaml
2022-10-14 15:38:09 +00:00
sed -i "s/file_picker: ^5.2.1/file_picker: 4.6.1/g" pubspec.yaml
2022-10-27 07:21:46 +00:00
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
2022-07-01 07:08:28 +00:00
flutter pub get
2022-06-03 06:58:25 +00:00
2022-07-01 07:08:28 +00:00
- name: Upgrade deps version (flutter2 mac)
2023-07-09 23:16:43 +00:00
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.host == 'macos-latest' && startsWith(matrix.config.flutter_version, '2')
2022-06-03 06:58:25 +00:00
run: |
brew install gnu-sed
2022-07-01 07:08:28 +00:00
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
2022-07-01 08:34:19 +00:00
gsed -i "s/filesystem_picker: ^3.0.0-beta.1/filesystem_picker: 2.0.0/g" pubspec.yaml
2022-10-14 15:38:09 +00:00
gsed -i "s/file_picker: ^5.2.1/file_picker: 4.6.1/g" pubspec.yaml
2022-10-27 07:21:46 +00:00
gsed -i "s/multi_select_flutter: ^4.0.0/multi_select_flutter: 4.1.2/g" pubspec.yaml
2023-01-21 16:38:09 +00:00
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
2022-07-01 07:08:28 +00:00
flutter pub get
2022-06-03 06:58:25 +00:00
2022-03-22 09:12:48 +00:00
- name: Build (windows)
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.target == 'windows'
run: |
hover build windows
2022-06-17 11:25:15 +00:00
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
2022-03-22 09:12:48 +00:00
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
2022-07-25 03:22:07 +00:00
- name: Append application-identifier (ios)
2022-03-22 09:12:48 +00:00
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.target == 'ios'
run: |
/usr/libexec/PlistBuddy -c 'Add :application-identifier string niuhuan.pikapika' ios/Runner/Info.plist
2022-07-25 03:22:07 +00:00
- name: Build (ios)
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.target == 'ios'
run: |
2022-03-22 09:12:48 +00:00
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' )
2022-04-18 04:30:45 +00:00
env:
KEY_FILE_BASE64: ${{ secrets.KEY_FILE_BASE64 }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: |
sh scripts/sign-apk-github-actions.sh
2022-03-22 09:12:48 +00:00
- name: Upload Asset (All)
if: steps.check_asset.outputs.skip_build != 'true'
run: |
cd ci
go run ./cmd/upload_asset
send_to_community:
2022-06-03 06:58:25 +00:00
needs:
- check_release
- build_release_assets
name: Send message to community
2023-07-09 23:16:43 +00:00
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