|
| 1 | +name: Upgrade Roblox Packages |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + schedule: |
| 6 | + # Scheduled to run every week around when Roblox releases new versions of |
| 7 | + # Studio. Usually midday (PST) on Wednesdays. We start this job at 1 PM PST |
| 8 | + # to give some buffer room |
| 9 | + - cron: "0 21 * * 3" |
| 10 | + |
| 11 | +jobs: |
| 12 | + version-check: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + timeout-minutes: 5 |
| 15 | + outputs: |
| 16 | + current-version: ${{ steps.get_current_version.outputs.current-version }} |
| 17 | + latest-version: ${{ steps.get_latest_version.outputs.latest-version }} |
| 18 | + should-upgrade: ${{ steps.get_version_diff.outputs.should-upgrade }} |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - uses: CompeyDev/setup-rokit@v0.1.2 |
| 23 | + with: |
| 24 | + version: v1.2.0 |
| 25 | + |
| 26 | + - name: Get the latest Roblox Studio version |
| 27 | + id: get_latest_version |
| 28 | + run: | |
| 29 | + latestVersion=$(roblox-packages list | tail -n 1 | awk '{print $1}') |
| 30 | + echo $latestVersion |
| 31 | + echo "latest-version=$latestVersion" >> "$GITHUB_OUTPUT" |
| 32 | +
|
| 33 | + - name: Get current RobloxPackages version |
| 34 | + id: get_current_version |
| 35 | + run: | |
| 36 | + currentVersion=$(grep -o 'ROBLOX_PACKAGES_VERSION = "[^"]*"' project.luau | awk -F'"' '{print $2}') |
| 37 | + echo "current-version=$currentVersion" >> "$GITHUB_OUTPUT" |
| 38 | +
|
| 39 | + - name: Compare RobloxPackages versions |
| 40 | + id: get_version_diff |
| 41 | + run: | |
| 42 | + currentVersion=${{ steps.get_current_version.outputs.current-version }} |
| 43 | + latestVersion=${{ steps.get_latest_version.outputs.latest-version }} |
| 44 | +
|
| 45 | + if [ "$latestVersion" = "$currentVersion" ]; then |
| 46 | + shouldUpgrade=false |
| 47 | + else |
| 48 | + shouldUpgrade=true |
| 49 | + fi |
| 50 | +
|
| 51 | + echo "should-upgrade=$shouldUpgrade" >> "$GITHUB_OUTPUT" |
| 52 | +
|
| 53 | + create-pr: |
| 54 | + needs: [version-check] |
| 55 | + runs-on: ubuntu-latest |
| 56 | + timeout-minutes: 5 |
| 57 | + permissions: |
| 58 | + contents: write |
| 59 | + pull-requests: write |
| 60 | + env: |
| 61 | + BRANCH_NAME: upgrade-roblox-packages |
| 62 | + if: ${{ needs.version-check.outputs.should-upgrade == 'true' }} |
| 63 | + steps: |
| 64 | + - uses: actions/checkout@v4 |
| 65 | + |
| 66 | + - name: Apply new version |
| 67 | + run: sed -i "s/$CURRENT_VERSION/$LATEST_VERSION/" project.luau |
| 68 | + env: |
| 69 | + CURRENT_VERSION: ${{ needs.version-check.outputs.current-version }} |
| 70 | + LATEST_VERSION: ${{ needs.version-check.outputs.latest-version }} |
| 71 | + |
| 72 | + - name: View project.luau contents |
| 73 | + run: cat project.luau |
| 74 | + |
| 75 | + - name: Check branch existence |
| 76 | + id: branch_existence |
| 77 | + continue-on-error: true |
| 78 | + run: git ls-remote --exit-code --heads origin ${{ env.BRANCH_NAME }} |
| 79 | + |
| 80 | + - name: Create pull request |
| 81 | + uses: peter-evans/create-pull-request@v8 |
| 82 | + # Default behavior for this action is to force push to the branch it |
| 83 | + # manages. This doesn't work great for our use case since we typicallly |
| 84 | + # need to make edits to the branch to get Flipbook working with the |
| 85 | + # dependency changes. This means when the schedule re-runs (or the |
| 86 | + # workflow is manually dispatched) then all of our in-progress changes |
| 87 | + # get erased. This check makes sure that doesn't happen. |
| 88 | + if: ${{ steps.branch_existence.conclusion.failure }} |
| 89 | + with: |
| 90 | + base: main |
| 91 | + add-paths: | |
| 92 | + project.luau |
| 93 | + commit-message: "Upgrade RobloxPackages to ${{ needs.version-check.outputs.latest-version }}" |
| 94 | + branch: ${{ env.BRANCH_NAME }} |
| 95 | + title: "[AUTO-GENERATED] Upgrade RobloxPackages to ${{ needs.version-check.outputs.latest-version }}" |
| 96 | + body: | |
| 97 | + Upgrading RobloxPackages to ${{ needs.version-check.outputs.latest-version }} |
| 98 | +
|
| 99 | + Please carefully test these changes before merging. These packages can and will change out from under us with no warning. |
| 100 | +
|
| 101 | + This pull request was generated by [this run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}). |
| 102 | + reviewers: vocksel |
0 commit comments