Add Settings page and SubscriptionScreen for XTLS config #50
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: Build and Release Flutter Packages | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: [linux, windows, macos, android, ios] | |
arch: [x64, arm64] | |
exclude: | |
- platform: windows | |
arch: arm64 | |
- platform: ios | |
arch: x64 | |
- platform: android | |
arch: x64 | |
include: | |
- platform: macos | |
arch: x64 | |
- platform: macos | |
arch: arm64 | |
- platform: linux | |
arch: x64 | |
- platform: linux | |
arch: arm64 | |
- platform: android | |
arch: arm64 | |
- platform: ios | |
arch: arm64 | |
- platform: windows | |
arch: x64 | |
runs-on: ${{ | |
matrix.platform == 'windows' && 'windows-latest' || | |
matrix.platform == 'linux' && 'ubuntu-latest' || | |
matrix.platform == 'android' && 'ubuntu-latest' || | |
matrix.platform == 'macos' && 'macos-latest' || | |
matrix.platform == 'ios' && 'macos-latest' }} | |
env: | |
PLATFORM: ${{ matrix.platform }} | |
ARCH: ${{ matrix.arch }} | |
steps: | |
- name: Checkout codebase | |
uses: actions/checkout@v4 | |
- name: Set up Flutter environment for Linux | |
if: ${{ matrix.platform == 'linux' }} | |
run: | | |
sudo apt-get update | |
sudo snap install flutter --classic | |
export PATH="$PATH:/snap/bin" | |
flutter doctor | |
- name: Set up Flutter environment for Windows | |
if: ${{ matrix.platform == 'windows' }} | |
shell: powershell | |
run: | | |
Set-ExecutionPolicy Bypass -Scope Process -Force | |
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12 | |
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) | |
choco install flutter -y | |
echo "C:\flutter\bin" >> $GITHUB_ENV | |
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" | |
refreshenv | |
flutter --version | |
- name: Set up Flutter environment for Android | |
if: ${{ matrix.platform == 'android' }} | |
run: | | |
sudo apt-get update | |
sudo snap install flutter --classic | |
sudo apt-get install -y snapd openjdk-17-jdk | |
echo "JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))" >> $GITHUB_ENV | |
# Set OpenJDK 17 as the default version | |
sudo update-alternatives --set java /usr/lib/jvm/java-17-openjdk-amd64/bin/java | |
sudo update-alternatives --set javac /usr/lib/jvm/java-17-openjdk-amd64/bin/javac | |
export PATH="$PATH:/snap/bin" | |
java -version | |
flutter doctor | |
- name: Set up Flutter environment for macOS/iOS | |
if: ${{ matrix.platform == 'macos' || matrix.platform == 'ios' }} | |
run: | | |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
if [[ "${{ matrix.arch }}" == "arm64" ]]; then | |
eval "$(/opt/homebrew/bin/brew shellenv)" # For Apple Silicon | |
else | |
eval "$(/usr/local/bin/brew shellenv)" # For Intel | |
fi | |
brew install --cask flutter | |
export PATH="$PATH:/Users/runner/Library/Flutter/bin" | |
flutter doctor | |
- name: Show workflow information | |
run: | | |
echo "Platform: $PLATFORM, Architecture: $ARCH" | |
- name: Build Flutter packages for Windows | |
if: ${{ matrix.platform == 'windows' }} | |
shell: powershell | |
run: | | |
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" | |
refreshenv | |
flutter build windows --release | |
env: | |
PLATFORM: ${{ matrix.platform }} | |
ARCH: ${{ matrix.arch }} | |
PATH: C:\flutter\bin;${{ secrets.PATH }} | |
- name: Build Flutter packages for Linux/Android/macOS/iOS | |
run: | | |
case $PLATFORM in | |
"linux") | |
flutter build linux --release | |
;; | |
"android") | |
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 | |
export PATH=$JAVA_HOME/bin:$PATH | |
flutter build apk --release | |
;; | |
"macos") | |
flutter build macos --release | |
;; | |
"ios") | |
flutter build ios --release --no-codesign | |
;; | |
esac | |
shell: bash | |
env: | |
PLATFORM: ${{ matrix.platform }} | |
ARCH: ${{ matrix.arch }} | |
- name: List built files | |
run: ls -R build | |
- name: Upload built packages to artifact | |
if: success() # 仅在构建成功时执行 | |
uses: actions/upload-artifact@v3 | |
with: | |
name: flutter-packages-${{ github.run_number }}-${{ github.run_id }} | |
path: | | |
build/linux/x64/release/bundle/* | |
build/linux/arm64/release/bundle/* | |
build/windows/runner/Release/XStream.exe | |
build/macos/Build/Products/Release/XStream.app | |
build/app/outputs/flutter-apk/app-release.apk | |
build/ios/iphoneos/XStream.app | |
release: | |
runs-on: ubuntu-latest | |
needs: build # 确保构建任务完成后再执行 | |
steps: | |
- name: Checkout codebase | |
uses: actions/checkout@v4 | |
- name: Download built packages from artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: flutter-packages-${{ github.run_number }}-${{ github.run_id }} | |
- name: Check if tag exists | |
id: check_tag | |
run: | | |
TAG_EXISTS=$(git tag --list "v${{ github.run_number }}-${{ github.run_id }}") | |
echo "tag_exists=$TAG_EXISTS" >> $GITHUB_ENV | |
- name: Set tag_name | |
id: set_tag_name | |
run: | | |
# 根据标签是否存在设置 tag_name | |
if [ -z "$TAG_EXISTS" ]; then | |
echo "tag_name=v${{ github.run_number }}-${{ github.run_id }}" >> $GITHUB_ENV | |
else | |
echo "tag_name=$TAG_EXISTS" >> $GITHUB_ENV | |
fi | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
with: | |
tag_name: ${{ env.tag_name }} | |
release_name: Release ${{ env.tag_name }} | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload built packages to Release | |
if: env.tag_exists != '' # 只有在标签存在时才上传 | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ env.tag_name }} | |
files: | | |
build/linux/x64/release/bundle/* | |
build/linux/arm64/release/bundle/* | |
build/windows/runner/Release/XStream.exe | |
build/macos/Build/Products/Release/XStream.app | |
build/app/outputs/flutter-apk/app-release.apk | |
build/ios/iphoneos/XStream.app | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |