mirror of
https://github.com/RetroDECK/XRoar.git
synced 2025-06-05 09:20:51 +00:00
90 lines
3.9 KiB
YAML
90 lines
3.9 KiB
YAML
name: Check and Publish New XRoar Release
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
schedule:
|
|
- cron: '0 6 * * *' # Runs daily at 6:00 UTC
|
|
|
|
jobs:
|
|
check-xroar-release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: 'Checkout repository'
|
|
uses: actions/checkout@v4
|
|
|
|
- name: 'Get latest GitHub release tag'
|
|
id: get_latest_release
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const releases = await github.rest.repos.listReleases({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
per_page: 1
|
|
});
|
|
if (releases.data.length === 0) {
|
|
core.setFailed('No releases found');
|
|
} else {
|
|
const tag = releases.data[0].tag_name;
|
|
core.setOutput('tag', tag);
|
|
}
|
|
|
|
- name: 'Fetch XRoar website'
|
|
id: fetch_xroar_page
|
|
run: |
|
|
curl -sSL https://www.6809.org.uk/xroar/ > xroar_page.html
|
|
|
|
- name: 'Extract version from XRoar page'
|
|
id: extract_version
|
|
run: |
|
|
version=$(grep -oP 'Source code version \K[0-9]+\.[0-9]+\.[0-9]+' xroar_page.html | head -n1)
|
|
echo "version=$version" >> $GITHUB_OUTPUT
|
|
|
|
- name: 'Compare versions'
|
|
id: compare_versions
|
|
run: |
|
|
latest_tag="${{ steps.get_latest_release.outputs.tag }}"
|
|
web_version="${{ steps.extract_version.outputs.version }}"
|
|
echo "Latest tag: $latest_tag"
|
|
echo "Web version: $web_version"
|
|
if [[ "$latest_tag" == "$web_version" ]]; then
|
|
echo "No new version found."
|
|
echo "update_needed=false" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "New version detected."
|
|
echo "update_needed=true" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: 'Extract download link from XRoar page'
|
|
if: steps.compare_versions.outputs.update_needed == 'true'
|
|
id: extract_download_link
|
|
run: |
|
|
version="${{ steps.extract_version.outputs.version }}"
|
|
url=$(grep -oP "https://www.6809.org.uk/xroar/dl/xroar-${version}\.tar\.gz" xroar_page.html | head -n1)
|
|
if [ -z "$url" ]; then
|
|
echo "Download link not found"
|
|
exit 1
|
|
fi
|
|
echo "url=$url" >> $GITHUB_OUTPUT
|
|
|
|
- name: 'Download and extract new source'
|
|
if: steps.compare_versions.outputs.update_needed == 'true'
|
|
run: |
|
|
url="${{ steps.extract_download_link.outputs.url }}"
|
|
curl -sSL "$url" -o xroar.tar.gz
|
|
tar -xzf xroar.tar.gz --strip-components=1
|
|
|
|
- name: 'Commit and push updated source'
|
|
if: steps.compare_versions.outputs.update_needed == 'true'
|
|
run: |
|
|
git config --global user.name "github-actions[bot]"
|
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
git checkout -b "update-xroar-${{ steps.extract_version.outputs.version }}"
|
|
git add .
|
|
git commit -m "Update XRoar source to version ${{ steps.extract_version.outputs.version }}"
|
|
git push --set-upstream origin "update-xroar-${{ steps.extract_version.outputs.version }}"
|
|
|
|
- name: 'Build XRoar (placeholder)'
|
|
if: steps.compare_versions.outputs.update_needed == 'true'
|
|
run: |
|
|
echo "TODO: Add build steps here" |