💚 Update ci scripts
This commit is contained in:
parent
3d3f452c40
commit
4ffce64f29
|
@ -4,15 +4,18 @@ on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||||
go_version: '1.17'
|
go_version: '1.17'
|
||||||
flutter_channel: 'stable'
|
flutter_channel: 'stable'
|
||||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
host_linux: ubuntu-latest
|
||||||
|
host_windows: windows-latest
|
||||||
|
host_macos: macos-latest
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
ci-pass:
|
ci-pass:
|
||||||
name: CI is green
|
name: CI is green
|
||||||
runs-on: ubuntu-latest
|
runs-on: ${{ env.host_linux }}
|
||||||
needs:
|
needs:
|
||||||
- check_release
|
- check_release
|
||||||
- build_release_assets
|
- build_release_assets
|
||||||
|
@ -22,7 +25,7 @@ jobs:
|
||||||
|
|
||||||
check_release:
|
check_release:
|
||||||
name: Check release
|
name: Check release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ${{ env.host_linux }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
|
@ -37,9 +40,9 @@ jobs:
|
||||||
path: |
|
path: |
|
||||||
~/.cache/go-build
|
~/.cache/go-build
|
||||||
~/go/pkg/mod
|
~/go/pkg/mod
|
||||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
key: ${{ env.host_linux }}-go-${{ hashFiles('**/go.sum') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-go-
|
${{ env.host_linux }}-go-
|
||||||
- name: Check release
|
- name: Check release
|
||||||
run: |
|
run: |
|
||||||
cd ci
|
cd ci
|
||||||
|
@ -52,85 +55,98 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
|
sources:
|
||||||
|
- branch: master
|
||||||
|
- branch: resizeful
|
||||||
config:
|
config:
|
||||||
- target: windows
|
- target: windows
|
||||||
host: windows-latest
|
host: ${{ env.host_windows }}
|
||||||
flutter_version: '2.10.3'
|
flutter_version: '2.10.3'
|
||||||
- target: macos
|
- target: macos
|
||||||
host: macos-latest
|
host: ${{ env.host_macos }}
|
||||||
flutter_version: '2.10.3'
|
flutter_version: '2.10.3'
|
||||||
- target: linux
|
- target: linux
|
||||||
host: ubuntu-latest
|
host: ${{ env.host_linux }}
|
||||||
flutter_version: '2.10.3'
|
flutter_version: '2.10.3'
|
||||||
- target: ios
|
- target: ios
|
||||||
host: macos-latest
|
host: ${{ env.host_macos }}
|
||||||
flutter_version: '3.7.3'
|
flutter_version: '3.7.3'
|
||||||
- target: android-arm32
|
- target: android-arm32
|
||||||
host: ubuntu-latest
|
host: ${{ env.host_linux }}
|
||||||
flutter_version: '2.10.5'
|
flutter_version: '2.10.5'
|
||||||
- target: android-arm64
|
- target: android-arm64
|
||||||
host: ubuntu-latest
|
host: ${{ env.host_linux }}
|
||||||
flutter_version: '2.10.5'
|
flutter_version: '2.10.5'
|
||||||
- target: android-x86_64
|
- target: android-x86_64
|
||||||
host: ubuntu-latest
|
host: ${{ env.host_linux }}
|
||||||
flutter_version: '2.10.5'
|
flutter_version: '2.10.5'
|
||||||
- target: android-arm32
|
- target: android-arm32
|
||||||
host: ubuntu-latest
|
host: ${{ env.host_linux }}
|
||||||
flutter_version: '3.7.3'
|
flutter_version: '3.7.3'
|
||||||
- target: android-arm64
|
- target: android-arm64
|
||||||
host: ubuntu-latest
|
host: ${{ env.host_linux }}
|
||||||
flutter_version: '3.7.3'
|
flutter_version: '3.7.3'
|
||||||
- target: android-x86_64
|
- target: android-x86_64
|
||||||
host: ubuntu-latest
|
host: ${{ env.host_linux }}
|
||||||
flutter_version: '3.7.3'
|
flutter_version: '3.7.3'
|
||||||
|
|
||||||
runs-on: ${{ matrix.config.host }}
|
runs-on: ${{ matrix.config.host }}
|
||||||
|
|
||||||
env:
|
env:
|
||||||
TARGET: ${{ matrix.config.target }}
|
TARGET: ${{ matrix.config.target }}
|
||||||
flutter_version: ${{ matrix.config.flutter_version }}
|
FLUTTER_VERSION: ${{ matrix.config.flutter_version }}
|
||||||
|
BRANCH: ${{ matrix.sources.branch }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
# Setup golang env and cache go module
|
||||||
|
|
||||||
- name: Setup golang
|
- name: Setup golang
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.go_version }}
|
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)
|
- name: Cache go modules (Windows)
|
||||||
if: matrix.config.target == 'windows'
|
if: matrix.config.host == env.host_windows
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~\AppData\Local\go-build
|
~\AppData\Local\go-build
|
||||||
~\go\pkg\mod
|
~\go\pkg\mod
|
||||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
key: ${{ matrix.config.host }}-go-${{ hashFiles('**/go.sum') }}
|
||||||
restore-keys: |
|
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
|
- id: check_asset
|
||||||
name: Check asset
|
name: Check asset
|
||||||
|
@ -138,6 +154,8 @@ jobs:
|
||||||
cd ci
|
cd ci
|
||||||
go run ./cmd/check_asset
|
go run ./cmd/check_asset
|
||||||
|
|
||||||
|
#
|
||||||
|
|
||||||
- name: Setup flutter
|
- name: Setup flutter
|
||||||
if: steps.check_asset.outputs.skip_build != 'true'
|
if: steps.check_asset.outputs.skip_build != 'true'
|
||||||
uses: subosito/flutter-action@v2
|
uses: subosito/flutter-action@v2
|
||||||
|
@ -232,7 +250,7 @@ jobs:
|
||||||
cp version.code.txt ../lib/assets/version.txt
|
cp version.code.txt ../lib/assets/version.txt
|
||||||
|
|
||||||
- name: Upgrade deps version (flutter2 non-mac)
|
- 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: |
|
run: |
|
||||||
sed -i "s/another_xlider: ^1.0.1+2/another_xlider: 1.0.1+2/g" pubspec.yaml
|
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/flutter_styled_toast: ^2.0.0/flutter_styled_toast: 2.0.0/g" pubspec.yaml
|
||||||
|
@ -244,7 +262,7 @@ jobs:
|
||||||
flutter pub get
|
flutter pub get
|
||||||
|
|
||||||
- name: Upgrade deps version (flutter2 mac)
|
- 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: |
|
run: |
|
||||||
brew install gnu-sed
|
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/another_xlider: ^1.0.1+2/another_xlider: 1.0.1+2/g" pubspec.yaml
|
||||||
|
@ -331,7 +349,7 @@ jobs:
|
||||||
- check_release
|
- check_release
|
||||||
- build_release_assets
|
- build_release_assets
|
||||||
name: Send message to community
|
name: Send message to community
|
||||||
runs-on: ubuntu-latest
|
runs-on: ${{ env.host_linux }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
|
|
|
@ -56,6 +56,7 @@ ios/build/
|
||||||
|
|
||||||
# IDE
|
# IDE
|
||||||
*.iml
|
*.iml
|
||||||
|
.vscode/
|
||||||
|
|
||||||
# APP
|
# APP
|
||||||
/lib/assets/version.txt
|
/lib/assets/version.txt
|
||||||
|
|
|
@ -19,39 +19,26 @@ func main() {
|
||||||
}
|
}
|
||||||
// get version
|
// get version
|
||||||
version := commons.LoadVersion()
|
version := commons.LoadVersion()
|
||||||
// get target
|
// get TARGET
|
||||||
target := os.Getenv("TARGET")
|
target := os.Getenv("TARGET")
|
||||||
if target == "" {
|
if target == "" {
|
||||||
println("Env ${TARGET} is not set")
|
println("Env ${TARGET} is not set")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
// get target
|
// get FLUTTER_VERSION
|
||||||
flutterVersion := os.Getenv("flutter_version")
|
flutterVersion := os.Getenv("FLUTTER_VERSION")
|
||||||
if target == "" {
|
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)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
var releaseFileName string
|
var releaseFileName = commons.AssetName(version, flutterVersion, target, branch)
|
||||||
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
|
|
||||||
}
|
|
||||||
// get version
|
// get version
|
||||||
getReleaseRequest, err := http.NewRequest(
|
getReleaseRequest, err := http.NewRequest(
|
||||||
"GET",
|
"GET",
|
||||||
|
|
|
@ -20,39 +20,26 @@ func main() {
|
||||||
}
|
}
|
||||||
// get version
|
// get version
|
||||||
version := commons.LoadVersion()
|
version := commons.LoadVersion()
|
||||||
// get target
|
// get TARGET
|
||||||
target := os.Getenv("TARGET")
|
target := os.Getenv("TARGET")
|
||||||
if target == "" {
|
if target == "" {
|
||||||
println("Env ${TARGET} is not set")
|
println("Env ${TARGET} is not set")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
// get target
|
// get FLUTTER_VERSION
|
||||||
flutterVersion := os.Getenv("flutter_version")
|
flutterVersion := os.Getenv("FLUTTER_VERSION")
|
||||||
if target == "" {
|
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)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
var releaseFileName string
|
var releaseFileName = commons.AssetName(version, flutterVersion, target, branch)
|
||||||
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 releaseFilePath string
|
var releaseFilePath string
|
||||||
var contentType string
|
var contentType string
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package commons
|
package commons
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
@ -24,3 +25,27 @@ func LoadVersion() Version {
|
||||||
version.Info = strings.TrimSpace(string(infoFile))
|
version.Info = strings.TrimSpace(string(infoFile))
|
||||||
return version
|
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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue