💚 Update ci scripts

This commit is contained in:
niuhuan 2023-07-07 14:27:02 +08:00
parent 3d3f452c40
commit 4ffce64f29
5 changed files with 112 additions and 94 deletions

View File

@ -4,15 +4,18 @@ on:
workflow_dispatch:
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
go_version: '1.17'
flutter_channel: 'stable'
GH_TOKEN: ${{ secrets.GH_TOKEN }}
host_linux: ubuntu-latest
host_windows: windows-latest
host_macos: macos-latest
jobs:
ci-pass:
name: CI is green
runs-on: ubuntu-latest
runs-on: ${{ env.host_linux }}
needs:
- check_release
- build_release_assets
@ -22,7 +25,7 @@ jobs:
check_release:
name: Check release
runs-on: ubuntu-latest
runs-on: ${{ env.host_linux }}
steps:
- uses: actions/checkout@v3
with:
@ -37,9 +40,9 @@ jobs:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
key: ${{ env.host_linux }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
${{ env.host_linux }}-go-
- name: Check release
run: |
cd ci
@ -52,85 +55,98 @@ jobs:
strategy:
fail-fast: false
matrix:
sources:
- branch: master
- branch: resizeful
config:
- target: windows
host: windows-latest
host: ${{ env.host_windows }}
flutter_version: '2.10.3'
- target: macos
host: macos-latest
host: ${{ env.host_macos }}
flutter_version: '2.10.3'
- target: linux
host: ubuntu-latest
host: ${{ env.host_linux }}
flutter_version: '2.10.3'
- target: ios
host: macos-latest
host: ${{ env.host_macos }}
flutter_version: '3.7.3'
- target: android-arm32
host: ubuntu-latest
host: ${{ env.host_linux }}
flutter_version: '2.10.5'
- target: android-arm64
host: ubuntu-latest
host: ${{ env.host_linux }}
flutter_version: '2.10.5'
- target: android-x86_64
host: ubuntu-latest
host: ${{ env.host_linux }}
flutter_version: '2.10.5'
- target: android-arm32
host: ubuntu-latest
host: ${{ env.host_linux }}
flutter_version: '3.7.3'
- target: android-arm64
host: ubuntu-latest
host: ${{ env.host_linux }}
flutter_version: '3.7.3'
- target: android-x86_64
host: ubuntu-latest
host: ${{ env.host_linux }}
flutter_version: '3.7.3'
runs-on: ${{ matrix.config.host }}
env:
TARGET: ${{ matrix.config.target }}
flutter_version: ${{ matrix.config.flutter_version }}
FLUTTER_VERSION: ${{ matrix.config.flutter_version }}
BRANCH: ${{ matrix.sources.branch }}
steps:
- name: Checkout
uses: actions/checkout@v3
# 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 (Linux/Android)
if: 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: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Cache go modules (macOS/ios)
if: matrix.config.target == 'macos' || matrix.config.target == 'ios'
uses: actions/cache@v3
with:
path: |
~/Library/Caches/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Cache go modules (Windows)
if: matrix.config.target == 'windows'
if: matrix.config.host == env.host_windows
uses: actions/cache@v3
with:
path: |
~\AppData\Local\go-build
~\go\pkg\mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
key: ${{ matrix.config.host }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
${{ matrix.config.host }}-go-
- name: Cache go modules (Linux)
if: matrix.config.host == env.host_linux
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 == env.host_macos
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: ${{ matrix.config.host }}
# check_access
- id: check_asset
name: Check asset
@ -138,6 +154,8 @@ jobs:
cd ci
go run ./cmd/check_asset
#
- name: Setup flutter
if: steps.check_asset.outputs.skip_build != 'true'
uses: subosito/flutter-action@v2
@ -232,7 +250,7 @@ jobs:
cp version.code.txt ../lib/assets/version.txt
- name: Upgrade deps version (flutter2 non-mac)
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.host != 'macos-latest' && startsWith(matrix.config.flutter_version, '2')
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.host != '${{ env.host_macos }}' && 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
@ -244,7 +262,7 @@ jobs:
flutter pub get
- name: Upgrade deps version (flutter2 mac)
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.host == 'macos-latest' && startsWith(matrix.config.flutter_version, '2')
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.host == '${{ env.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
@ -331,7 +349,7 @@ jobs:
- check_release
- build_release_assets
name: Send message to community
runs-on: ubuntu-latest
runs-on: ${{ env.host_linux }}
steps:
- uses: actions/checkout@v3
with:

1
.gitignore vendored
View File

@ -56,6 +56,7 @@ ios/build/
# IDE
*.iml
.vscode/
# APP
/lib/assets/version.txt

View File

@ -19,39 +19,26 @@ func main() {
}
// get version
version := commons.LoadVersion()
// get target
// get TARGET
target := os.Getenv("TARGET")
if target == "" {
println("Env ${TARGET} is not set")
os.Exit(1)
}
// get target
flutterVersion := os.Getenv("flutter_version")
// get FLUTTER_VERSION
flutterVersion := os.Getenv("FLUTTER_VERSION")
if target == "" {
println("Env ${flutter_version} is not set")
println("Env ${FLUTTER_VERSION} is not set")
os.Exit(1)
}
// get BRANCH
branch := os.Getenv("BRANCH")
if target == "" {
println("Env ${BRANCH} is not set")
os.Exit(1)
}
//
var releaseFileName string
switch target {
case "macos":
releaseFileName = fmt.Sprintf("pikapika-%v-macos-intel.dmg", version.Code)
case "ios":
releaseFileName = fmt.Sprintf("pikapika-%v-ios-nosign.ipa", version.Code)
case "windows":
releaseFileName = fmt.Sprintf("pikapika-%v-windows-x86_64.zip", version.Code)
case "linux":
releaseFileName = fmt.Sprintf("pikapika-%v-linux-x86_64.AppImage", version.Code)
case "android-arm32":
releaseFileName = fmt.Sprintf("pikapika-%v-android-arm32.apk", version.Code)
case "android-arm64":
releaseFileName = fmt.Sprintf("pikapika-%v-android-arm64.apk", version.Code)
case "android-x86_64":
releaseFileName = fmt.Sprintf("pikapika-%v-android-x86_64.apk", version.Code)
}
if strings.HasPrefix(flutterVersion, "2.") {
releaseFileName = "z-of-" + releaseFileName
}
var releaseFileName = commons.AssetName(version, flutterVersion, target, branch)
// get version
getReleaseRequest, err := http.NewRequest(
"GET",

View File

@ -20,39 +20,26 @@ func main() {
}
// get version
version := commons.LoadVersion()
// get target
// get TARGET
target := os.Getenv("TARGET")
if target == "" {
println("Env ${TARGET} is not set")
os.Exit(1)
}
// get target
flutterVersion := os.Getenv("flutter_version")
// get FLUTTER_VERSION
flutterVersion := os.Getenv("FLUTTER_VERSION")
if target == "" {
println("Env ${flutter_version} is not set")
println("Env ${FLUTTER_VERSION} is not set")
os.Exit(1)
}
// get BRANCH
branch := os.Getenv("BRANCH")
if target == "" {
println("Env ${BRANCH} is not set")
os.Exit(1)
}
//
var releaseFileName string
switch target {
case "macos":
releaseFileName = fmt.Sprintf("pikapika-%v-macos-intel.dmg", version.Code)
case "ios":
releaseFileName = fmt.Sprintf("pikapika-%v-ios-nosign.ipa", version.Code)
case "windows":
releaseFileName = fmt.Sprintf("pikapika-%v-windows-x86_64.zip", version.Code)
case "linux":
releaseFileName = fmt.Sprintf("pikapika-%v-linux-x86_64.AppImage", version.Code)
case "android-arm32":
releaseFileName = fmt.Sprintf("pikapika-%v-android-arm32.apk", version.Code)
case "android-arm64":
releaseFileName = fmt.Sprintf("pikapika-%v-android-arm64.apk", version.Code)
case "android-x86_64":
releaseFileName = fmt.Sprintf("pikapika-%v-android-x86_64.apk", version.Code)
}
if strings.HasPrefix(flutterVersion, "2.") {
releaseFileName = "z-of-" + releaseFileName
}
var releaseFileName = commons.AssetName(version, flutterVersion, target, branch)
//
var releaseFilePath string
var contentType string

View File

@ -1,6 +1,7 @@
package commons
import (
"fmt"
"io/ioutil"
"strings"
)
@ -24,3 +25,27 @@ func LoadVersion() Version {
version.Info = strings.TrimSpace(string(infoFile))
return version
}
func AssetName(version Version, flutterVersion, target, branch string) string {
releaseFileName := fmt.Sprintf("pikapika-%v_flutter-%v", version.Code, flutterVersion)
switch target {
case "macos":
releaseFileName += "-macos-intel.dmg"
case "ios":
releaseFileName = "-ios-nosign.ipa"
case "windows":
releaseFileName = "-windows-x86_64.zip"
case "linux":
releaseFileName = "-linux-x86_64.AppImage"
case "android-arm32":
releaseFileName = "-android-arm32.apk"
case "android-arm64":
releaseFileName = "-android-arm64.apk"
case "android-x86_64":
releaseFileName = "-android-x86_64.apk"
}
if branch != "master" && branch != "main" {
releaseFileName = branch + "-" + releaseFileName
}
return releaseFileName
}