Skip to content

Update Luau/Lute

Update Luau/Lute #56

Workflow file for this run

name: Update Luau/Lute
on:
schedule:
- cron: "0 0 * * 6"
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
update-luau:
runs-on: ubuntu-latest
outputs:
pull-request-url: ${{ steps.create-pr.outputs.pull-request-url }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Get latest Luau release
id: latest-release
run: |
# Fetch the latest release tag from luau-lang/luau
LATEST_TAG=$(curl -s https://api.github.com/repos/luau-lang/luau/releases/latest | jq -r '.tag_name')
echo "Latest Luau release: $LATEST_TAG"
echo "tag=$LATEST_TAG" >> $GITHUB_OUTPUT
# Fetch the commit hash for this tag
COMMIT_HASH=$(curl -s https://api.github.com/repos/luau-lang/luau/git/ref/tags/$LATEST_TAG | jq -r '.object.sha')
echo "Commit hash: $COMMIT_HASH"
echo "commit=$COMMIT_HASH" >> $GITHUB_OUTPUT
- name: Check current version
id: current-version
run: |
CURRENT_BRANCH=$(grep '^branch' extern/luau.tune | sed -E 's/^branch *= *"(.*)"/\1/')
echo "Current Luau version: $CURRENT_BRANCH"
echo "branch=$CURRENT_BRANCH" >> $GITHUB_OUTPUT
- name: Update version files
if: steps.current-version.outputs.branch != steps.latest-release.outputs.tag
run: |
# Update the branch and revision in luau.tune if needed
if [ "${{ steps.current-version.outputs.branch }}" != "${{ steps.latest-release.outputs.tag }}" ]; then
sed -i 's/^branch = ".*"/branch = "${{ steps.latest-release.outputs.tag }}"/' extern/luau.tune
sed -i 's/^revision = ".*"/revision = "${{ steps.latest-release.outputs.commit }}"/' extern/luau.tune
echo "Updated luau.tune:"
cat extern/luau.tune
fi
- name: Create Pull Request
id: create-pr
if: steps.current-version.outputs.branch != steps.latest-release.outputs.tag
uses: luau-lang/create-pull-request@v7.0.9
with:
commit-message: "chore: update dependencies"
title: "Update Luau to ${{ steps.latest-release.outputs.tag }}"
body: |
${{ format('**Luau**: Updated from `{0}` to `{1}`', steps.current-version.outputs.branch, steps.latest-release.outputs.tag) }}
**Release Notes:**
${{ format('https://github.com/luau-lang/luau/releases/tag/{0}', steps.latest-release.outputs.tag) }}
---
*This PR was automatically created by the [Update Luau workflow](https://github.com/${{ github.repository }}/actions/workflows/update-prs.yml)*
branch: update-luau
delete-branch: true
base: primary
- name: No update needed
if: steps.current-version.outputs.branch == steps.latest-release.outputs.tag
run: |
echo "Luau is already up to date: ${{ steps.current-version.outputs.branch }}"
update-lute:
runs-on: ubuntu-latest
needs: update-luau
outputs:
pull-request-url: ${{ steps.create-pr.outputs.pull-request-url }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Get latest Lute release
id: latest-release
run: |
# Fetch the latest release tag from luau-lang/lute
LATEST_LUTE=$(
curl -s https://api.github.com/repos/luau-lang/lute/releases \
| jq -r 'map(select(.draft | not))[0]?.tag_name'
)
echo "Latest Lute release: $LATEST_LUTE"
echo "tag=$LATEST_LUTE" >> $GITHUB_OUTPUT
# rokit/foreman versions are SemVer and must not include a leading "v"
LATEST_LUTE_VERSION="${LATEST_LUTE#v}"
echo "Latest Lute version: $LATEST_LUTE_VERSION"
echo "version=$LATEST_LUTE_VERSION" >> $GITHUB_OUTPUT
- name: Check current version
id: current-version
run: |
CURRENT_LUTE=$(grep '^lute = ' rokit.toml | sed -E 's/^lute = ".*@(.*)"/\1/')
echo "Current Lute version: $CURRENT_LUTE"
echo "lute=$CURRENT_LUTE" >> $GITHUB_OUTPUT
- name: Update version files
run: |
# Update lute version in rokit.toml and foreman.toml
if [ "${{ steps.current-version.outputs.lute }}" != "${{ steps.latest-release.outputs.version }}" ]; then
sed -i 's/^lute = "luau-lang\/lute@.*"/lute = "luau-lang\/lute@${{ steps.latest-release.outputs.version }}"/' rokit.toml
echo "Updated rokit.toml:"
cat rokit.toml
echo ""
sed -i 's/^lute = { github = "luau-lang\/lute", version = ".*" }/lute = { github = "luau-lang\/lute", version = "=${{ steps.latest-release.outputs.version }}" }/' foreman.toml
echo "Updated foreman.toml:"
cat foreman.toml
fi
- name: Create Pull Request
id: create-pr
if: steps.current-version.outputs.lute != steps.latest-release.outputs.version
uses: luau-lang/create-pull-request@v7.0.9
with:
commit-message: "chore: update dependencies"
title: "Update Lute to ${{ steps.latest-release.outputs.tag }}"
body: |
${{ format('**Lute**: Updated from `{0}` to `{1}`', steps.current-version.outputs.lute, steps.latest-release.outputs.version)}}
**Release Notes:**
${{ format('https://github.com/luau-lang/lute/releases/tag/{0}', steps.latest-release.outputs.tag)}}
---
*This PR was automatically created by the [Update Luau workflow](https://github.com/${{ github.repository }}/actions/workflows/update-prs.yml)*
branch: update-lute
delete-branch: true
- name: No update needed
if: steps.current-version.outputs.lute == steps.latest-release.outputs.version
run: |
echo "Lute is already up to date: ${{ steps.current-version.outputs.lute }}"
notify:
runs-on: ubuntu-latest
needs: [update-luau, update-lute]
if: always()
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
steps:
- name: Send Slack notification
run: |
CHANNEL_ID="${{ secrets.SLACK_CHANNEL_ID }}"
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
if [[ "${{ needs.update-luau.result }}" == "success" && "${{ needs.update-lute.result }}" == "success" ]]; then
TEXT=":meow_code: *Update Luau/Lute workflow succeeded*"
LUAU_PR="${{ needs.update-luau.outputs.pull-request-url }}"
LUTE_PR="${{ needs.update-lute.outputs.pull-request-url }}"
if [[ -n "$LUAU_PR" ]]; then
ESCAPED=$'\n• Luau PR: '
TEXT="$TEXT$ESCAPED <$LUAU_PR>"
fi
if [[ -n "$LUTE_PR" ]]; then
ESCAPED=$'\n• Lute PR: '
TEXT="$TEXT$ESCAPED <$LUTE_PR>"
fi
else
TEXT=":meow_sad_rain: *Update Luau/Lute workflow failed* (<$RUN_URL|view workflow run>)"
fi
curl -sS -o /dev/null -X POST https://slack.com/api/chat.postMessage \
-H "Authorization: Bearer $SLACK_BOT_TOKEN" \
-H "Content-Type: application/json; charset=utf-8" \
--data "$(jq -n --arg channel "$CHANNEL_ID" --arg text "$TEXT" '{channel: $channel, text: $text}')"