-
Notifications
You must be signed in to change notification settings - Fork 55
180 lines (151 loc) · 7.26 KB
/
Copy pathupdate-prs.yml
File metadata and controls
180 lines (151 loc) · 7.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
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
TEXT=$'$TEXT\n- Luau PR: <$LUAU_PR>'
fi
if [[ -n "$LUTE_PR" ]]; then
TEXT=$'$TEXT\n- Lute PR: <$LUTE_PR>'
fi
TEXT=$'$TEXT\nafter newline'
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}')"