Skip to content

Auto Update Version #38

Auto Update Version

Auto Update Version #38

Workflow file for this run

name: Launcher
run-name: Auto Update Version
on:
schedule:
- cron: 0 16 * * *
workflow_dispatch:
jobs:
update:
name: Update Launcher
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
max-parallel: 1
matrix:
include:
- subtitle: HMCL
url: https://github.com/HMCL-dev/HMCL
- subtitle: HMCL-PE
url: https://github.com/HMCL-dev/HMCL-PE
- subtitle: PCL2
url: https://github.com/Hex-Dragon/PCL2
- subtitle: FCL
url: https://github.com/FCL-Team/FoldCraftLauncher
- subtitle: PojavLauncher
url: https://github.com/PojavLauncherTeam/PojavLauncher
device: Android
- subtitle: PojavLauncher
url: https://github.com/PojavLauncherTeam/PojavLauncher_iOS
device: iOS
- subtitle: ColorMC
url: https://github.com/Coloryr/ColorMC
device: Windows|macOS|Linux
- subtitle: ColorMC
url: https://github.com/Coloryr/ColorMC.Android
device: Android
- subtitle: XMCL
url: https://github.com/Voxelum/x-minecraft-launcher
- subtitle: Prism
url: https://github.com/PrismLauncher/PrismLauncher
steps:
- uses: actions/checkout@main
- name: Handle files
id: handle
run: |
git pull --rebase
API=`echo ${{ matrix.url }} | sed 's/:\/\/github\.com\//:\/\/api.github.com\/repos\//g' | sed 's/$/\/releases/g'`
wget -O latest.json $API/latest || echo '{"tag_name":""}' > latest.json
wget -O releases.json $API
if [ '${{ matrix.device }}' ]; then
DEVICE_LIST=`echo '${{ matrix.device }}' | sed 's/|/\\\\|/g'`
sed -n '/\('"$DEVICE_LIST"'\)Launcher/,/]/p' data/launcher.js > launcher.js
else
cp data/launcher.js launcher.js
fi
- name: Get ${{ matrix.subtitle }} version
id: get
run: |
# Get Last Stable ${{ matrix.subtitle }}
LAST_STABLE_VERSION=`sed -n '/"${{ matrix.subtitle }}"/,/version:/p' launcher.js | sed -n '$p' | sed 's/^.*:\s*"v\?\|",$//gi' | sed 's/\./\\\\./g'`
# Get Last Dev ${{ matrix.subtitle }}
LAST_DEV_VERSION=`sed -n '/"${{ matrix.subtitle }}"/,/}/p' launcher.js | sed -n '/dev:/,/version:/p' | sed -n '$p' | sed 's/^.*:\s*"v\?\|"$//gi' | sed 's/\./\\\\./g'`
# GET Latest Stable ${{ matrix.subtitle }}
if [ '${{ matrix.subtitle }}' = HMCL ]; then
LATEST_STABLE_VERSION=`cat releases.json | sed -n '/"tag_name":\s*"release-/p' | sed -n 1p | sed 's/^.*release-\|",$//g' | sed 's/\./\\\\./g'`
else
LATEST_STABLE_VERSION=`cat latest.json | jq .tag_name | sed 's/^"v\?\|"$//gi' | sed 's/\./\\\\./g'`
fi
if [ ${#LATEST_STABLE_VERSION} = 0 ]; then
unset LAST_STABLE_VERSION
fi
# GET Latest Dev ${{ matrix.subtitle }}
if [ "$LAST_DEV_VERSION" ]; then
LATEST_DEV_VERSION=`cat releases.json | sed -n '/"tag_name":/p' | sed -n 1p | sed 's/^.*:\s*"v\?\|",$//gi' | sed 's/\./\\\\./g'`
if [ "$LATEST_DEV_VERSION" = "$LATEST_STABLE_VERSION" ]; then
unset LATEST_DEV_VERSION
fi
fi
# Remove Needless Files
rm latest.json releases.json launcher.js
# Output
echo "last_stable_version=$LAST_STABLE_VERSION" >> $GITHUB_OUTPUT
echo "last_dev_version=$LAST_DEV_VERSION" >> $GITHUB_OUTPUT
echo "latest_stable_version=$LATEST_STABLE_VERSION" >> $GITHUB_OUTPUT
echo "latest_dev_version=$LATEST_DEV_VERSION" >> $GITHUB_OUTPUT
- name: Modify launcher.js
id: modify
run: |
LAST_STABLE_VERSION='${{ steps.get.outputs.last_stable_version }}'
LAST_DEV_VERSION='${{ steps.get.outputs.last_dev_version }}'
LATEST_STABLE_VERSION='${{ steps.get.outputs.latest_stable_version }}'
LATEST_DEV_VERSION='${{ steps.get.outputs.latest_dev_version }}'
if [ '${{ matrix.device }}' ]; then
DEVICE_STRING=' [${{ matrix.device }}]'
else
DEVICE_STRING=''
fi
if [ "$LATEST_STABLE_VERSION" ]; then
if [ "$LAST_STABLE_VERSION" != "$LATEST_STABLE_VERSION" ]; then
sed -i 's/\([/"v-]\)'"$LAST_STABLE_VERSION"'\(\.[a-z]\|["/-]\)/\1'"$LATEST_STABLE_VERSION"'\2/gi' data/launcher.js
LAST_STABLE_VERSION=`echo $LAST_STABLE_VERSION | sed 's/\\\\././g'`
LATEST_STABLE_VERSION=`echo $LATEST_STABLE_VERSION | sed 's/\\\\././g'`
CHANGELOG_E=' ${{ matrix.subtitle }}(stable): '"$LAST_STABLE_VERSION => $LATEST_STABLE_VERSION$DEVICE_STRING"
fi
fi
if [ "$LATEST_DEV_VERSION" ]; then
if [ "$LAST_DEV_VERSION" != "$LATEST_DEV_VERSION" ]; then
sed -i 's/\([/"v-]\)'"$LAST_DEV_VERSION"'\(\.[a-z]\|["/-]\)/\1'"$LATEST_DEV_VERSION"'\2/gi' data/launcher.js
LAST_DEV_VERSION=`echo $LAST_DEV_VERSION | sed 's/\\\\././g'`
LATEST_DEV_VERSION=`echo $LATEST_DEV_VERSION | sed 's/\\\\././g'`
if [ "$CHANGELOG_E" ]; then
CHANGELOG_E="${CHANGELOG_E}"'#n ${{ matrix.subtitle }}(dev): '"$LAST_DEV_VERSION => $LATEST_DEV_VERSION$DEVICE_STRING"
else
CHANGELOG_E=' ${{ matrix.subtitle }}(dev): '"$LAST_DEV_VERSION => $LATEST_DEV_VERSION$DEVICE_STRING"
fi
fi
fi
if [ "$CHANGELOG_E" ]; then
CHANGELOG=`echo "$CHANGELOG_E" | sed 's/#n/\n/g'`
echo ===============================================================
echo "$CHANGELOG"
echo ===============================================================
echo "changelog=$CHANGELOG_E" >> $GITHUB_OUTPUT
fi
- name: Commit changes
id: commit
continue-on-error: true
run: |
git config --global user.name teaSummer
git config --global user.email see_tea@outlook.com
CHANGELOG=`echo '${{ steps.modify.outputs.changelog }}' | sed 's/#n/\n/g'`
git commit -am 'modify: update ${{ matrix.subtitle }}
[Auto] Update Launcher Version:
'"$CHANGELOG
(Time: `date +'%F %X %Z'`)"
- name: Push changes
if: ${{ steps.commit.outcome == 'success' }}
id: push
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.TOKEN }}
branch: main
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: update
steps:
- name: Run remote commands
id: run
uses: fifsky/ssh-action@master
with:
host: ${{ secrets.HOST }}
port: ${{ secrets.PORT }}
key: ${{ secrets.KEY }}
command: |
echo ===============================================================
cd /www/wwwroot/mcisee.top
git pull
echo ===============================================================