297 lines
9.9 KiB
YAML
297 lines
9.9 KiB
YAML
name: Build
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- "v*"
|
|
paths-ignore:
|
|
- "**.md"
|
|
- "docs/**"
|
|
- ".github/**"
|
|
- "!.github/workflows/build.yml"
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
concurrency:
|
|
group: ${{ github.ref }}-${{ github.workflow }}
|
|
cancel-in-progress: true
|
|
env:
|
|
CHANNEL: ${{ github.ref_type == 'tag' && endsWith(github.ref_name, 'dev') && 'dev' || github.ref_type != 'tag' && 'dev' || 'prod' }}
|
|
jobs:
|
|
build:
|
|
permissions: write-all
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- platform: android-apk
|
|
os: ubuntu-latest
|
|
targets: apk
|
|
|
|
- platform: android-aab
|
|
os: ubuntu-latest
|
|
targets: aab
|
|
|
|
- platform: windows
|
|
os: windows-latest
|
|
aarch: amd64
|
|
targets: exe
|
|
|
|
- platform: linux
|
|
os: ubuntu-latest
|
|
aarch: amd64
|
|
targets: AppImage
|
|
|
|
- platform: macos
|
|
os: macos-13
|
|
aarch: universal
|
|
targets: dmg
|
|
|
|
# - platform: ios
|
|
# os: macos-11
|
|
# aarch: universal
|
|
# targets: ipa
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- name: checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup Flutter
|
|
uses: subosito/flutter-action@v2
|
|
with:
|
|
flutter-version: "3.13.x"
|
|
channel: "stable"
|
|
cache: true
|
|
|
|
- name: Setup Java
|
|
if: startsWith(matrix.platform,'android')
|
|
uses: actions/setup-java@v3
|
|
with:
|
|
distribution: "zulu"
|
|
java-version: 11
|
|
|
|
- name: Setup Flutter Distributor
|
|
if: ${{ !startsWith(matrix.platform,'android') }}
|
|
run: |
|
|
dart pub global activate flutter_distributor
|
|
|
|
- name: Setup Linux dependencies
|
|
if: matrix.platform == 'linux'
|
|
run: |
|
|
sudo apt install -y locate ninja-build pkg-config libgtk-3-dev libglib2.0-dev libgio2.0-cil-dev libayatana-appindicator3-dev fuse
|
|
sudo modprobe fuse
|
|
wget -O appimagetool "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"
|
|
chmod +x appimagetool
|
|
mv appimagetool /usr/local/bin/
|
|
|
|
- name: Build macos dmg
|
|
if: matrix.platform == 'macos' || matrix.platform == 'ios'
|
|
run: |
|
|
brew install create-dmg tree node
|
|
npm install -g appdmg
|
|
|
|
- name: Get Geo Assets
|
|
run: |
|
|
make get-geo-assets
|
|
|
|
- name: Get Dependencies
|
|
run: |
|
|
make get
|
|
|
|
- name: Generate
|
|
run: |
|
|
make translate
|
|
make gen
|
|
|
|
- name: Get Libs ${{ matrix.platform }}
|
|
run: |
|
|
make ${{ matrix.platform }}-libs
|
|
|
|
- name: Setup Signing Properties
|
|
if: startsWith(matrix.platform,'android')
|
|
env:
|
|
ANDROID_SIGNING_KEY_ALIAS: ${{ secrets.ANDROID_SIGNING_KEY_ALIAS }}
|
|
ANDROID_SIGNING_KEY_PASSWORD: ${{ secrets.ANDROID_SIGNING_KEY_PASSWORD }}
|
|
ANDROID_SIGNING_STORE_PASSWORD: ${{ secrets.ANDROID_SIGNING_STORE_PASSWORD }}
|
|
ANDROID_SIGNING_KEY: ${{ secrets.ANDROID_SIGNING_KEY }}
|
|
run: |
|
|
cd android
|
|
pwd
|
|
touch signing.properties
|
|
echo $ANDROID_SIGNING_KEY | base64 -d > release.keystore
|
|
echo "keystore.path=release.keystore" > release.properties
|
|
echo keystore.password="$ANDROID_SIGNING_STORE_PASSWORD" >> release.properties
|
|
echo key.alias="$ANDROID_SIGNING_KEY_ALIAS" >> release.properties
|
|
echo key.password="$ANDROID_SIGNING_KEY_PASSWORD" >> release.properties
|
|
cp release.* app/
|
|
cat release.properties
|
|
cd ..
|
|
|
|
- name: Release ${{ matrix.platform }}
|
|
env:
|
|
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
|
|
run: |
|
|
make ${{ matrix.platform }}-release
|
|
|
|
- name: Upload Debug Symbols
|
|
if: ${{ github.ref_type == 'tag' }}
|
|
env:
|
|
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
|
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
|
|
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
|
|
SENTRY_DIST: ${{ matrix.platform == 'android-aab' && 'google-play' || 'general' }}
|
|
run: |
|
|
flutter packages pub run sentry_dart_plugin
|
|
|
|
- name: Copy to out Windows
|
|
if: matrix.platform == 'windows'
|
|
run: |
|
|
New-Item -ItemType Directory -Force -Name "out"
|
|
New-Item -ItemType Directory -Force -Name "tmp_out"
|
|
$EXT_ARRAY = "${{ matrix.targets }}" -split ","
|
|
foreach ($EXT in $EXT_ARRAY) {
|
|
# Find all files with this extension in the current directory, and copy them to "out" directory
|
|
Get-ChildItem -Recurse -File -Filter "*setup.$EXT" | Copy-Item -Destination "out" -ErrorAction SilentlyContinue
|
|
move out\*setup.$EXT tmp_out\setup.$EXT
|
|
Get-ChildItem -Recurse -File -Filter "*.$EXT"
|
|
}
|
|
|
|
xcopy /s /v '.\.github\help\mac-windows\' .\hiddify-${{ matrix.platform }}-x64-setup\
|
|
cd tmp_out
|
|
Compress-Archive .\ ..\out\hiddify-${{ matrix.platform }}-x64-setup.zip
|
|
cd ..
|
|
|
|
|
|
mkdir HiddifyNext-portable
|
|
xcopy /s /v D:\a\hiddify-next\hiddify-next\build\windows\runner\Release\ .\HiddifyNext-portable\
|
|
xcopy /s /v '.\.github\help\mac-windows\' .\HiddifyNext-portable\
|
|
cd HiddifyNext-portable
|
|
Compress-Archive .\ ..\out\hiddify-${{ matrix.platform }}-x64-portable.zip
|
|
|
|
- name: Copy to out Android apk
|
|
if: matrix.platform == 'android-apk'
|
|
run: |
|
|
mkdir out
|
|
ls -R ./build/app/outputs
|
|
mv ./build/app/outputs/flutter-apk/*arm64-v8a*.apk out/hiddify-android-arm64.apk || echo "no arm64 apk"
|
|
mv ./build/app/outputs/flutter-apk/*armeabi-v7a*.apk out/hiddify-android-arm7.apk || echo "no arm7 apk"
|
|
mv ./build/app/outputs/flutter-apk/*x86_64*.apk out/hiddify-android-x86_64.apk || echo "no x64 apk"
|
|
mv ./build/app/outputs/flutter-apk/app-release.apk out/hiddify-android-universal.apk || echo "no universal apk"
|
|
|
|
- name: Copy to out Android aab
|
|
if: matrix.platform == 'android-aab'
|
|
run: |
|
|
mkdir out
|
|
ls -R ./build/app/outputs
|
|
cp ./build/app/outputs/bundle/release/app-release.aab out/hiddify-android-market.aab || echo "no aab"
|
|
|
|
- name: Copy to out unix
|
|
if: matrix.platform == 'linux' || matrix.platform == 'macos' || matrix.platform == 'ios'
|
|
run: |
|
|
ls -R
|
|
mkdir out
|
|
mkdir tmp_out
|
|
IFS=',' read -r -a EXT_ARRAY <<< "${{ matrix.targets }}"
|
|
# Loop over extensions
|
|
for EXT in "${EXT_ARRAY[@]}"; do
|
|
# Find all files with this extension in SRC_DIR, and copy them to DST_DIR
|
|
find "." -type f -name "*.$EXT" -exec cp {} "tmp_out" \;
|
|
done
|
|
|
|
mv tmp_out/*.AppImage tmp_out/hiddify-linux-x64.AppImage &&\
|
|
chmod +x tmp_out/hiddify-linux-x64.AppImage &&\
|
|
cp ./.github/help/linux/* tmp_out/ \
|
|
||echo "no app image"
|
|
mv tmp_out/*.dmg tmp_out/hiddify-macos-universal.dmg && \
|
|
cp ./.github/help/mac-windows/* tmp_out/ \
|
|
|| echo "no macos dmg"
|
|
cd tmp_out && 7z a hiddify-${{matrix.platform}}-x64.zip ./ && mv *.zip ../out/s
|
|
|
|
- name: Upload Artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: artifact
|
|
path: ./out
|
|
retention-days: 2
|
|
|
|
upload-draft:
|
|
permissions: write-all
|
|
if: ${{ github.ref_type == 'branch' }}
|
|
needs: [build]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Download Artifact
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: artifact
|
|
path: ./out/
|
|
|
|
- name: Display Files Structure
|
|
run: ls -R
|
|
working-directory: ./out
|
|
|
|
- name: Delete Current Release Assets
|
|
uses: 8Mi-Tech/delete-release-assets-action@main
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
tag: "draft"
|
|
deleteOnlyFromDrafts: false
|
|
|
|
- name: Create or Update Draft Release
|
|
uses: softprops/action-gh-release@v1
|
|
if: ${{ github.ref_type != 'tag' }}
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
files: ./out/*
|
|
name: "draft"
|
|
tag_name: "draft"
|
|
prerelease: true
|
|
|
|
upload-release:
|
|
permissions: write-all
|
|
if: ${{ github.ref_type == 'tag' }}
|
|
needs: [build]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/download-artifact@v3
|
|
with:
|
|
name: artifact
|
|
path: ./out/
|
|
|
|
- name: prepare_release_message
|
|
run: |
|
|
pip install gitchangelog
|
|
previous_release=$(curl --silent "https://api.github.com/repos/hiddify/hiddify-next/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")')
|
|
current="${{ github.ref_name }}"
|
|
gitchangelog "${previous_release}..v$current" > release.md
|
|
sed 's|${tag}|${{ github.ref_name }}|g' ./.github/release_message.md >> release.md
|
|
- name: Display Files Structure
|
|
run: ls -R
|
|
working-directory: ./out
|
|
|
|
- name: Upload Release
|
|
uses: softprops/action-gh-release@v1
|
|
if: ${{ success() }}
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
prerelease: ${{ env.CHANNEL == 'dev' }}
|
|
tag_name: ${{ github.ref_name }}
|
|
body_path: "./.github/release_message.md"
|
|
files: ./out/*
|
|
|
|
- name: Create service_account.json
|
|
run: echo '${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }}' > service_account.json
|
|
|
|
- name: Deploy to Google Play Internal Testers
|
|
uses: r0adkll/upload-google-play@v1
|
|
with:
|
|
serviceAccountJson: service_account.json
|
|
packageName: app.hiddify.com
|
|
releaseName: ${{ github.ref }}
|
|
releaseFiles: ./out/hiddify-android-market.aab
|
|
track: internal
|