Skip to content

Commit

Permalink
cache
Browse files Browse the repository at this point in the history
  • Loading branch information
chen08209 committed Dec 6, 2024
1 parent 171cc70 commit 02a7239
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 109 deletions.
209 changes: 106 additions & 103 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,23 @@ jobs:
strategy:
matrix:
include:
- platform: android
# - platform: android
# os: ubuntu-latest
# - platform: windows
# os: windows-latest
# arch: amd64
- platform: linux
os: ubuntu-latest
- platform: windows
os: windows-latest
arch: amd64
- platform: linux
os: ubuntu-latest
arch: amd64
- platform: macos
os: macos-13
arch: amd64
- platform: macos
os: macos-latest
arch: arm64
# - platform: macos
# os: macos-13
# arch: amd64
# - platform: macos
# os: macos-latest
# arch: arm64

steps:
- name: Checkout
Expand Down Expand Up @@ -148,97 +151,97 @@ jobs:
path: ./dist
overwrite: true

upload:
permissions: write-all
needs: [ build ]
runs-on: ubuntu-latest
services:
telegram-bot-api:
image: aiogram/telegram-bot-api:latest
env:
TELEGRAM_API_ID: ${{ secrets.TELEGRAM_API_ID }}
TELEGRAM_API_HASH: ${{ secrets.TELEGRAM_API_HASH }}
ports:
- 8081:8081
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download
uses: actions/download-artifact@v4
with:
path: ./dist/
pattern: artifact-*
merge-multiple: true

