Files
homebrew-software/.github/workflows/bump-apprenticevr.yml
Darwin Cereska efd676ef34 fix workflow
2025-08-07 03:11:19 -04:00

108 lines
3.8 KiB
YAML

name: Bump ApprenticeVR Cask
on:
workflow_dispatch:
schedule:
- cron: '0 */6 * * *' # every 6 hours (fixed cron syntax)
jobs:
bump:
runs-on: ubuntu-latest
steps:
- name: Checkout tap repo
uses: actions/checkout@v4 # updated to v4
with:
persist-credentials: true
- name: Fetch latest release from GitHub
id: fetch
uses: actions/github-script@v7 # updated to v7
with:
script: |
const release = await github.rest.repos.getLatestRelease({
owner: 'jimzrt',
repo: 'apprenticeVr'
});
const version = release.data.tag_name;
const cleanVersion = version.replace(/^v/, ''); // Remove 'v' prefix
core.setOutput("version", cleanVersion);
core.setOutput("tag_name", version);
// Construct the expected filename and URL
const expectedFilename = `apprenticevr-${cleanVersion}-arm64.dmg`;
const downloadUrl = `https://github.com/jimzrt/apprenticeVr/releases/download/${version}/${expectedFilename}`;
core.setOutput("download_url", downloadUrl);
core.setOutput("asset_name", expectedFilename);
- name: Download DMG and compute SHA256
id: compute
run: |
DOWNLOAD_URL="${{ steps.fetch.outputs.download_url }}"
ASSET_NAME="${{ steps.fetch.outputs.asset_name }}"
echo "Downloading: $DOWNLOAD_URL"
curl -L -o "$ASSET_NAME" "$DOWNLOAD_URL"
SHA256=$(sha256sum "$ASSET_NAME" | awk '{ print $1 }')
echo "Computed SHA256: $SHA256"
echo "sha256=$SHA256" >> $GITHUB_OUTPUT
- name: Check current cask version
id: current
run: |
CASK_FILE="Casks/apprenticevr.rb"
if [ -f "$CASK_FILE" ]; then
CURRENT_VERSION=$(grep -o 'version "[^"]*"' "$CASK_FILE" | sed 's/version "\([^"]*\)"/\1/')
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "Current version: $CURRENT_VERSION"
else
echo "Cask file not found: $CASK_FILE"
exit 1
fi
- name: Update cask file
run: |
VERSION="${{ steps.fetch.outputs.version }}"
SHA256="${{ steps.compute.outputs.sha256 }}"
CURRENT_VERSION="${{ steps.current.outputs.current_version }}"
CASK_FILE="Casks/apprenticevr.rb"
echo "Current version: $CURRENT_VERSION"
echo "New version: $VERSION"
if [ "$VERSION" = "$CURRENT_VERSION" ]; then
echo "Version unchanged, skipping update"
echo "skip_commit=true" >> $GITHUB_ENV
else
echo "Updating $CASK_FILE to version $VERSION with SHA256 $SHA256"
# Update version
sed -i "s/version \"[^\"]*\"/version \"$VERSION\"/g" "$CASK_FILE"
# Update SHA256
sed -i "s/sha256 \"[^\"]*\"/sha256 \"$SHA256\"/g" "$CASK_FILE"
echo "Updated cask file:"
cat "$CASK_FILE"
fi
- name: Commit and push changes
if: env.skip_commit != 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Casks/apprenticevr.rb
if ! git diff --cached --quiet; then
VERSION="${{ steps.fetch.outputs.version }}"
git commit -m "bump: Updated apprenticeVr to $VERSION"
git push
echo "Successfully updated apprenticevr cask to version $VERSION"
else
echo "No changes to commit"
fi