Skip to content

Nightly Release

Nightly Release #479

Workflow file for this run

---
name: Nightly Release
on:
workflow_dispatch:
schedule:
# Run builds on midnight EST on weekdays
- cron: '0 5 * * 1-5'
# prevent multiple releases from running at the same time
concurrency:
group: ${{ github.workflow_ref }}
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Create tag name
shell: bash
run: |
DATE="$(date +%d-%m-%Y)"
echo DATE=$DATE >> $GITHUB_ENV
echo TAG_NAME=nightly-$DATE >> $GITHUB_ENV
echo "RELEASE_NAME=Nightly ($DATE)" >> $GITHUB_ENV
- name: Get Cargo.toml package version
shell: bash
run: |
echo CARGO_PKG_VERSION=$(cargo pkgid | cut -d@ -f2 ) >> $GITHUB_ENV
- name: Create Draft Release
id: release
uses: ncipollo/release-action@v1
with:
allowUpdates: true # allow overwriting
updateOnlyUnreleased: true # prevent modifying any non-draft non-prerelease
removeArtifacts: true # deletes any existing artifacts when modifying
draft: false
prerelease: true
tag: ${{ env.TAG_NAME }}
name: ${{ env.RELEASE_NAME }}
commit: ${{ github.sha }} # need commit because tag doesn't exist yet
body: |
Nightly pre-release build of `${{ github.ref_name }}` on ${{ env.DATE }}.
This build is for development purposes and not intended for production use.
outputs:
releaseId: ${{ steps.release.outputs.id }}
releaseUploadUrl: ${{ steps.release.outputs.upload_url }}
tagName: ${{ env.TAG_NAME }}
cargoPackageVersion: ${{ env.CARGO_PKG_VERSION }}
build-release:
name: Build Release
needs: create-release
uses: ./.github/workflows/build-release.yml
with:
releaseId: ${{ needs.create-release.outputs.releaseId }}
releaseUploadUrl: ${{ needs.create-release.outputs.releaseUploadUrl }}
releaseTag: ${{ needs.create-release.outputs.tagName }}
packageVersion: ${{ needs.create-release.outputs.cargoPackageVersion }}
debRevision: ${{ needs.create-release.outputs.tagName }}
rpmSnapshot: ${{ github.sha }}
rustFlags: '-C debuginfo=2 -C strip=none'
test-release:
name: Test Release
needs: [create-release, build-release]
uses: ./.github/workflows/test-release.yml
with:
releaseId: ${{ needs.create-release.outputs.releaseId }}
releaseVersion: ${{ needs.create-release.outputs.tagName }}
serverUrl: https://api.staging.cloudtruth.io
secrets:
CLOUDTRUTH_API_KEY: ${{ secrets.CT_STAGING_CI_ADMIN_API_KEY }}
make-prerelease:
name: Make Pre-Release
needs: [create-release, build-release, test-release]
# run after tests but ignore if they fail
if: always() && needs.build-release.result == 'success'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# move new release from draft to pre-release
- uses: ncipollo/release-action@v1
with:
draft: false
prerelease: true
allowUpdates: true
omitBody: true
omitName: true
tag: ${{ needs.create-release.outputs.tagName }}
commit: ${{ github.sha }}
# rotate out old nightly releases
- uses: dev-drprasad/delete-older-releases@v0.3.3
with:
keep_latest: 2
delete_expired_data: 3
delete_tag_pattern: nightly
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# dispatch repo event to trigger test-nightly.yml
- uses: peter-evans/repository-dispatch@v2
with:
event-type: nightly-release
client-payload: '{"tagName": "${{ needs.create-release.outputs.tagName }}"}'