Repository navigation
66 lines (61 loc) · 2.53 KB
/
Copy pathbuild-nightly.yml
File metadata and controls
66 lines (61 loc) · 2.53 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
name: "Build: Nightly"
on:
workflow_dispatch:
inputs:
branch:
description: 'The branch to build night release from'
required: false
default: 'main'
schedule:
- cron: "0 23 * * *"
permissions:
contents: read
jobs:
publish_binary_packages:
permissions:
contents: read
runs-on: ubuntu-22.04
steps:
- name: Harden Runner
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
token: ${{ secrets.MOAUTO_WORKFLOW_TOKEN }}
- name: set nightly version
id: nightly
continue-on-error: false
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
env:
GH_TOKEN: ${{ secrets.MOAUTO_WORKFLOW_TOKEN }}
TARGET_BRANCH: ${{ github.event.inputs.branch }}
run: |
NIGHTLY_VERSION="nightly"
# Delete EVERY release pointing at the nightly tag, including leftover DRAFT
# releases (the SLSA provenance `upload-assets` step creates draft releases
# that `gh release delete <tag>` leaves behind, so they pile up over time).
for rid in $(gh api --paginate "repos/${GITHUB_REPOSITORY}/releases" \
--jq ".[] | select(.tag_name==\"${NIGHTLY_VERSION}\") | .id"); do
echo "Deleting nightly release id=${rid}"
gh api -X DELETE "repos/${GITHUB_REPOSITORY}/releases/${rid}" || true
done
gh release delete "${NIGHTLY_VERSION}" --cleanup-tag --yes || echo "${NIGHTLY_VERSION} does not exist"
git push --delete origin "${NIGHTLY_VERSION}" || echo "${NIGHTLY_VERSION} tag does not exist"
if [ -z "$TARGET_BRANCH" ]; then
TARGET_BRANCH="main"
fi
gh release create "${NIGHTLY_VERSION}" --generate-notes --prerelease --title "${NIGHTLY_VERSION}" --target "${TARGET_BRANCH}"
publish-cedarling-nightly:
needs: publish_binary_packages
# Only publish on scheduled runs or when the target branch is main (default).
# A workflow_dispatch targeting a feature branch would produce a nightly from
# an unstable ref; skip the crates.io publish in that case.
if: github.event_name == 'schedule' || github.event.inputs.branch == '' || github.event.inputs.branch == 'main'
uses: ./.github/workflows/release-cedarling.yml
with:
ref: nightly
dry_run: false
secrets:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}