Nightly Release #829
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This GitHub action triggers a fresh set of Levant builds and publishes them | |
# to GitHub Releases under the `nightly` tag. | |
# Note that artifacts available via GitHub Releases are not codesigned or | |
# notarized. | |
# Failures are reported to slack. | |
name: Nightly Release | |
on: | |
schedule: | |
# Runs against the default branch every day overnight | |
- cron: "18 3 * * *" | |
workflow_dispatch: | |
jobs: | |
# Build a fresh set of artifacts | |
build-artifacts: | |
uses: ./.github/workflows/build.yml | |
github-release: | |
needs: build-artifacts | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 | |
- name: Download built artifacts | |
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 | |
with: | |
path: out/ | |
# Set BUILD_OUTPUT_LIST to out\<project>-<version>.<fileext>\*,out\... | |
# This is needed to attach the build artifacts to the GitHub Release | |
- name: Set BUILD_OUTPUT_LIST | |
run: | | |
(ls -xm1 out/) > tmp.txt | |
sed 's:.*:out/&/*:' < tmp.txt > tmp2.txt | |
echo "BUILD_OUTPUT_LIST=$(tr '\n' ',' < tmp2.txt | perl -ple 'chop')" >> "$GITHUB_ENV" | |
rm -rf tmp.txt && rm -rf tmp2.txt | |
- name: Advance nightly tag | |
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
try { | |
await github.rest.git.deleteRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: "tags/nightly" | |
}) | |
} catch (e) { | |
console.log("Warning: The nightly tag doesn't exist yet, so there's nothing to do. Trace: " + e) | |
} | |
await github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: "refs/tags/nightly", | |
sha: context.sha | |
}) | |
# This will create a new GitHub Release called `nightly` | |
# If a release with this name already exists, it will overwrite the existing data | |
- name: Create a nightly GitHub prerelease | |
id: create_prerelease | |
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 | |
with: | |
name: nightly | |
artifacts: "${{ env.BUILD_OUTPUT_LIST }}" | |
tag: nightly | |
bodyFile: ".github/workflows/nightly-release-readme.md" | |
prerelease: true | |
allowUpdates: true | |
removeArtifacts: true | |
draft: false | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish nightly GitHub prerelease | |
uses: eregon/publish-release@01df127f5e9a3c26935118e22e738d95b59d10ce # v1.0.6 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
release_id: ${{ steps.create_prerelease.outputs.id }} | |
# Send a slack notification if either job defined above fails | |
slack-notify: | |
needs: | |
- build-artifacts | |
- github-release | |
if: always() && (needs.build-artifacts.result == 'failure' || needs.github-release.result == 'failure') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Notify Slack on Nightly Release Failure | |
uses: hashicorp/actions-slack-status@1a3f63b30bd476aee1f3bd6f9d8f2aacc4f14d81 # v2.0.1 | |
with: | |
failure-message: |- | |
:x::moon::nomad-sob: Levant Nightly Release *FAILED* on | |
status: failure | |
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }} | |
permissions: | |
contents: write |