Make OpenClash run files #21
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: | |
- main | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Create OpenClash & openclash directory for git & ipk | |
run: mkdir OpenClash openclash | |
- name: Checkout package branch to OpenClash directory | |
uses: actions/checkout@v4 | |
with: | |
repository: vernesong/OpenClash | |
path: OpenClash | |
ref: package | |
- name: Copy latest openclash IPK to openclash directory | |
run: cp OpenClash/master/*.ipk openclash/ | |
- name: Get version info | |
id: extract_version | |
run: | | |
first_line=$(head -n 1 OpenClash/master/version) | |
echo "::set-output name=version::$first_line" | |
second_line=$(sed -n '2p' OpenClash/master/version) | |
echo "::set-output name=svg::$second_line" | |
- name: Create Meta directory for git | |
run: mkdir Meta | |
- name: Checkout core branch to Meta directory | |
uses: actions/checkout@v4 | |
with: | |
repository: vernesong/OpenClash | |
path: Meta | |
ref: core | |
- name: list all cores on core branch | |
run: ls Meta/master/meta | |
- name: Copy latest meta core to openclash directory | |
run: | | |
tar -xzvf Meta/master/meta/clash-linux-amd64.tar.gz -C openclash/ | |
mv openclash/clash openclash/clash_meta | |
ls openclash | |
- name: Create install.sh script save to openclash directory | |
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 | |
- name: Clone makeself repository for self-extracting installer | |
run: | | |
git clone https://github.com/megastep/makeself.git | |
- name: move openclash directory to makeself & create run | |
run: | | |
mv openclash makeself/ | |
cd makeself | |
./makeself.sh openclash/ openclash-amd64.run "by github action" ./install.sh | |
- name: Generate new tag & release | |
uses: softprops/action-gh-release@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.extract_version.outputs.version }} | |
target_commitish: ${{ github.ref_name }} | |
prerelease: false | |
body: <img src="${{ steps.extract_version.outputs.svg }}"> | |
- name: Upload run files as release assets | |
uses: softprops/action-gh-release@v2.1.0 | |
with: | |
tag_name: ${{ steps.extract_version.outputs.version }} | |
files: makeself/*.run | |
token: ${{ secrets.GITHUB_TOKEN }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |