Update README.md #16
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: Build OpenClash Installer | |
on: | |
push: | |
branches: | |
- master | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Create OpenClash directory | |
run: mkdir OpenClash | |
- name: Checkout OpenClash to created directory | |
uses: actions/checkout@v4 | |
with: | |
repository: vernesong/OpenClash | |
path: OpenClash | |
ref: package | |
- name: list OpenClash ipk | |
run: ls OpenClash/master | |
# Step 2: Create little openclash directory | |
- name: Create little openclash directory | |
run: mkdir openclash | |
# Step 3: Copy latest IPK file from master | |
- name: Copy latest OpenClash IPK | |
run: cp OpenClash/master/*.ipk openclash/ | |
- name: Create Meta directory for git | |
run: mkdir Meta | |
- name: Checkout core | |
uses: actions/checkout@v4 | |
with: | |
repository: vernesong/OpenClash | |
path: Meta | |
ref: core | |
- name: list Meta/master/meta on core branch | |
run: ls Meta/master/meta | |
- name: Copy latest meta core | |
run: | | |
tar -xzvf Meta/master/meta/clash-linux-amd64.tar.gz -C openclash/ | |
mv openclash/clash openclash/clash_meta | |
ls openclash | |
# Step 4: Create install.sh script | |
- name: Create install.sh script | |
run: | | |
cat << 'EOF' > openclash/install.sh | |
opkg update | |
if [ $? -ne 0 ]; then | |
echo "update failed。" | |
exit 1 | |
fi | |
opkg install *.ipk || exit 1 | |
mv clash_meta /etc/openclash/core/ | |
sleep 10s | |
ifconfig br-lan > /dev/null 2>&1 | |
if [ $? -ne 0 ]; then | |
echo "接口错误,重启网络。" | |
/etc/init.d/network restart | |
echo "重启完毕" | |
exit 0 | |
fi | |
EOF | |
chmod +x openclash/install.sh | |
# git clone makeself for self-extracting installer | |
- name: Clone makeself repository | |
run: | | |
git clone https://github.com/megastep/makeself.git | |
# Step 6: Create self-extracting installer | |
- name: Create self-extracting installer | |
run: | | |
mv openclash makeself/ | |
cd makeself | |
ls | |
./makeself.sh openclash/ openclash-amd64.run "by github action" ./install.sh | |
# Step 7: Upload openclash.run to Release | |
- name: Generate new tag & release | |
uses: softprops/action-gh-release@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: MakeOpenClash | |
target_commitish: ${{ github.ref_name }} | |
prerelease: false | |
body: test release | |
- name: Upload run files as release assets | |
uses: softprops/action-gh-release@v2.1.0 | |
with: | |
tag_name: MakeOpenClash | |
files: makeself/*.run | |
token: ${{ secrets.GITHUB_TOKEN }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |