Compile The New Clash Premium Core #246
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: Compile The New Clash Premium Core | |
on: | |
schedule: | |
- cron: "0 21 * * 1,3,5" | |
workflow_dispatch: | |
jobs: | |
Get-Commit-id: | |
runs-on: ubuntu-latest | |
outputs: | |
current_id: ${{ steps.current_id.outputs.current_id }} | |
upstream_id: ${{ steps.upstream_id.outputs.upstream_id }} | |
steps: | |
- name: Apt Update | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
sudo apt-get update | |
sudo apt-get -y install curl git gzip | |
- name: Clone OpenClash Repository | |
uses: actions/checkout@v4 | |
with: | |
ref: core | |
- name: Get Current Version | |
id: current_id | |
run: | | |
echo "current_id=$(sed -n 2p ./dev/core_version)" >> $GITHUB_OUTPUT | |
echo "current_id: $(sed -n 2p ./dev/core_version)" | |
- name: Get Upstream Version | |
id: upstream_id | |
run: | | |
cd .. | |
mkdir tmp | |
GZNAME="clash-latest.gz" | |
curl -kSL --retry 2 https://release.dreamacro.workers.dev/latest//clash-linux-amd64-latest.gz -o ./tmp/$GZNAME | |
gzip -d ./tmp/$GZNAME | |
chmod +x ./tmp/clash-latest | |
echo "upstream_id=$(./tmp/clash-latest -v |awk -F ' ' '{print $2}')" >> $GITHUB_OUTPUT | |
echo "upstream_id: $(./tmp/clash-latest -v |awk -F ' ' '{print $2}')" | |
Compile: | |
runs-on: ubuntu-latest | |
needs: Get-Commit-id | |
if: ${{ needs.Get-Commit-id.outputs.current_id != needs.Get-Commit-id.outputs.upstream_id }} | |
steps: | |
- name: Apt Update | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
sudo apt-get update | |
sudo apt-get -y install curl git tar gzip | |
- name: Setup UPX | |
run: | | |
cd .. | |
wget https://github.com/upx/upx/releases/download/v3.95/upx-3.95-amd64_linux.tar.xz | |
tar xf upx-3.95-amd64_linux.tar.xz | |
echo "upx=../upx-3.95-amd64_linux/upx" >> $GITHUB_ENV | |
- name: Clone OpenClash Repository | |
uses: actions/checkout@v4 | |
with: | |
ref: core | |
- name: Copy Scripts | |
run: | | |
cd .. | |
mkdir tmp | |
mkdir tmp/bin | |
cp ./OpenClash/.github/makefile/tun.sh ./tmp/tun.sh | |
- name: Compile Premium Clash | |
run: | | |
bash ../tmp/tun.sh | |
rm -rf ../tmp/tun.sh | |
- name: Change Version | |
run: | | |
sed -i '2d' ./dev/core_version | |
sed -i "2i ${{ needs.Get-Commit-id.outputs.upstream_id }}" ./dev/core_version | |
- name: Commit and push | |
run: | | |
rm -rf ./dev/premium/* | |
cp -rf "../tmp/." "./dev/premium/" | |
git config user.name 'github-actions[bot]' | |
git config user.email 'github-actions[bot]@users.noreply.github.com' | |
git add . | |
git commit -m "Auto update Premium core: ${{ needs.Get-Commit-id.outputs.upstream_id }}" | |
git push |