-
Notifications
You must be signed in to change notification settings - Fork 71
205 lines (175 loc) · 6.97 KB
/
nightly.yml
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
name: Nightly
on:
workflow_dispatch:
inputs:
dry_run:
description: "Dry run"
type: boolean
default: true
schedule:
- cron: '0 0 * * 3,6'
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
permissions:
contents: write
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
nightly_tag: ${{ steps.version.outputs.nightly_tag }}
nightly_version: ${{ steps.version.outputs.nightly_version }}
nightly_branch: ${{ steps.version.outputs.nightly_branch }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Configure Git for committing
run: |
git config user.name github-actions
git config user.email github-actions@github.com
- name: Build xtasks
run: cargo build -p xtask
- name: Upgrade Cairo to latest main commit
run: cargo xtask upgrade cairo --rev $(git ls-remote --refs "https://github.com/starkware-libs/cairo" main | awk '{print $1}')
- name: Upgrade CairoLS to latest main commit
run: cargo xtask upgrade cairols --rev $(git ls-remote --refs "https://github.com/software-mansion/cairols" main | awk '{print $1}')
- name: Rebuild xtasks after Cargo.toml changes
run: cargo build -p xtask
- name: Determine nightly version
id: version
shell: bash
run: |
NIGHTLY_TAG=$(cargo xtask get-nightly-version --tag)
NIGHTLY_VERSION=$(cargo xtask get-nightly-version)
NIGHTLY_BRANCH="nightly/tmp/$NIGHTLY_TAG"
echo "NIGHTLY_TAG=$NIGHTLY_TAG" >> $GITHUB_ENV
echo "NIGHTLY_VERSION=$NIGHTLY_VERSION" >> $GITHUB_ENV
echo "NIGHTLY_BRANCH=$NIGHTLY_BRANCH" >> $GITHUB_ENV
echo "nightly_tag=$NIGHTLY_TAG" >> $GITHUB_OUTPUT
echo "nightly_version=$NIGHTLY_VERSION" >> $GITHUB_OUTPUT
echo "nightly_branch=$NIGHTLY_BRANCH" >> $GITHUB_OUTPUT
- name: Set Scarb version build metadata
run: cargo xtask sync-version --build ${{ env.NIGHTLY_TAG }} --no-pre-release
- name: Rebuild xtasks after Cargo.toml changes
run: cargo build -p xtask
- name: Compose release notes
run: cargo xtask nightly-release-notes > NIGHTLY_RELEASE_NOTES.md
- name: Commit patches
run: |
git checkout -b ${{ env.NIGHTLY_BRANCH }}
git add .
git commit -m ${{ env.NIGHTLY_TAG }}
# NOTE: This must be the last operation done in this job in order for cleanup job to work properly.
- name: Push patches to the repository
run: git push origin ${{ env.NIGHTLY_BRANCH }}
check:
uses: ./.github/workflows/_check-release.yml
needs: prepare
with:
ref: ${{ needs.prepare.outputs.nightly_branch }}
fail-fast: false
release:
uses: ./.github/workflows/_build-release.yml
needs: prepare
with:
scarb-tag: v${{ needs.prepare.outputs.nightly_version }}
ref: ${{ needs.prepare.outputs.nightly_branch }}
upload:
runs-on: ubuntu-latest
needs: [ prepare, release ]
# Do not run on dry_run
if: ${{ !(inputs.dry_run) }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.nightly_branch }}
- name: Create source code archives
run: |
git archive "--prefix=scarb-${{ needs.prepare.outputs.nightly_tag }}/" -o "scarb-${{ needs.prepare.outputs.nightly_tag }}.zip" HEAD
git archive "--prefix=scarb-${{ needs.prepare.outputs.nightly_tag }}/" -o "scarb-${{ needs.prepare.outputs.nightly_tag }}.tar.gz" HEAD
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts-dl
- name: Unpack artifacts to staging directory
run: |
mkdir -p artifacts
mv artifacts-dl/build-*/scarb-* artifacts/
mv artifacts-dl/checksums/* artifacts/
ls -lh artifacts/
- name: Create GitHub release
run: |
gh release create \
"${{ needs.prepare.outputs.nightly_tag }}" \
--repo software-mansion/scarb-nightlies \
--latest \
--title "${{ needs.prepare.outputs.nightly_tag }}" \
--notes-file NIGHTLY_RELEASE_NOTES.md
env:
GH_TOKEN: ${{ secrets.SCARB_NIGHTLIES_CONTENTS_WRITE }}
- name: Upload release assets
run: |
for file in \
./artifacts/* \
"scarb-${{ needs.prepare.outputs.nightly_tag }}.zip#Scarb source code (zip)" \
"scarb-${{ needs.prepare.outputs.nightly_tag }}.tar.gz#Scarb source code (tar.gz)"
do
# If there isn't # in name, it means that it is a build artifact
# and we need to remove version tag from the name, so it can be
# easily accessed in asdf and Scarb installation scripts
#
# for example:
# scarb-v0.6.0+nightly-2023-08-09-aarch64-apple-darwin.tar.gz
# becomes
# scarb-nightly-2023-08-09-aarch64-apple-darwin.tar.gz
if ! [[ $(grep "#" <<< $file) ]]; then
label=$(echo $file | sed -E "s/v[^+]*\+//" | sed -E "s/.\/artifacts\///")
cp "$file" "$label"
file="$label"
fi
gh release upload \
"${{ needs.prepare.outputs.nightly_tag }}" \
"$file" \
--repo software-mansion/scarb-nightlies
done
env:
GH_TOKEN: ${{ secrets.SCARB_NIGHTLIES_CONTENTS_WRITE }}
cleanup:
runs-on: ubuntu-latest
if: always() && needs.prepare.result == 'success'
needs: [ prepare, upload ]
steps:
- uses: actions/checkout@v4
- name: Delete nightly branch
run: |
git push origin -d ${{ needs.prepare.outputs.nightly_branch }}
notify_failed:
runs-on: ubuntu-latest
# Do not run on dry_run or success
if: always() && !(inputs.dry_run) && contains(needs.*.result, 'failure')
needs: [ cleanup, upload, release, prepare ]
steps:
- name: Notifying about Nightly fail!
uses: slackapi/slack-github-action@v2.0.0
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NIGHTLY_FAILURE_WEBHOOK_URL }}
with:
payload: |
{
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
notify_failed_check:
runs-on: ubuntu-latest
# Do not run on dry_run, check success or if we have already notified
if: always() && !(inputs.dry_run) && needs.check.result == 'failure' && needs.notify_failed.result == 'skipped'
needs: [ check, notify_failed ]
steps:
- name: Notifying about check fail!
uses: slackapi/slack-github-action@v2.0.0
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NIGHTLY_CHECK_FAILURE_WEBHOOK_URL }}
with:
payload: |
{
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}