Skip to content

v1.2.4

v1.2.4 #26

Workflow file for this run

name: deploy_release
on:
release:
types: [published]
jobs:
deploy_release:
if: contains(github.event.release.body, '@@release.trigger_deploy@@')
runs-on: ubuntu-latest
steps:
- name: Install deploy key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Restore yushijinhun/authlib-injector.yushi.moe:master cache
uses: actions/cache@v1
with:
path: ~/deploy
key: cache-deploy
- name: Pull yushijinhun/authlib-injector.yushi.moe:master
shell: bash
run: |
if [ -d ~/deploy ]; then
cd ~/deploy
git fetch origin
git add --all
git reset --hard origin/master
else
git clone --single-branch --branch master "[email protected]:yushijinhun/authlib-injector.yushi.moe" ~/deploy
fi
- name: Deploy
shell: bash
run: |
release_body='${{ github.event.release.body }}'
build_number=$(grep -Pom1 '@@release\.build_number=\K.*(?=@@)' <<< $release_body)
version_number=$(grep -Pom1 '@@release\.version_number=\K.*(?=@@)' <<< $release_body)
asset_name='${{ github.event.release.assets[0].name }}'
release_published_at='${{ github.event.release.published_at }}'
cd ~/deploy
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
mkdir -p "artifact/$build_number"
wget -O "artifact/$build_number/$asset_name" '${{ github.event.release.assets[0].browser_download_url }}'
sha256=$(sha256sum "artifact/$build_number/$asset_name" | grep -P -o '^[0-9a-f]+')
jq -n \
--arg build_number "$build_number" \
--arg version "$version_number" \
--arg release_time "$release_published_at" \
--arg download_url "https://authlib-injector.yushi.moe/artifact/$build_number/$asset_name" \
--arg sha256 "$sha256" \
'
{
"build_number": $build_number|tonumber,
"version": $version,
"release_time": $release_time,
"download_url": $download_url,
"checksums": {
"sha256": $sha256
}
}
' > "artifact/$build_number.json"
for file in artifact/*; do
if basename -- "$file" | grep -q -P '^\d+\.json$'; then
jq '
{
"build_number": .build_number,
"version": .version
}' < "$file"
fi
done | jq -s 'sort_by(.build_number)|reverse|
{
"latest_build_number": max_by(.build_number).build_number,
"artifacts": .
}' > artifacts.json
latest_build_number=$(jq ".latest_build_number" < artifacts.json)
rm -f artifact/latest.json
ln -s "$latest_build_number.json" "artifact/latest.json"
git add --all
git commit -m "Deploy release $version_number ($build_number)
GitHub Action: https://github.com/${{ github.repository }}/actions/runs/$GITHUB_RUN_ID
"
git push "[email protected]:yushijinhun/authlib-injector.yushi.moe" master:master