Skip to content

Compile The New Clash Dev Core #349

Compile The New Clash Dev Core

Compile The New Clash Dev Core #349

name: Compile The New Clash Dev Core
on:
schedule:
- cron: "0 19 * * 1,3,5,6"
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 git
- name: Clone OpenClash Repository
uses: actions/checkout@v4
with:
ref: core
- name: Get Current Version
id: current_id
run: |
echo "current_id=$(sed -n 1p ./dev/core_version)" >> $GITHUB_OUTPUT
echo "current_id: $(sed -n 1p ./dev/core_version)"
- name: Clone Clash Repository
uses: actions/checkout@v4
with:
repository: Dreamacro/clash
ref: dev
fetch-depth: '0'
- name: Get Upstream Version
id: upstream_id
run: |
echo "upstream_id=$(git describe --tags)" >> $GITHUB_OUTPUT
echo "upstream_id: $(git describe --tags)"
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 wget git tar
- 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 Makefile
run: |
cd ..
mkdir tmp
mkdir tmp/bin
cp ./OpenClash/.github/makefile/dev ./tmp/Makefile
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: "1.21"
check-latest: true
- name: Clone Clash Repository
uses: actions/checkout@v4
with:
repository: Dreamacro/clash
ref: dev
fetch-depth: '0'
- name: Compile Dev Clash
run: |
cp ../tmp/Makefile ./Makefile
make releases
- name: Copy Clash Bin
run: |
cp -rf "./bin/." "../tmp/bin/"
- name: Clone OpenClash Repository
uses: actions/checkout@v4
with:
ref: core
- name: Change Version
run: |
sed -i '1d' ./dev/core_version
sed -i "1i ${{ needs.Get-Commit-id.outputs.upstream_id }}" ./dev/core_version
- name: Commit and push
run: |
rm -rf ./dev/dev/*
cp -rf "../tmp/bin/." "./dev/dev/"
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 Dev core: ${{ needs.Get-Commit-id.outputs.upstream_id }}"
git push