Skip to content

build-nightly

build-nightly #1995

Workflow file for this run

# Github Action to build nightly releases
#
# This script builds and packages a release for Linux, Windows, OSX and FreeBSD
# using current master. The generated archives are published as the current
# nightly build on the Gitbub release page.
#
# Job overview:
# 1. Builds the actual release using `build_release_template` from dlang/installer
# 2. Publishes all artifacts from (1) to the release page on GitHub
name: build-nightly
on:
# Rebuild every day
schedule:
- cron: '0 0 * * *'
jobs:
# Build and package a new release for all supported platforms
build-all-releases:
name: Build nightly from master
if: github.repository == 'dlang/dmd'
uses: dlang/installer/.github/workflows/build_release_template.yml@master
with:
release_branch: master
# Resolve the revisions that will be built up-front. The reusable workflow
# also exposes these, but its outputs come back empty when any platform in
# its build matrix fails, which would leave the release notes blank. Capturing
# them here provides a reliable fallback (see `generate_release` below).
revisions:
name: Capture built revisions
if: github.repository == 'dlang/dmd'
runs-on: ubuntu-latest
outputs:
dmd: ${{ steps.resolve.outputs.dmd }}
phobos: ${{ steps.resolve.outputs.phobos }}
steps:
- name: Resolve master revisions
id: resolve
shell: bash
run: |
set -euo pipefail
echo "dmd=$(git ls-remote https://github.com/dlang/dmd.git refs/heads/master | cut -f1)" >> "$GITHUB_OUTPUT"
echo "phobos=$(git ls-remote https://github.com/dlang/phobos.git refs/heads/master | cut -f1)" >> "$GITHUB_OUTPUT"
# Bundles and publishes the entire release
generate_release:
name: "Publish artifacts on the release page"
needs:
- build-all-releases
- revisions
# Publish whichever platform builds succeeded, even if another platform
# (e.g. FreeBSD) failed. `!cancelled()` still runs on upstream failure but
# skips when the workflow run was manually cancelled. The repository guard
# keeps forks from attempting to publish (their build jobs are skipped).
if: ${{ !cancelled() && github.repository == 'dlang/dmd' }}
runs-on: ubuntu-latest
steps:
#################################################################
# Fetch all artifacts from the jobs defined above
#
- name: Download generated releases from the artifacts
uses: actions/download-artifact@v4
with:
pattern: dmd-release-*
merge-multiple: true
path: ~/artifacts/
#################################################################
# Debug: Check that all required artifacts are present
#
- name: Display all files included in the artifacts
id: list-artifacts
shell: bash
run: |
set -euox pipefail
ls -aul ~ ~/artifacts
echo "artifacts_directory=$HOME/artifacts" >> $GITHUB_OUTPUT
#################################################################
# Create the new release using the downloaded artifacts
#
- name: Create the nightly release
uses: ncipollo/release-action@v1
with:
token: "${{ secrets.GITHUB_TOKEN }}"
name: DMD nightly
prerelease: true
body: |
Nightly build of the reference D compiler
Note that the official date and commit will be outdated because this
release is continuously updated. The actually built revisions are:
| Component | Revision |
| --------- | ---------------------------------------------------------------- |
| DMD | dlang/dmd@${{ needs.build-all-releases.outputs.dmd-revision || needs.revisions.outputs.dmd }} |
| Phobos | dlang/phobos@${{ needs.build-all-releases.outputs.phobos-revision || needs.revisions.outputs.phobos }} |
artifacts: ${{ steps.list-artifacts.outputs.artifacts_directory }}/*
artifactErrorsFailBuild: true
# Always tag the same commit to only update the body + assets
tag: nightly
commit: f01bc99e87ad9d04b47a5323f6ccb1fd728eae8c
allowUpdates: true
# Overwrite the assets this run rebuilt, but keep assets from previous
# nightlies that were not rebuilt (e.g. the last successful FreeBSD
# build) rather than deleting them.
replacesArtifacts: true
removeArtifacts: false