-
-
Notifications
You must be signed in to change notification settings - Fork 613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add nightly build on Github Actions #12491
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,302 @@ | ||
# 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. Generates the documentation included in each release | ||
# 2. Builds the actual release (using a matrix over all targets) | ||
# 3. Publishes all artifacts from (2) to the release page on GitHub | ||
|
||
name: build-nightly | ||
|
||
on: | ||
# Rebuild every day | ||
schedule: | ||
- cron: '0 0 * * *' | ||
|
||
jobs: | ||
# Build the documentation used by all releases | ||
build-docs: | ||
name: Build documentation for all repos | ||
|
||
steps: | ||
# Clone all required repos | ||
- name: Clone dmd | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: 'dlang/dmd' | ||
path: 'dmd' | ||
|
||
- name: Clone druntime | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: 'dlang/druntime' | ||
path: 'druntime' | ||
|
||
- name: Clone phobos | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: 'dlang/phobos' | ||
path: 'phobos' | ||
|
||
- name: Clone dlang.org | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: 'dlang/dlang.org' | ||
path: 'dlang.org' | ||
|
||
# Fetch host compiler | ||
- uses: dlang-community/setup-dlang@v1 | ||
name: Install host DMD | ||
|
||
# Actually build the docs | ||
- name: Build docs and man pages | ||
shell: bash | ||
run: | | ||
set -euox pipefail | ||
|
||
# Build minimal host compiler (sometimes not triggered by dlang.org/posix.mak) | ||
make -f posix.mak -j2 -C druntime | ||
|
||
# Build docs and include the man pages | ||
make -f posix.mak -j2 -C dlang.org release | ||
cp -r dmd/generated/docs/man dlang.org/web/ | ||
|
||
# Save the generated documentation for the target-specific builds | ||
- name: Upload generated docs as a temporary artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: dmd-nightly-docs | ||
path: dlang.org/web | ||
retention-days: 1 | ||
if-no-files-found: error | ||
|
||
runs-on: ubuntu-latest | ||
|
||
# Build and package a new release for each platform | ||
build-all-releases: | ||
name: Build nightly for ${{ matrix.target }} on ${{ matrix.os }} | ||
needs: build-docs | ||
timeout-minutes: 60 | ||
|
||
strategy: | ||
matrix: | ||
include: | ||
- os: ubuntu-20.04 | ||
target: linux | ||
- os: macos-10.15 | ||
target: osx | ||
- os: windows-2019 | ||
target: windows | ||
# FreeBSD is built on an additional VM | ||
- os: macos-10.15 | ||
target: freebsd | ||
|
||
steps: | ||
|
||
################################################################# | ||
# Install the system dependencies required to build and run | ||
# the actual release scripts | ||
# | ||
# Linux implementation based on `linux_both` in build_all.d and | ||
# some additional experimentation to get curl working | ||
# | ||
- name: Install dependencies for linux | ||
if: matrix.target == 'linux' | ||
shell: bash | ||
run: | | ||
set -euox pipefail | ||
|
||
# Install base dependencies (including multlib support) | ||
sudo dpkg --add-architecture i386 | ||
sudo apt -y update | ||
sudo apt -y install --no-install-recommends \ | ||
build-essential \ | ||
ca-certificates \ | ||
curl \ | ||
dpkg-dev \ | ||
fakeroot \ | ||
g++ \ | ||
g++-multilib \ | ||
gcc \ | ||
git \ | ||
gpg \ | ||
gpg-agent \ | ||
libcurl4 \ | ||
libcurl4-openssl-dev \ | ||
libcurl4:i386 \ | ||
libxml2 \ | ||
make \ | ||
p7zip-full \ | ||
rpm \ | ||
rsync \ | ||
unzip \ | ||
xz-utils | ||
|
||
# Save some space | ||
sudo apt clean | ||
|
||
################################################################# | ||
# Install latest LDC used to compile the release scripts and to | ||
# determine the currently available version number | ||
# | ||
- uses: dlang-community/setup-dlang@v1 | ||
name: Install latest LDC | ||
if: matrix.target != 'freebsd' | ||
with: | ||
compiler: ldc-latest | ||
|
||
################################################################# | ||
# Clone dlang/installer which provides the actual build scripts | ||
# | ||
- name: Clone installer repo | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: 'dlang/installer' | ||
|
||
################################################################# | ||
# Load the generated documentation in the create_dmd_release folder | ||
# | ||
- name: Download docs generated by the previous job | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: dmd-nightly-docs | ||
path: create_dmd_release/docs | ||
|
||
################################################################# | ||
# Build for the current target using build_all.d from installer | ||
# | ||
- name: Fetch common resources and run build_all.d for ${{ matrix.target }} | ||
id: build | ||
if: matrix.target != 'freebsd' | ||
shell: bash | ||
run: | | ||
set -euox pipefail | ||
|
||
# Fetch GPG key used to sign the generated binaries | ||
curl https://dlang.org/d-keyring.gpg -o d-keyring.gpg | ||
gpg --import d-keyring.gpg | ||
|
||
# Compile release builder | ||
cd create_dmd_release | ||
ldmd2 -g -m64 --link-defaultlib-debug -version=NoVagrant -i build_all.d | ||
|
||
# Determine installed LDC version | ||
LDC=$(ldc2 --version | head -n 1 | cut -d'(' -f2 | cut -d')' -f1) | ||
echo "::set-output name=host_ldc::$LDC" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This automatically updates the host compiler with every LDC release. |
||
|
||
# WINDOWS: Fetch additional DM tools | ||
if [[ "${{ matrix.target }}" == "windows" ]] | ||
then | ||
|
||
# Fetch DM make | ||
curl http://downloads.dlang.org/other/dm857c.zip -o dmc.zip | ||
7z x dmc.zip | ||
|
||
# Fetch implib | ||
curl http://ftp.digitalmars.com/bup.zip -o bup.zip | ||
7z x bup.zip dm/bin/implib.exe | ||
|
||
# Add DM binaries to the path | ||
export PATH="$PWD/dm/bin;$PATH" | ||
|
||
# Export VS dir | ||
export LDC_VSDIR='C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise' | ||
fi | ||
|
||
# Build the release | ||
./build_all --targets=${{ matrix.target }} "v$LDC" master | ||
|
||
################################################################# | ||
# FREEBSD: Build for the current target using build_all.d from installer | ||
# | ||
- name: Run build_all.d for FreeBSD in a dedicated VM | ||
if: matrix.target == 'freebsd' | ||
uses: vmactions/freebsd-vm@v0.1.3 | ||
with: | ||
usesh: true | ||
# Need more RAM than the default 1G | ||
mem: 4096 | ||
prepare: pkg install -y bash curl curlpp git gmake pkgconf gnupg rsync llvm90 | ||
run: | | ||
set -eux | ||
|
||
# Import key used to sign binaries | ||
curl https://dlang.org/d-keyring.gpg -o d-keyring.gpg | ||
gpg d-keyring.gpg | ||
|
||
# Install ldc | ||
curl https://dlang.org/install.sh -o install.sh | ||
bash install.sh ldc -p . | ||
|
||
# Use absolute paths because activate doesn't work correctly | ||
LDC_BIN=$PWD/ldc-*/bin | ||
|
||
# Determine installed LDC version | ||
LDC=$($LDC_BIN/ldc2 --version | head -n 1 | cut -d'(' -f2 | cut -d')' -f1) | ||
|
||
# Determine additional linker flags to make -lcurl work | ||
EXTRA_FLAGS="-L$(pkg-config --libs-only-L libcurl)" | ||
|
||
# Actually build the release | ||
cd create_dmd_release | ||
$LDC_BIN/ldmd2 -g -m64 --link-defaultlib-debug -version=NoVagrant -i build_all.d $EXTRA_FLAGS | ||
./build_all --targets=${{ matrix.target }} "v$LDC" master | ||
|
||
################################################################# | ||
# Save the target-specific release as a artifact s.t. the next | ||
# job can bundle the entire release for all supported targets | ||
# | ||
- name: Upload generated release as a temporary artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: dmd-nightly | ||
path: | | ||
${{ github.workspace }}/create_dmd_release/build/* | ||
!${{ github.workspace }}/create_dmd_release/build/*.zip | ||
retention-days: 1 | ||
if-no-files-found: error | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
# Bundles and publishes the entire release | ||
generate_release: | ||
name: "Publish artifacts on the release page" | ||
needs: build-all-releases | ||
steps: | ||
################################################################# | ||
# Fetch all artifacts from the jobs defined above | ||
# | ||
- name: Download generated releases from the artifacts | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: dmd-nightly | ||
path: ~/artifacts/ | ||
|
||
################################################################# | ||
# Debug: Check that all required artifacts are present | ||
# | ||
- name: Display all files included in the artifacts | ||
shell: bash | ||
run: | | ||
set -euox pipefail | ||
ls -aul ~ ~/artifacts | ||
|
||
################################################################# | ||
# Create the new release using the downloaded artifacts | ||
# | ||
- name: Create the nightly release | ||
# Currently disabled due to missing permissions | ||
if: ${{ false }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't work due to missing permissions because the PR was issued from a fork. Could probably be enabled by another PR from an upstream branch. See the generated artifacts for a preview of the actual releases |
||
uses: "marvinpinto/action-automatic-releases@latest" | ||
with: | ||
repo_token: "${{ secrets.GITHUB_TOKEN }}" | ||
automatic_release_tag: nightly | ||
name: dmd-master | ||
prerelease: true | ||
draft: true | ||
files: ~/artifacts/* | ||
|
||
runs-on: ubuntu-latest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of those should already be included in the base image, but I've kept them just to be sure.