Skip to content

Commit 9a07678

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

1 file changed

Lines changed: 61 additions & 5 deletions

File tree

.github/workflows/nightly.yml

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,63 @@ 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+
# Fetch the commit SHA of the latest nightly release
30+
const releases = await github.rest.repos.listReleases({
31+
owner: context.repo.owner,
32+
repo: context.repo.repo,
33+
per_page: 100
34+
});
35+
const nightlyRelease = releases.data.find(release => release.tag_name.includes('nightly') || release.name.includes('Nightly'));
36+
if (nightlyRelease) {
37+
const tagName = nightlyRelease.tag_name;
38+
const tag = await github.rest.git.getRef({
39+
owner: context.repo.owner,
40+
repo: context.repo.repo,
41+
ref: `tags/${tagName}`
42+
});
43+
const commitSha = tag.data.object.sha;
44+
return commitSha;
45+
} else {
46+
return null;
47+
}
48+
- name: Check the proceed condition
49+
id: check
50+
run: |
51+
LAST_NIGHTLY_COMMIT="${{ steps.last_nightly.outputs.result }}"
52+
CURRENT_COMMIT="${GITHUB_SHA}"
53+
echo "Last nightly commit: $LAST_NIGHTLY_COMMIT"
54+
echo "Current commit: $CURRENT_COMMIT"
55+
if [ -z "$LAST_NIGHTLY_COMMIT" ]; then
56+
echo "No previous nightly release found. Proceeding with build."
57+
echo "proceed=true" >> $GITHUB_OUTPUT
58+
elif [ "$LAST_NIGHTLY_COMMIT" != "$CURRENT_COMMIT" ]; then
59+
echo "New commits found since last nightly release. Proceeding with build."
60+
echo "proceed=true" >> $GITHUB_OUTPUT
61+
else
62+
echo "No new commits since last nightly release. Skipping build."
63+
echo "proceed=false" >> $GITHUB_OUTPUT
64+
fi
1565
build:
1666
name: Nightly Build on ${{ matrix.os }}
67+
needs: check
68+
if: needs.check.outputs.proceed == 'true'
1769
runs-on: ${{ matrix.os }}
1870
strategy:
71+
fail-fast: false
1972
matrix:
2073
os: [windows-latest, macos-latest]
2174
steps:
@@ -58,12 +111,15 @@ jobs:
58111
luamake soluna
59112
if [[ "$RUNNER_OS" == "Windows" ]]; then
60113
SOLUNA_BINARY="soluna.exe"
114+
RENAME_BINARY="soluna-windows-amd64.exe"
61115
else
62116
SOLUNA_BINARY="soluna"
117+
RENAME_BINARY="soluna-macos-arm64"
63118
fi
64119
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
120+
cp "$SOLUNA_PATH" "bin/$RENAME_BINARY"
121+
echo "SOLUNA_PATH=bin/$RENAME_BINARY" >> $GITHUB_OUTPUT
122+
echo "SOLUNA_BINARY=$RENAME_BINARY" >> $GITHUB_OUTPUT
67123
- uses: actions/upload-artifact@v4
68124
name: Upload
69125
if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'
@@ -74,7 +130,7 @@ jobs:
74130
overwrite: "true"
75131
release:
76132
name: Create Nightly Release
77-
needs: build
133+
needs: [check, build]
78134
runs-on: ubuntu-latest
79135
if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'
80136
permissions:
@@ -141,8 +197,8 @@ jobs:
141197
- **Workflow:** [${context.runId}](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId})
142198
143199
**Assets:**
144-
- soluna-Windows-soluna.exe
145-
- soluna-macOS-soluna
200+
- soluna-windows-amd64.exe
201+
- soluna-macos-arm64
146202
147203
> ⚠️ **Note:** This is an automated nightly build. It may contain unstable features and bugs.
148204
>

0 commit comments

Comments
 (0)