2025-01-10 00:37:11 +00:00
|
|
|
name: Fetch and Publish Latest Release
|
|
|
|
|
|
|
|
on:
|
|
|
|
schedule:
|
|
|
|
- cron: '0 18 * * *' # 3:00 AM GMT+9
|
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
tag_name:
|
|
|
|
description: 'Tag name for the manual release'
|
|
|
|
required: true
|
2025-01-11 03:17:47 +00:00
|
|
|
default: "manual"
|
2025-01-10 00:40:13 +00:00
|
|
|
push:
|
|
|
|
branches:
|
2025-01-10 00:40:40 +00:00
|
|
|
- main
|
2025-01-10 00:37:11 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
fetch-and-publish:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout this repository
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Fetch latest release from Vita3K
|
|
|
|
id: fetch_release
|
|
|
|
run: |
|
|
|
|
latest_release=$(curl -s https://api.github.com/repos/Vita3K/Vita3K/releases/latest)
|
2025-01-10 01:07:14 +00:00
|
|
|
tag_name="$(echo $latest_release | jq -r .tag_name)"
|
2025-01-10 00:59:56 +00:00
|
|
|
|
|
|
|
# fetching assets
|
|
|
|
mkdir -p artifacts
|
2025-01-10 01:13:02 +00:00
|
|
|
for url in $(echo $latest_release | jq -r '.assets[] | .browser_download_url'); do
|
2025-01-10 00:59:56 +00:00
|
|
|
wget -P artifacts $url
|
|
|
|
done
|
|
|
|
|
2025-01-10 01:14:49 +00:00
|
|
|
ls -lah artifacts
|
|
|
|
|
2025-01-10 01:09:43 +00:00
|
|
|
release_name="$(echo $latest_release | jq -r .body | grep -oP 'Vita3K Build: \d+' | sed 's/Vita3K Build: /Vita3K - Build /')"
|
2025-01-10 01:15:58 +00:00
|
|
|
echo "release_name=$release_name"
|
2025-01-10 01:07:14 +00:00
|
|
|
|
2025-01-10 01:09:43 +00:00
|
|
|
commit_hash="$(echo $latest_release | jq -r .body | grep -oP 'Corresponding commit: \K[0-9a-f]{40}')"
|
2025-01-10 01:15:58 +00:00
|
|
|
echo "commit_hash=$commit_hash"
|
|
|
|
|
2025-01-10 01:24:44 +00:00
|
|
|
release_body+="Corresponding commit: [$commit_hash](https://github.com/Vita3K/Vita3K/commit/$commit_hash)</br>"
|
2025-01-10 01:19:56 +00:00
|
|
|
release_body+="$release_name"
|
2025-01-10 01:15:58 +00:00
|
|
|
echo "release_body=$release_body"
|
2025-01-10 01:01:32 +00:00
|
|
|
|
2025-01-11 03:17:47 +00:00
|
|
|
build_number="${release_name//Vita3K - Build /}"
|
|
|
|
echo "build_number=$build_number" >> $GITHUB_ENV
|
|
|
|
|
2025-01-10 00:54:10 +00:00
|
|
|
echo "tag_name=$tag_name" >> $GITHUB_ENV
|
|
|
|
echo "release_body=$release_body" >> $GITHUB_ENV
|
2025-01-10 00:48:15 +00:00
|
|
|
echo "release_name=$release_name" >> $GITHUB_ENV
|
2025-01-10 00:59:56 +00:00
|
|
|
|
2025-01-10 00:37:11 +00:00
|
|
|
- name: Create release in this repository
|
|
|
|
id: create_release
|
|
|
|
uses: actions/create-release@v1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
2025-01-11 03:17:47 +00:00
|
|
|
tag_name: ${{ env.build_number }}
|
2025-01-10 00:48:15 +00:00
|
|
|
release_name: ${{ env.release_name }}
|
|
|
|
body: ${{ env.release_body }}
|
2025-01-10 00:37:11 +00:00
|
|
|
draft: false
|
|
|
|
prerelease: false
|
|
|
|
|
|
|
|
- name: Upload assets to the new release
|
2025-01-10 01:23:22 +00:00
|
|
|
run: |
|
|
|
|
for file in artifacts/*; do
|
|
|
|
echo "Uploading $file..."
|
|
|
|
gh release upload ${{ env.tag_name }} "$file" --clobber
|
|
|
|
done
|
2025-01-11 03:05:39 +00:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Check for ubuntu-latest.zip and delete release if not found
|
|
|
|
run: |
|
|
|
|
if ! ls artifacts | grep -q 'ubuntu-latest.zip'; then
|
|
|
|
echo "ubuntu-latest.zip not found. Deleting release..."
|
|
|
|
gh release delete ${{ env.tag_name }} --yes
|
|
|
|
exit 1
|
|
|
|
fi
|
2025-01-10 00:37:11 +00:00
|
|
|
env:
|
2025-01-10 01:23:22 +00:00
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|