Synchronize warp-go #251
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: Synchronize warp-go | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '3 2 * * *' | |
jobs: | |
build: | |
name: Synchronize warp-go | |
runs-on: ubuntu-latest | |
env: | |
FILE_DIR: warp-go | |
steps: | |
- uses: actions/checkout@v4.2.2 | |
- name: Synchronize warp-go to the latest version | |
run: | | |
NOW=$(wget -qO- https://raw.githubusercontent.com/${{ github.repository }}/main/warp-go.sh | grep 'latest=${latest' | cut -d \' -f2) | |
LATEST=$(wget -qO- -T1 -t1 https://gitlab.com/api/v4/projects/ProjectWARP%2Fwarp-go/releases | grep -oP '"tag_name":"v\K[^\"]+' | head -n 1) | |
if [ "$LATEST" != "$NOW" ]; then | |
[ ! -d ${{ env.FILE_DIR }} ] && mkdir -p ${{ env.FILE_DIR }} | |
PLATFORM=( "linux_386" | |
"linux_amd64" | |
"linux_amd64v2" | |
"linux_amd64v3" | |
"linux_amd64v4" | |
"linux_arm64" | |
"linux_386" | |
"linux_s390x" | |
) | |
SCRIPTS=( "warp-go.sh" | |
) | |
for i in "${PLATFORM[@]}"; do | |
wget -NP ${{ env.FILE_DIR }} https://gitlab.com/ProjectWARP/warp-go/-/releases/v"$LATEST"/downloads/warp-go_"$LATEST"_"$i".tar.gz | |
rm -f ${{ env.FILE_DIR }}/warp-go_"$NOW"_"$i".tar.gz | |
done | |
for j in "${SCRIPTS[@]}"; do | |
sed -i "/判断 warp-go 的最新版本/s/$NOW/$LATEST/; /latest=\${/s/$NOW/$LATEST/" $j || true | |
done | |
echo "VERSION=$LATEST" >> $GITHUB_ENV | |
echo "DATE=$(date "+%Y/%m/%d %H:%M:%S")" >> $GITHUB_ENV | |
fi | |
- name: Upload to repository | |
uses: stefanzweifel/git-auto-commit-action@v5.0.1 | |
if: ${{ env.VERSION != '' }} | |
with: | |
commit_message: Sync warp-go to V${{ env.VERSION }} by Github Actions, ${{ env.DATE }} | |
- name: Release binaries | |
uses: softprops/action-gh-release@v2 | |
if: ${{ env.VERSION != '' }} | |
with: | |
tag_name: warp-go_v${{ env.VERSION }} | |
files: ${{ env.FILE_DIR }}/* |