- name: Generate release.md
run: |
tags=($(git tag --merged $(git rev-parse HEAD) --sort=-creatordate))
preTag=$(curl --silent "https://api.github.com/repos/chen08209/FlClash/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")' || echo "")
currentTag=""
for ((i = 0; i <= ${#tags[@]}; i++)); do
if (( i < ${#tags[@]} )); then
tag=${tags[$i]}
else
tag=""
fi
if [ -n "$currentTag" ]; then
if [ "$(echo -e "$currentTag\n$preTag" | sort -V | head -n 1)" == "$currentTag" ]; then
break
fi
fi
if [ -n "$currentTag" ]; then
if [ -n "$tag" ]; then
git log --pretty=format:"%B" "$tag..$currentTag" | awk 'NF {print "- " $0} !NF {print ""}' >> release.md
else
git log --pretty=format:"%B" "$currentTag" | awk 'NF {print "- " $0} !NF {print ""}' >> release.md
fi
echo "" >> release.md
fi
currentTag=$tag
done
- name: Push to telegram
env:
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TAG: ${{ github.ref_name }}
run: |
python -m pip install --upgrade pip
pip install requests
python release.py
- name: Patch release.md
run: |
version=$(echo "${{ github.ref_name }}" | sed 's/^v//')
sed "s|VERSION|$version|g" ./.github/release_template.md >> release.md
- name: Release
if: ${{ !contains(github.ref, '+') }}
uses: softprops/action-gh-release@v2
with:
files: ./dist/*
body_path: './release.md'

- name: Create Fdroid Source Dir
if: ${{ !contains(github.ref, '+') }}
run: |
mkdir -p ./tmp
cp ./dist/*android-arm64-v8a* ./tmp/ || true
echo "Files copied successfully"
- name: Push to fdroid repo
if: ${{ !contains(github.ref, '+') }}
uses: cpina/github-action-push-to-another-repository@v1.7.2
env:
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
with:
source-directory: ./tmp/
destination-github-username: chen08209
destination-repository-name: FlClash-fdroid-repo
user-name: 'github-actions[bot]'
user-email: 'github-actions[bot]@users.noreply.github.com'
target-branch: action-pr
commit-message: Update from ${{ github.ref_name }}
target-directory: /tmp/
# upload:
# permissions: write-all
# needs: [ build ]
# runs-on: ubuntu-latest
# services:
# telegram-bot-api:
# image: aiogram/telegram-bot-api:latest
# env:
# TELEGRAM_API_ID: ${{ secrets.TELEGRAM_API_ID }}
# TELEGRAM_API_HASH: ${{ secrets.TELEGRAM_API_HASH }}
# ports:
# - 8081:8081
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
#
# - name: Download
# uses: actions/download-artifact@v4
# with:
# path: ./dist/
# pattern: artifact-*
# merge-multiple: true
#
# - name: Generate release.md
# run: |
# tags=($(git tag --merged $(git rev-parse HEAD) --sort=-creatordate))
# preTag=$(curl --silent "https://api.github.com/repos/chen08209/FlClash/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")' || echo "")
# currentTag=""
# for ((i = 0; i <= ${#tags[@]}; i++)); do
# if (( i < ${#tags[@]} )); then
# tag=${tags[$i]}
# else
# tag=""
# fi
# if [ -n "$currentTag" ]; then
# if [ "$(echo -e "$currentTag\n$preTag" | sort -V | head -n 1)" == "$currentTag" ]; then
# break
# fi
# fi
# if [ -n "$currentTag" ]; then
# if [ -n "$tag" ]; then
# git log --pretty=format:"%B" "$tag..$currentTag" | awk 'NF {print "- " $0} !NF {print ""}' >> release.md
# else
# git log --pretty=format:"%B" "$currentTag" | awk 'NF {print "- " $0} !NF {print ""}' >> release.md
# fi
# echo "" >> release.md
# fi
# currentTag=$tag
# done
#
# - name: Push to telegram
# env:
# TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
# TAG: ${{ github.ref_name }}
# run: |
# python -m pip install --upgrade pip
# pip install requests
# python release.py
#
# - name: Patch release.md
# run: |
# version=$(echo "${{ github.ref_name }}" | sed 's/^v//')
# sed "s|VERSION|$version|g" ./.github/release_template.md >> release.md
#
# - name: Release
# if: ${{ !contains(github.ref, '+') }}
# uses: softprops/action-gh-release@v2
# with:
# files: ./dist/*
# body_path: './release.md'
#
# - name: Create Fdroid Source Dir
# if: ${{ !contains(github.ref, '+') }}
# run: |
# mkdir -p ./tmp
# cp ./dist/*android-arm64-v8a* ./tmp/ || true
# echo "Files copied successfully"
#
# - name: Push to fdroid repo
# if: ${{ !contains(github.ref, '+') }}
# uses: cpina/github-action-push-to-another-repository@v1.7.2
# env:
# SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
# with:
# source-directory: ./tmp/
# destination-github-username: chen08209
# destination-repository-name: FlClash-fdroid-repo
# user-name: 'github-actions[bot]'
# user-email: 'github-actions[bot]@users.noreply.github.com'
# target-branch: action-pr
# commit-message: Update from ${{ github.ref_name }}
# target-directory: /tmp/
12 changes: 6 additions & 6 deletions setup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,10 @@ class BuildCommand extends Command {
arches.where((element) => element.name == archName).toList();
final arch = currentArches.isEmpty ? null : currentArches.first;

if (arch == null && !Platform.isAndroid) {
throw "Invalid arch parameter";
}

await Build.buildCore(
target: target,
arch: arch,
Expand Down Expand Up @@ -452,17 +456,13 @@ class BuildCommand extends Command {
Arch.arm64: "linux-arm64",
Arch.amd64: "linux-x64",
};
final defaultArches = [Arch.arm64, Arch.amd64];
final defaultTargets = defaultArches
.where((element) => arch == null ? true : element == arch)
.map((e) => targetMap[e])
.toList();
final defaultTarget = targetMap[arch];
await _getLinuxDependencies();
_buildDistributor(
target: target,
targets: "appimage,deb,rpm",
args:
"--description $archName --build-target-platform ${defaultTargets.join(",")}",
"--description $archName --build-target-platform $defaultTarget",
);
return;
case Target.android:
Expand Down

0 comments on commit 02a7239

Please sign in to comment.