|
1 | | -name: Nightly |
2 | | - |
3 | | -# A prerelease of main every day there is something new, tagged |
4 | | -# vX.Y.Z-nightly.YYYYMMDD.N where X.Y.Z follows the last release (so a |
5 | | -# nightly sorts after the release it builds on and before the next one) and |
6 | | -# N counts that day's nightlies. It is built and published by release.yml's |
7 | | -# own jobs; the `nightly` update channel takes it (src/core/semver.bend). |
| 1 | +name: Nightly candidate (build only) |
8 | 2 |
|
| 3 | +# Future nightly wiring remains available; no tag, public release or pruning |
| 4 | +# is performed before root has accepted the candidate's actual package gates. |
9 | 5 | on: |
10 | 6 | schedule: |
11 | 7 | - cron: "17 4 * * *" |
12 | 8 | workflow_dispatch: |
13 | 9 |
|
14 | 10 | permissions: |
15 | | - contents: write |
| 11 | + contents: read |
16 | 12 |
|
17 | 13 | concurrency: |
18 | 14 | group: nightly |
19 | 15 | cancel-in-progress: false |
20 | 16 |
|
21 | 17 | jobs: |
22 | | - tag: |
23 | | - name: Tag |
| 18 | + plan: |
| 19 | + name: Plan immutable nightly candidate |
24 | 20 | runs-on: ubuntu-24.04 |
25 | 21 | outputs: |
26 | | - tag: ${{ steps.tag.outputs.tag }} |
| 22 | + commit: ${{ steps.identity.outputs.commit }} |
| 23 | + version: ${{ steps.identity.outputs.version }} |
27 | 24 | steps: |
28 | 25 | - uses: actions/checkout@v4 |
29 | 26 | with: |
30 | 27 | fetch-depth: 0 |
31 | | - - id: tag |
32 | | - env: |
33 | | - MANUAL: ${{ github.event_name == 'workflow_dispatch' }} |
| 28 | + - id: identity |
34 | 29 | run: | |
35 | 30 | set -eu |
36 | | - git fetch --tags --force |
37 | | - stable=$(git tag -l 'v*' | grep -v -- '-' | sort -V | tail -n1) |
| 31 | + stable=$(git tag -l 'v*' | grep -v -- '-' | sort -V | tail -n1 || true) |
38 | 32 | ver=${stable#v} |
39 | 33 | ver=${ver:-0.0.0} |
40 | 34 | maj=${ver%%.*}; rest=${ver#*.}; min=${rest%%.*}; pat=${rest#*.} |
41 | 35 | base="v$maj.$min.$((pat + 1))" |
42 | | - last=$(git tag -l 'v*-nightly.*' | sort -V | tail -n1) |
43 | | - if [ -n "$last" ] && [ "$(git rev-list -n1 "$last")" = "$(git rev-parse HEAD)" ] && [ "$MANUAL" != true ]; then |
44 | | - echo "main has not moved since $last" |
45 | | - echo "tag=" >> "$GITHUB_OUTPUT" |
46 | | - exit 0 |
47 | | - fi |
48 | 36 | day=$(date -u +%Y%m%d) |
49 | | - n=$(( $(git tag -l "$base-nightly.$day.*" | wc -l) + 1 )) |
50 | | - tag="$base-nightly.$day.$n" |
51 | | - git tag "$tag" HEAD |
52 | | - git push origin "$tag" |
53 | | - echo "tag=$tag" >> "$GITHUB_OUTPUT" |
54 | | - echo "tagged $tag" |
| 37 | + # Build-only candidates have no tags to count. Reserve a unique numeric |
| 38 | + # suffix per actual run/attempt, including retries of the same source. |
| 39 | + [ "$GITHUB_RUN_ATTEMPT" -lt 1000 ] |
| 40 | + n=$(( GITHUB_RUN_ID * 1000 + GITHUB_RUN_ATTEMPT )) |
| 41 | + echo "commit=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" |
| 42 | + echo "version=$base-nightly.$day.$n" >> "$GITHUB_OUTPUT" |
55 | 43 |
|
56 | | - release: |
57 | | - name: Release |
58 | | - needs: [tag] |
59 | | - if: needs.tag.outputs.tag != '' |
| 44 | + candidate: |
| 45 | + name: Build nightly candidate only |
| 46 | + needs: [plan] |
60 | 47 | uses: ./.github/workflows/release.yml |
61 | 48 | with: |
62 | | - tag: ${{ needs.tag.outputs.tag }} |
| 49 | + ref: ${{ needs.plan.outputs.commit }} |
| 50 | + version: ${{ needs.plan.outputs.version }} |
| 51 | + telemetry_url: https://backplane.works/api/v1/events |
63 | 52 | secrets: inherit |
64 | | - |
65 | | - prune: |
66 | | - name: Keep the last 14 nightlies |
67 | | - needs: [release] |
68 | | - runs-on: ubuntu-24.04 |
69 | | - env: |
70 | | - GH_TOKEN: ${{ github.token }} |
71 | | - steps: |
72 | | - - run: | |
73 | | - set -eu |
74 | | - gh release list --repo "$GITHUB_REPOSITORY" --limit 200 --json tagName --jq '.[].tagName' \ |
75 | | - | grep -- '-nightly\.' | sort -V -r | tail -n +15 \ |
76 | | - | while read -r t; do gh release delete "$t" --repo "$GITHUB_REPOSITORY" --cleanup-tag --yes; done |
0 commit comments