Make Passwall run files #30
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
#================================================= | |
# https://github.com/wukongdaily/RunFilesBuilder | |
# Description: Build RunFiles using GitHub Actions | |
# Lisence: MIT | |
# Author: wukongdaily | |
# Blog: wkdaily.cpolar.top | |
#================================================= | |
name: Make Passwall run files | |
on: | |
schedule: | |
- cron: '0 */6 * * *' | |
workflow_dispatch: | |
jobs: | |
build: | |
if: ${{ github.repository == 'wukongdaily/RunFilesBuilder' || github.event_name == 'workflow_dispatch' }} | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Fetch latest release tag from Passwall | |
id: fetch_latest_tag | |
run: | | |
latest_tag=$(curl -s https://api.github.com/repos/xiaorouji/openwrt-passwall/releases/latest | jq -r '.tag_name') | |
echo "LATEST_TAG=$latest_tag" >> $GITHUB_ENV | |
- name: Clone makeself repository | |
run: git clone https://github.com/megastep/makeself.git | |
- name: Download latest Passwall files | |
run: | | |
mkdir -p downloads | |
cd downloads | |
curl -LO $(curl -s https://api.github.com/repos/xiaorouji/openwrt-passwall/releases/latest | grep -oP '"browser_download_url":\s*".*passwall_packages_ipk_x86_64.zip"' | cut -d '"' -f 4) | |
curl -LO $(curl -s https://api.github.com/repos/xiaorouji/openwrt-passwall/releases/latest | grep -oP '"browser_download_url":\s*".*passwall_packages_ipk_aarch64_cortex-a53.zip"' | cut -d '"' -f 4) | |
curl -LO $(curl -s https://api.github.com/repos/xiaorouji/openwrt-passwall/releases/latest | grep -oP '"browser_download_url":\s*".*luci-19.07.*\.ipk"' | head -1 | cut -d '"' -f 4) | |
curl -LO $(curl -s https://api.github.com/repos/xiaorouji/openwrt-passwall/releases/latest | grep -oP '"browser_download_url":\s*".*luci-19.07.*\.ipk"' | tail -1 | cut -d '"' -f 4) | |
- name: Organize files for x86_64 | |
run: | | |
mkdir -p passwall_x86_64/depends passwall_x86_64/main | |
unzip downloads/passwall_packages_ipk_x86_64.zip -d passwall_x86_64/depends | |
rm downloads/passwall_packages_ipk_x86_64.zip | |
cp downloads/luci-19.07*.ipk passwall_x86_64/main/ | |
- name: Organize files for aarch64_cortex-a53 | |
run: | | |
mkdir -p passwall_aarch64/depends passwall_aarch64/main | |
unzip downloads/passwall_packages_ipk_aarch64_cortex-a53.zip -d passwall_aarch64/depends | |
rm downloads/passwall_packages_ipk_aarch64_cortex-a53.zip | |
cp downloads/luci-19.07*.ipk passwall_aarch64/main/ | |
- name: Create install.sh scripts | |
run: | | |
cat <<EOF > passwall_x86_64/install.sh | |
#!/bin/sh | |
opkg update | |
if [ $? -ne 0 ]; then | |
echo "update failed。" | |
exit 1 | |
fi | |
opkg install depends/*.ipk | |
opkg install main/*.ipk | |
EOF | |
chmod +x passwall_x86_64/install.sh | |
cp passwall_x86_64/install.sh passwall_aarch64/install.sh | |
- name: Move passwall directories to makeself | |
run: | | |
mv passwall_x86_64 makeself/ | |
mv passwall_aarch64 makeself/ | |
- name: Create self-extracting packages | |
run: | | |
cd makeself | |
./makeself.sh passwall_x86_64/ passwall_x86_64_${{ env.LATEST_TAG }}.run "by github action" ./install.sh | |
./makeself.sh passwall_aarch64/ passwall_aarch64_a53_${{ env.LATEST_TAG }}.run "by github action" ./install.sh | |
- name: Check file sizes | |
run: | | |
ls -lh makeself/passwall_*.run | |
- name: Preparing release name | |
run: | | |
release_name=$(TZ="Asia/Shanghai" date +'%Y-%m-%d %H:%M Build') | |
echo "RELEASE_NAME=$release_name" >> $GITHUB_ENV | |
- name: Fetch latest release details | |
id: fetch_release_details | |
run: | | |
extra_content="![Github](https://img.shields.io/badge/Passwall.run-123456?logo=github&logoColor=fff&labelColor=green&style=for-the-badge) [![Github](https://img.shields.io/badge/国内加速站下载-FC7C0D?logo=github&logoColor=fff&labelColor=000&style=for-the-badge)](https://wkdaily.cpolar.top/archives/1) ![GitHub Downloads (all assets, specific tag)](https://img.shields.io/github/downloads/wukongdaily/RunFilesBuilder/${{ env.LATEST_TAG }}/total?style=for-the-badge&labelColor=black&color=%2325c2a0)" | |
release_notes=$(curl -s https://api.github.com/repos/xiaorouji/openwrt-passwall/releases/latest | jq -r '.body') | |
if [ -z "$release_notes" ]; then | |
release_notes="No release notes available." | |
fi | |
echo -e "$extra_content\n\n$release_notes" > release_notes.md | |
- name: Print release notes | |
run: | | |
cat release_notes.md | |
- name: Generate new tag & release | |
uses: softprops/action-gh-release@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.LATEST_TAG }} | |
target_commitish: ${{ github.ref_name }} | |
prerelease: false | |
body_path: release_notes.md | |
- name: Upload run files as release assets | |
uses: softprops/[email protected] | |
with: | |
tag_name: ${{ env.LATEST_TAG }} | |
files: makeself/passwall_*.run | |
token: ${{ secrets.GITHUB_TOKEN }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |