Add github actions
This commit is contained in:
parent
047dc04726
commit
f5dbbe4c4e
|
@ -0,0 +1,205 @@
|
||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
go_version: '1.16'
|
||||||
|
flutter_channel: 'stable'
|
||||||
|
flutter_version: '2.10.3'
|
||||||
|
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
ci-pass:
|
||||||
|
name: CI is green
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- check_release
|
||||||
|
- build_release_assets
|
||||||
|
steps:
|
||||||
|
- run: exit 0
|
||||||
|
|
||||||
|
check_release:
|
||||||
|
name: Check release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
repository: ${{ github.event.inputs.repo }}
|
||||||
|
ref: 'master'
|
||||||
|
- name: Checkout submodules
|
||||||
|
run: git submodule update --init --recursive
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.go_version }}
|
||||||
|
- 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:
|
||||||
|
config:
|
||||||
|
- target: linux
|
||||||
|
host: ubuntu-latest
|
||||||
|
- target: windows
|
||||||
|
host: windows-latest
|
||||||
|
- target: macos
|
||||||
|
host: macos-latest
|
||||||
|
- target: ios
|
||||||
|
host: macos-latest
|
||||||
|
- target: android-arm32
|
||||||
|
host: ubuntu-latest
|
||||||
|
- target: android-arm64
|
||||||
|
host: ubuntu-latest
|
||||||
|
- target: android-x86_64
|
||||||
|
host: ubuntu-latest
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.config.host }}
|
||||||
|
|
||||||
|
env:
|
||||||
|
TARGET: ${{ matrix.config.target }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup golang
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.go_version }}
|
||||||
|
|
||||||
|
- id: check_asset
|
||||||
|
name: Check asset
|
||||||
|
run: |
|
||||||
|
cd ci
|
||||||
|
go run ./cmd/check_asset
|
||||||
|
|
||||||
|
- name: Setup flutter
|
||||||
|
if: steps.check_asset.outputs.skip_build != 'true'
|
||||||
|
uses: subosito/flutter-action@v2.3.0
|
||||||
|
with:
|
||||||
|
channel: ${{ env.flutter_channel }}
|
||||||
|
flutter-version: ${{ env.flutter_version }}
|
||||||
|
|
||||||
|
- 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:
|
||||||
|
java-version: 8
|
||||||
|
distribution: 'zulu'
|
||||||
|
|
||||||
|
- 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: maxim-lobanov/setup-android-tools@v1
|
||||||
|
with:
|
||||||
|
packages: |
|
||||||
|
platform-tools
|
||||||
|
platforms;android-32
|
||||||
|
build-tools;30.0.2
|
||||||
|
ndk;22.1.7171670
|
||||||
|
|
||||||
|
- 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
|
||||||
|
sudo apt-get install -y libgl1-mesa-dev xorg-dev
|
||||||
|
|
||||||
|
- 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
|
||||||
|
|
||||||
|
- name: Build (windows)
|
||||||
|
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.target == 'windows'
|
||||||
|
run: |
|
||||||
|
hover build windows
|
||||||
|
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
|
||||||
|
|
||||||
|
- name: Build (ios)
|
||||||
|
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.target == 'ios'
|
||||||
|
run: |
|
||||||
|
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' )
|
||||||
|
uses: r0adkll/sign-android-release@v1
|
||||||
|
id: sign_app
|
||||||
|
with:
|
||||||
|
releaseDirectory: build/app/outputs/flutter-apk
|
||||||
|
signingKeyBase64: ${{ secrets.SIGN_FILE_BASE64 }}
|
||||||
|
alias: ${{ secrets.KEY_ALIAS }}
|
||||||
|
keyStorePassword: ${{ secrets.KEYSTORE_PASSWORD }}
|
||||||
|
keyPassword: ${{ secrets.KEY_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Upload Asset (All)
|
||||||
|
if: steps.check_asset.outputs.skip_build != 'true'
|
||||||
|
run: |
|
||||||
|
cd ci
|
||||||
|
go run ./cmd/upload_asset
|
||||||
|
|
|
@ -54,5 +54,8 @@ app.*.map.json
|
||||||
|
|
||||||
ios/build/
|
ios/build/
|
||||||
|
|
||||||
|
# IDE
|
||||||
|
*.iml
|
||||||
|
|
||||||
# APP
|
# APP
|
||||||
/lib/assets/version.txt
|
/lib/assets/version.txt
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"ci/commons"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
const owner = "niuhuan"
|
||||||
|
const repo = "pikapika"
|
||||||
|
const ua = "niuhuan pikapika ci"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// get ghToken
|
||||||
|
ghToken := os.Getenv("GH_TOKEN")
|
||||||
|
if ghToken == "" {
|
||||||
|
println("Env ${GH_TOKEN} is not set")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
// get version
|
||||||
|
var version commons.Version
|
||||||
|
codeFile, err := ioutil.ReadFile("version.code.txt")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
version.Code = strings.TrimSpace(string(codeFile))
|
||||||
|
infoFile, err := ioutil.ReadFile("version.info.txt")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
version.Info = strings.TrimSpace(string(infoFile))
|
||||||
|
// get target
|
||||||
|
target := os.Getenv("TARGET")
|
||||||
|
if ghToken == "" {
|
||||||
|
println("Env ${TARGET} 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)
|
||||||
|
}
|
||||||
|
// get version
|
||||||
|
getReleaseRequest, err := http.NewRequest(
|
||||||
|
"GET",
|
||||||
|
fmt.Sprintf("https://api.github.com/repos/%v/%v/releases/tags/%v", owner, repo, version.Code),
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
getReleaseRequest.Header.Set("User-Agent", ua)
|
||||||
|
getReleaseRequest.Header.Set("Authorization", ghToken)
|
||||||
|
getReleaseResponse, err := http.DefaultClient.Do(getReleaseRequest)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
defer getReleaseResponse.Body.Close()
|
||||||
|
if getReleaseResponse.StatusCode == 404 {
|
||||||
|
panic("NOT FOUND RELEASE")
|
||||||
|
}
|
||||||
|
buff, err := ioutil.ReadAll(getReleaseResponse.Body)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
var release commons.Release
|
||||||
|
err = json.Unmarshal(buff, &release)
|
||||||
|
if err != nil {
|
||||||
|
println(string(buff))
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
for _, asset := range release.Assets {
|
||||||
|
if asset.Name == releaseFileName {
|
||||||
|
println("::set-output name=skip_build::true")
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print("::set-output name=skip_build::false")
|
||||||
|
}
|
|
@ -0,0 +1,89 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"ci/commons"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
const owner = "niuhuan"
|
||||||
|
const repo = "pikapika"
|
||||||
|
const ua = "niuhuan pikapika ci"
|
||||||
|
const mainBranch = "master"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// get ghToken
|
||||||
|
ghToken := os.Getenv("GH_TOKEN")
|
||||||
|
if ghToken == "" {
|
||||||
|
println("Env ${GH_TOKEN} is not set")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
// get version
|
||||||
|
var version commons.Version
|
||||||
|
codeFile, err := ioutil.ReadFile("version.code.txt")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
version.Code = strings.TrimSpace(string(codeFile))
|
||||||
|
infoFile, err := ioutil.ReadFile("version.info.txt")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
version.Info = strings.TrimSpace(string(infoFile))
|
||||||
|
// get version
|
||||||
|
getReleaseRequest, err := http.NewRequest(
|
||||||
|
"GET",
|
||||||
|
fmt.Sprintf("https://api.github.com/repos/%v/%v/releases/tags/%v", owner, repo, version.Code),
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
panic(nil)
|
||||||
|
}
|
||||||
|
getReleaseRequest.Header.Set("User-Agent", ua)
|
||||||
|
getReleaseRequest.Header.Set("Authorization", ghToken)
|
||||||
|
getReleaseResponse, err := http.DefaultClient.Do(getReleaseRequest)
|
||||||
|
if err != nil {
|
||||||
|
panic(nil)
|
||||||
|
}
|
||||||
|
defer getReleaseResponse.Body.Close()
|
||||||
|
if getReleaseResponse.StatusCode == 404 {
|
||||||
|
url := fmt.Sprintf("https://api.github.com/repos/%v/%v/releases", owner, repo)
|
||||||
|
body := map[string]interface{}{
|
||||||
|
"tag_name": version.Code,
|
||||||
|
"target_commitish": mainBranch,
|
||||||
|
"name": version.Code,
|
||||||
|
"body": version.Info,
|
||||||
|
}
|
||||||
|
var buff []byte
|
||||||
|
buff, err = json.Marshal(&body)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
var createReleaseRequest *http.Request
|
||||||
|
createReleaseRequest, err = http.NewRequest("POST", url, bytes.NewBuffer(buff))
|
||||||
|
if err != nil {
|
||||||
|
panic(nil)
|
||||||
|
}
|
||||||
|
createReleaseRequest.Header.Set("User-Agent", ua)
|
||||||
|
createReleaseRequest.Header.Set("Authorization", ghToken)
|
||||||
|
var createReleaseResponse *http.Response
|
||||||
|
createReleaseResponse, err = http.DefaultClient.Do(createReleaseRequest)
|
||||||
|
if err != nil {
|
||||||
|
panic(nil)
|
||||||
|
}
|
||||||
|
defer createReleaseResponse.Body.Close()
|
||||||
|
if createReleaseResponse.StatusCode != 201 {
|
||||||
|
buff, err = ioutil.ReadAll(createReleaseResponse.Body)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
println(string(buff))
|
||||||
|
panic("NOT 201")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,139 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"ci/commons"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
const owner = "niuhuan"
|
||||||
|
const repo = "pikapika"
|
||||||
|
const ua = "niuhuan pikapika ci"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// get ghToken
|
||||||
|
ghToken := os.Getenv("GH_TOKEN")
|
||||||
|
if ghToken == "" {
|
||||||
|
println("Env ${GH_TOKEN} is not set")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
// get version
|
||||||
|
var version commons.Version
|
||||||
|
codeFile, err := ioutil.ReadFile("version.code.txt")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
version.Code = strings.TrimSpace(string(codeFile))
|
||||||
|
infoFile, err := ioutil.ReadFile("version.info.txt")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
version.Info = strings.TrimSpace(string(infoFile))
|
||||||
|
// get target
|
||||||
|
target := os.Getenv("TARGET")
|
||||||
|
if ghToken == "" {
|
||||||
|
println("Env ${TARGET} is not set")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
//
|
||||||
|
var releaseFilePath string
|
||||||
|
var releaseFileName string
|
||||||
|
var contentType string
|
||||||
|
var contentLength int64
|
||||||
|
switch target {
|
||||||
|
case "macos":
|
||||||
|
releaseFilePath = "build/build.dmg"
|
||||||
|
releaseFileName = fmt.Sprintf("pikapika-%v-macos-intel.dmg", version.Code)
|
||||||
|
contentType = "application/octet-stream"
|
||||||
|
case "ios":
|
||||||
|
releaseFilePath = "build/nosign.ipa"
|
||||||
|
releaseFileName = fmt.Sprintf("pikapika-%v-ios-nosign.ipa", version.Code)
|
||||||
|
contentType = "application/octet-stream"
|
||||||
|
case "windows":
|
||||||
|
releaseFilePath = "build/build.zip"
|
||||||
|
releaseFileName = fmt.Sprintf("pikapika-%v-windows-x86_64.zip", version.Code)
|
||||||
|
contentType = "application/octet-stream"
|
||||||
|
case "linux":
|
||||||
|
releaseFilePath = "build/build.AppImage"
|
||||||
|
releaseFileName = fmt.Sprintf("pikapika-%v-linux-x86_64.AppImage", version.Code)
|
||||||
|
contentType = "application/octet-stream"
|
||||||
|
case "android-arm32":
|
||||||
|
releaseFilePath = "build/app/outputs/flutter-apk/app-release.apk"
|
||||||
|
releaseFileName = fmt.Sprintf("pikapika-%v-android-arm32.apk", version.Code)
|
||||||
|
contentType = "application/octet-stream"
|
||||||
|
case "android-arm64":
|
||||||
|
releaseFilePath = "build/app/outputs/flutter-apk/app-release.apk"
|
||||||
|
releaseFileName = fmt.Sprintf("pikapika-%v-android-arm64.apk", version.Code)
|
||||||
|
contentType = "application/octet-stream"
|
||||||
|
case "android-x86_64":
|
||||||
|
releaseFilePath = "build/app/outputs/flutter-apk/app-release.apk"
|
||||||
|
releaseFileName = fmt.Sprintf("pikapika-%v-android-x86_64.apk", version.Code)
|
||||||
|
contentType = "application/octet-stream"
|
||||||
|
}
|
||||||
|
releaseFilePath = path.Join("..", releaseFilePath)
|
||||||
|
info, err := os.Stat(releaseFilePath)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
contentLength = info.Size()
|
||||||
|
// get version
|
||||||
|
getReleaseRequest, err := http.NewRequest(
|
||||||
|
"GET",
|
||||||
|
fmt.Sprintf("https://api.github.com/repos/%v/%v/releases/tags/%v", owner, repo, version.Code),
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
getReleaseRequest.Header.Set("User-Agent", ua)
|
||||||
|
getReleaseRequest.Header.Set("Authorization", ghToken)
|
||||||
|
getReleaseResponse, err := http.DefaultClient.Do(getReleaseRequest)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
defer getReleaseResponse.Body.Close()
|
||||||
|
if getReleaseResponse.StatusCode == 404 {
|
||||||
|
panic("NOT FOUND RELEASE")
|
||||||
|
}
|
||||||
|
buff, err := ioutil.ReadAll(getReleaseResponse.Body)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
var release commons.Release
|
||||||
|
err = json.Unmarshal(buff, &release)
|
||||||
|
if err != nil {
|
||||||
|
println(string(buff))
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
file, err := os.Open(releaseFilePath)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
uploadUrl := fmt.Sprintf("https://uploads.github.com/repos/%v/%v/releases/%v/assets?name=%v", owner, repo, release.Id, releaseFileName)
|
||||||
|
uploadRequest, err := http.NewRequest("POST", uploadUrl, file)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
uploadRequest.Header.Set("User-Agent", ua)
|
||||||
|
uploadRequest.Header.Set("Authorization", ghToken)
|
||||||
|
uploadRequest.Header.Set("Content-Type", contentType)
|
||||||
|
uploadRequest.ContentLength = contentLength
|
||||||
|
uploadResponse, err := http.DefaultClient.Do(uploadRequest)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if uploadResponse.StatusCode != 201 {
|
||||||
|
buff, err = ioutil.ReadAll(uploadResponse.Body)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
println(string(buff))
|
||||||
|
panic("NOT 201")
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,82 @@
|
||||||
|
package commons
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
type Version struct {
|
||||||
|
Code string `json:"code"`
|
||||||
|
Info string `json:"info"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Release struct {
|
||||||
|
Url string `json:"url"`
|
||||||
|
HtmlUrl string `json:"html_url"`
|
||||||
|
AssetsUrl string `json:"assets_url"`
|
||||||
|
UploadUrl string `json:"upload_url"`
|
||||||
|
TarballUrl string `json:"tarball_url"`
|
||||||
|
ZipballUrl string `json:"zipball_url"`
|
||||||
|
DiscussionUrl string `json:"discussion_url"`
|
||||||
|
Id int `json:"id"`
|
||||||
|
NodeId string `json:"node_id"`
|
||||||
|
TagName string `json:"tag_name"`
|
||||||
|
TargetCommitish string `json:"target_commitish"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Body string `json:"body"`
|
||||||
|
Draft bool `json:"draft"`
|
||||||
|
Prerelease bool `json:"prerelease"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
PublishedAt time.Time `json:"published_at"`
|
||||||
|
Author struct {
|
||||||
|
Login string `json:"login"`
|
||||||
|
Id int `json:"id"`
|
||||||
|
NodeId string `json:"node_id"`
|
||||||
|
AvatarUrl string `json:"avatar_url"`
|
||||||
|
GravatarId string `json:"gravatar_id"`
|
||||||
|
Url string `json:"url"`
|
||||||
|
HtmlUrl string `json:"html_url"`
|
||||||
|
FollowersUrl string `json:"followers_url"`
|
||||||
|
FollowingUrl string `json:"following_url"`
|
||||||
|
GistsUrl string `json:"gists_url"`
|
||||||
|
StarredUrl string `json:"starred_url"`
|
||||||
|
SubscriptionsUrl string `json:"subscriptions_url"`
|
||||||
|
OrganizationsUrl string `json:"organizations_url"`
|
||||||
|
ReposUrl string `json:"repos_url"`
|
||||||
|
EventsUrl string `json:"events_url"`
|
||||||
|
ReceivedEventsUrl string `json:"received_events_url"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
SiteAdmin bool `json:"site_admin"`
|
||||||
|
} `json:"author"`
|
||||||
|
Assets []struct {
|
||||||
|
Url string `json:"url"`
|
||||||
|
BrowserDownloadUrl string `json:"browser_download_url"`
|
||||||
|
Id int `json:"id"`
|
||||||
|
NodeId string `json:"node_id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Label string `json:"label"`
|
||||||
|
State string `json:"state"`
|
||||||
|
ContentType string `json:"content_type"`
|
||||||
|
Size int `json:"size"`
|
||||||
|
DownloadCount int `json:"download_count"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
|
Uploader struct {
|
||||||
|
Login string `json:"login"`
|
||||||
|
Id int `json:"id"`
|
||||||
|
NodeId string `json:"node_id"`
|
||||||
|
AvatarUrl string `json:"avatar_url"`
|
||||||
|
GravatarId string `json:"gravatar_id"`
|
||||||
|
Url string `json:"url"`
|
||||||
|
HtmlUrl string `json:"html_url"`
|
||||||
|
FollowersUrl string `json:"followers_url"`
|
||||||
|
FollowingUrl string `json:"following_url"`
|
||||||
|
GistsUrl string `json:"gists_url"`
|
||||||
|
StarredUrl string `json:"starred_url"`
|
||||||
|
SubscriptionsUrl string `json:"subscriptions_url"`
|
||||||
|
OrganizationsUrl string `json:"organizations_url"`
|
||||||
|
ReposUrl string `json:"repos_url"`
|
||||||
|
EventsUrl string `json:"events_url"`
|
||||||
|
ReceivedEventsUrl string `json:"received_events_url"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
SiteAdmin bool `json:"site_admin"`
|
||||||
|
} `json:"uploader"`
|
||||||
|
} `json:"assets"`
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
fonts:
|
||||||
|
- family: Roboto
|
||||||
|
fonts:
|
||||||
|
- asset: fonts/Roboto.ttf
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
v1.4.2
|
|
@ -0,0 +1 @@
|
||||||
|
测试RELEASE
|
|
@ -3,6 +3,7 @@
|
||||||
cd "$( cd "$( dirname "$0" )" && pwd )/.."
|
cd "$( cd "$( dirname "$0" )" && pwd )/.."
|
||||||
|
|
||||||
cd go/mobile
|
cd go/mobile
|
||||||
|
go get golang.org/x/mobile/cmd/gobind
|
||||||
gomobile bind -target=android/arm -o lib/Mobile.aar ./
|
gomobile bind -target=android/arm -o lib/Mobile.aar ./
|
||||||
cd ../..
|
cd ../..
|
||||||
flutter build apk --target-platform android-arm
|
flutter build apk --target-platform android-arm
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
cd "$( cd "$( dirname "$0" )" && pwd )/.."
|
cd "$( cd "$( dirname "$0" )" && pwd )/.."
|
||||||
|
|
||||||
cd go/mobile
|
cd go/mobile
|
||||||
|
go get golang.org/x/mobile/cmd/gobind
|
||||||
gomobile bind -target=android/arm64 -o lib/Mobile.aar ./
|
gomobile bind -target=android/arm64 -o lib/Mobile.aar ./
|
||||||
cd ../..
|
cd ../..
|
||||||
flutter build apk --target-platform android-arm64
|
flutter build apk --target-platform android-arm64
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
cd "$( cd "$( dirname "$0" )" && pwd )/.."
|
cd "$( cd "$( dirname "$0" )" && pwd )/.."
|
||||||
|
|
||||||
cd go/mobile
|
cd go/mobile
|
||||||
|
go get golang.org/x/mobile/cmd/gobind
|
||||||
gomobile bind -target=android/amd64 -o lib/Mobile.aar ./
|
gomobile bind -target=android/amd64 -o lib/Mobile.aar ./
|
||||||
cd ../..
|
cd ../..
|
||||||
flutter build apk --target-platform android-x64
|
flutter build apk --target-platform android-x64
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
cd "$( cd "$( dirname "$0" )" && pwd )/.."
|
cd "$( cd "$( dirname "$0" )" && pwd )/.."
|
||||||
|
|
||||||
cd go/mobile
|
cd go/mobile
|
||||||
|
go get golang.org/x/mobile/cmd/gobind
|
||||||
gomobile bind -target=android/386 -o lib/Mobile.aar ./
|
gomobile bind -target=android/386 -o lib/Mobile.aar ./
|
||||||
cd ../..
|
cd ../..
|
||||||
flutter build apk --target-platform android-x86
|
flutter build apk --target-platform android-x86
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
cd "$( cd "$( dirname "$0" )" && pwd )/.."
|
cd "$( cd "$( dirname "$0" )" && pwd )/.."
|
||||||
|
|
||||||
cd go/mobile
|
cd go/mobile
|
||||||
|
go get golang.org/x/mobile/cmd/gobind
|
||||||
gomobile bind -target=ios -o lib/Mobile.xcframework ./
|
gomobile bind -target=ios -o lib/Mobile.xcframework ./
|
||||||
cd ../..
|
cd ../..
|
||||||
flutter build ios --release --no-codesign
|
flutter build ios --release --no-codesign
|
||||||
|
|
Loading…
Reference in New Issue