Skip to content

Commit f312d25

Browse files
committed
ci: check proceed condition for nightly
1 parent 937cabb commit f312d25

File tree

1 file changed

+60
-5
lines changed

1 file changed

+60
-5
lines changed

.github/workflows/nightly.yml

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,62 @@ on:
1212
- cron: '0 0 * * *' # Runs every day at midnight UTC
1313

1414
jobs:
15+
check:
16+
name: Determine Build Necessity
17+
runs-on: ubuntu-latest
18+
outputs:
19+
proceed: ${{ steps.check.outputs.proceed }}
20+
steps:
21+
- uses: actions/checkout@v5
22+
with:
23+
fetch-depth: 0
24+
- name: Get the last nightly commit
25+
id: last_nightly
26+
uses: actions/github-script@v7
27+
with:
28+
script: |
29+
const releases = await github.rest.repos.listReleases({
30+
owner: context.repo.owner,
31+
repo: context.repo.repo,
32+
per_page: 100
33+
});
34+
const nightlyRelease = releases.data.find(release => release.tag_name.includes('nightly') || release.name.includes('Nightly'));
35+
if (nightlyRelease) {
36+
const tagName = nightlyRelease.tag_name;
37+
const tag = await github.rest.git.getRef({
38+
owner: context.repo.owner,
39+
repo: context.repo.repo,
40+
ref: `tags/${tagName}`
41+
});
42+
const commitSha = tag.data.object.sha;
43+
return commitSha;
44+
} else {
45+
return null;
46+
}
47+
- name: Check the proceed condition
48+
id: check
49+
run: |
50+
LAST_NIGHTLY_COMMIT="${{ steps.last_nightly.outputs.result }}"
51+
CURRENT_COMMIT="${GITHUB_SHA}"
52+
echo "Last nightly commit: $LAST_NIGHTLY_COMMIT"
53+
echo "Current commit: $CURRENT_COMMIT"
54+
if [ -z "$LAST_NIGHTLY_COMMIT" ]; then
55+
echo "No previous nightly release found. Proceeding with build."
56+
echo "proceed=true" >> $GITHUB_OUTPUT
57+
elif [ "$LAST_NIGHTLY_COMMIT" != "$CURRENT_COMMIT" ]; then
58+
echo "New commits found since last nightly release. Proceeding with build."
59+
echo "proceed=true" >> $GITHUB_OUTPUT
60+
else
61+
echo "No new commits since last nightly release. Skipping build."
62+
echo "proceed=false" >> $GITHUB_OUTPUT
63+
fi
1564
build:
1665
name: Nightly Build on ${{ matrix.os }}
66+
needs: check
67+
if: needs.check.outputs.proceed == 'true'
1768
runs-on: ${{ matrix.os }}
1869
strategy:
70+
fail-fast: false
1971
matrix:
2072
os: [windows-latest, macos-latest]
2173
steps:
@@ -58,12 +110,15 @@ jobs:
58110
luamake soluna
59111
if [[ "$RUNNER_OS" == "Windows" ]]; then
60112
SOLUNA_BINARY="soluna.exe"
113+
RENAME_BINARY="soluna-windows-amd64.exe"
61114
else
62115
SOLUNA_BINARY="soluna"
116+
RENAME_BINARY="soluna-macos-arm64"
63117
fi
64118
SOLUNA_PATH=$(find bin -name $SOLUNA_BINARY | head -n 1)
65-
echo "SOLUNA_PATH=$SOLUNA_PATH" >> $GITHUB_OUTPUT
66-
echo "SOLUNA_BINARY=$SOLUNA_BINARY" >> $GITHUB_OUTPUT
119+
cp "$SOLUNA_PATH" "bin/$RENAME_BINARY"
120+
echo "SOLUNA_PATH=bin/$RENAME_BINARY" >> $GITHUB_OUTPUT
121+
echo "SOLUNA_BINARY=$RENAME_BINARY" >> $GITHUB_OUTPUT
67122
- uses: actions/upload-artifact@v4
68123
name: Upload
69124
if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'
@@ -74,7 +129,7 @@ jobs:
74129
overwrite: "true"
75130
release:
76131
name: Create Nightly Release
77-
needs: build
132+
needs: [check, build]
78133
runs-on: ubuntu-latest
79134
if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'
80135
permissions:
@@ -141,8 +196,8 @@ jobs:
141196
- **Workflow:** [${context.runId}](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId})
142197
143198
**Assets:**
144-
- soluna-Windows-soluna.exe
145-
- soluna-macOS-soluna
199+
- soluna-windows-amd64.exe
200+
- soluna-macos-arm64
146201
147202
> ⚠️ **Note:** This is an automated nightly build. It may contain unstable features and bugs.
148203
>

0 commit comments

Comments
 (0)