Repository navigation
271 lines (227 loc) · 8.98 KB
/
Copy pathnightly.yml
File metadata and controls
271 lines (227 loc) · 8.98 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
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
name: Nightly Build
on:
schedule:
# Run at 2 AM UTC every day
- cron: '0 2 * * *'
workflow_dispatch:
inputs:
force:
description: 'Force build even if no changes'
required: false
type: boolean
default: false
env:
CARGO_TERM_COLOR: always
jobs:
check-changes:
name: Check for Changes
runs-on: ubuntu-latest
outputs:
should_build: ${{ steps.check.outputs.should_build }}
short_sha: ${{ steps.check.outputs.short_sha }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for recent changes
id: check
run: |
# Check if there were commits in the last 24 hours
LAST_COMMIT=$(git log -1 --format='%ct')
CURRENT_TIME=$(date +%s)
HOURS_AGO=$((($CURRENT_TIME - $LAST_COMMIT) / 3600))
SHORT_SHA=$(git rev-parse --short HEAD)
echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT
if [ $HOURS_AGO -lt 24 ] || [ "${{ github.event.inputs.force }}" == "true" ]; then
echo "should_build=true" >> $GITHUB_OUTPUT
echo "Changes detected in the last 24 hours or force build requested"
else
echo "should_build=false" >> $GITHUB_OUTPUT
echo "No changes in the last 24 hours, skipping build"
fi
build-nightly:
name: Build Nightly
needs: check-changes
if: needs.check-changes.outputs.should_build == 'true'
strategy:
fail-fast: false
matrix:
include:
# Linux builds
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
name: script-linux-amd64-nightly
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
name: script-linux-amd64-musl-nightly
# macOS builds
- target: x86_64-apple-darwin
os: macos-latest
name: script-macos-amd64-nightly
- target: aarch64-apple-darwin
os: macos-latest
name: script-macos-arm64-nightly
# Windows builds
- target: x86_64-pc-windows-msvc
os: windows-latest
name: script-windows-amd64-nightly
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@nightly
with:
targets: ${{ matrix.target }}
- name: Install cross-compilation tools
if: matrix.os == 'ubuntu-latest'
run: |
if [[ "${{ matrix.target }}" == "x86_64-unknown-linux-musl" ]]; then
sudo apt-get update
sudo apt-get install -y musl-tools
fi
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-nightly-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-nightly-${{ hashFiles('**/Cargo.lock') }}
- name: Build nightly binary
run: |
# Add nightly version info
export SCRIPT_BUILD_VERSION="nightly-${{ needs.check-changes.outputs.short_sha }}"
export SCRIPT_BUILD_DATE=$(date -u +"%Y-%m-%d")
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]] && [[ "${{ matrix.target }}" != "x86_64-unknown-linux-gnu" ]]; then
cargo install cross
cross build --release --target ${{ matrix.target }}
else
cargo build --release --target ${{ matrix.target }}
fi
shell: bash
- name: Build all binaries
run: |
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]] && [[ "${{ matrix.target }}" != "x86_64-unknown-linux-gnu" ]]; then
cross build --release --target ${{ matrix.target }} --bin script-lsp
cross build --release --target ${{ matrix.target }} --bin manuscript
else
cargo build --release --target ${{ matrix.target }} --bin script-lsp
cargo build --release --target ${{ matrix.target }} --bin manuscript
fi
shell: bash
- name: Prepare nightly artifacts
run: |
# Create staging directory
mkdir -p staging
# Copy binaries
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
cp target/${{ matrix.target }}/release/script.exe staging/
cp target/${{ matrix.target }}/release/script-lsp.exe staging/
cp target/${{ matrix.target }}/release/manuscript.exe staging/
else
cp target/${{ matrix.target }}/release/script staging/
cp target/${{ matrix.target }}/release/script-lsp staging/
cp target/${{ matrix.target }}/release/manuscript staging/
chmod +x staging/*
fi
# Create version info file
echo "Nightly Build" > staging/VERSION
echo "Commit: ${{ needs.check-changes.outputs.short_sha }}" >> staging/VERSION
echo "Date: $(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> staging/VERSION
echo "Target: ${{ matrix.target }}" >> staging/VERSION
# Copy additional files
cp README.md LICENSE staging/
# Create archive
cd staging
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
7z a ../${{ matrix.name }}.zip *
else
tar czf ../${{ matrix.name }}.tar.gz *
fi
shell: bash
- name: Upload nightly artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.name }}
path: |
${{ matrix.name }}.*
retention-days: 7
update-nightly-release:
name: Update Nightly Release
needs: [check-changes, build-nightly]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create release notes
run: |
cat > NIGHTLY_NOTES.md << EOF
# Nightly Build
**Build Date**: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
**Commit**: ${{ needs.check-changes.outputs.short_sha }}
## ⚠️ Warning
This is an automated nightly build of the latest development code.
It may be unstable and is not recommended for production use.
## Installation
Download the appropriate archive for your platform and extract it.
The binaries can be run directly or installed to your PATH.
## Changes
Recent commits:
$(git log --oneline -10)
---
*This release is automatically updated with the latest nightly build.*
EOF
- name: Update or create nightly release
uses: softprops/action-gh-release@v2
with:
tag_name: nightly
name: Nightly Build
body_path: NIGHTLY_NOTES.md
prerelease: true
files: |
artifacts/**/*
- name: Clean old nightly artifacts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Keep only the latest nightly release
gh release list --limit 100 | grep nightly | tail -n +2 | cut -f1 | xargs -I {} gh release delete {} -y || true
notify-failure:
name: Notify Build Failure
needs: [check-changes, build-nightly]
if: failure() && needs.check-changes.outputs.should_build == 'true'
runs-on: ubuntu-latest
steps:
- name: Create issue for build failure
uses: actions/github-script@v6
with:
script: |
const date = new Date().toISOString().split('T')[0];
const title = `Nightly Build Failed - ${date}`;
// Check if issue already exists
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'nightly-build-failure'
});
const existingIssue = issues.data.find(issue => issue.title === title);
if (!existingIssue) {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: `The nightly build failed on ${date}.\n\nWorkflow run: ${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
labels: ['nightly-build-failure', 'bug']
});
}