Skip to content

Commit

Permalink
Add nightly builds on Github Actions
Browse files Browse the repository at this point in the history
Creates a new action that generates a new release for all currently
supported targets (linux, osx, windows, freebsd) on merges to master.

The release are generated by using `build_all.d` from installer
  • Loading branch information
MoonlightSentinel committed May 5, 2021
1 parent 5dc9830 commit 07c815f
Showing 1 changed file with 308 additions and 0 deletions.
308 changes: 308 additions & 0 deletions .github/workflows/nightlies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,308 @@
# 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 on merges to master
push:
branches:
- master

# Debug: Trigger on pushes to the PR, for testing purposes only
pull_request:
branches:
- master

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"
# 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 }}
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

0 comments on commit 07c815f

Please sign in to comment.