Migrate to GitHub Actions (#637)

* Migrate to GitHub Actions

* Add release steps

* Use WebFreak001/upload-asset@v1.0.0

* Package the files using tar and 7z

* Use TAG_RAW in the names
This commit is contained in:
Amin Yahyaabadi 2021-06-01 10:25:31 -05:00 committed by GitHub
parent f38d36ab41
commit 3e5dbd979a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 108 additions and 328 deletions

108
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,108 @@
name: CI
on:
pull_request:
push:
branches:
- master
release:
types: [published]
jobs:
Build:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
dc:
- ldc-latest
- dmd-latest
arch:
- x86_64
include:
# windows x86
- os: windows-latest
arch: x86
dc: ldc-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Setup D
uses: dlang-community/setup-dlang@v1
with:
compiler: ${{ matrix.dc }}
# Build
- name: Build
run: |
dub build --build=release --config=client --arch=${{ matrix.arch }}
dub build --build=release --config=server --arch=${{ matrix.arch }}
# Tests
- name: Linux Tests
if: contains(matrix.os, 'ubuntu')
run: |
./run_tests.sh
working-directory: tests
shell: bash
- name: Windows and MacOS Tests
if: contains(matrix.os, 'windows') || contains(matrix.os, 'macos')
run: |
./run_tests.sh
working-directory: tests
shell: bash
continue-on-error: true
# Package Release
- name: Package the artificats
if: github.event_name == 'release' && contains(matrix.dc, 'ldc')
shell: pwsh
run: |
if ("${{ matrix.os }}" -like 'windows*') {
7z a -tzip dcd.zip dcd-client.exe dcd-server.exe
} else {
tar -cvzf dcd.tar.gz dcd-client dcd-server
}
# Release
- name: Release Linux
if: github.event_name == 'release' && contains(matrix.os, 'ubuntu') && contains(matrix.dc, 'ldc')
uses: WebFreak001/upload-asset@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OS: linux
with:
file: dcd.tar.gz
filename: dcd-${TAG_RAW}-${OS}-${{ matrix.arch }}.tar.gz
mime: application/tar+gzip
- name: Release Macos
if: github.event_name == 'release' && contains(matrix.os, 'macos') && contains(matrix.dc, 'ldc')
uses: WebFreak001/upload-asset@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OS: osx
with:
file: dcd.tar.gz
filename: dcd-${TAG_RAW}-${OS}-${{ matrix.arch }}.tar.gz
mime: application/tar+gzip
- name: Release Windows
if: github.event_name == 'release' && contains(matrix.os, 'windows') && contains(matrix.dc, 'ldc')
uses: WebFreak001/upload-asset@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OS: windows
with:
file: dcd.zip
filename: dcd-${TAG_RAW}-${OS}-${{ matrix.arch }}.zip
mime: application/zip

View File

@ -1,24 +0,0 @@
#!/bin/bash
set -e
if [[ $BUILD == dub ]]; then
if [[ -n $LIBDPARSE_VERSION ]]; then
rdmd ./d-test-utils/test_with_package.d $LIBDPARSE_VERSION libdparse -- dub build --build=release --config=client
rdmd ./d-test-utils/test_with_package.d $LIBDPARSE_VERSION libdparse -- dub build --build=release --config=server
elif [[ -n $DSYMBOL_VERSION ]]; then
rdmd ./d-test-utils/test_with_package.d $DSYMBOL_VERSION dsymbol -- dub build --build=release --config=client
rdmd ./d-test-utils/test_with_package.d $DSYMBOL_VERSION dsymbol -- dub build --build=release --config=server
else
echo 'Cannot run test without LIBDPARSE_VERSION nor DSYMBOL_VERSION environment variable'
exit 1
fi
elif [[ $DC == ldc2 ]]; then
git submodule update --init --recursive
make ldc -j2
else
git submodule update --init --recursive
make debug -j2
fi
cd tests && ./run_tests.sh

View File

@ -1,95 +0,0 @@
dist: xenial
language: d
d:
- dmd
- ldc-beta
- ldc
os:
- linux
# TODO, some bug in OSX for the server that causes it to fail
# - osx
env:
- BUILD=
- BUILD=dub LIBDPARSE_VERSION=min
- BUILD=dub LIBDPARSE_VERSION=max
- BUILD=dub DSYMBOL_VERSION=min
- BUILD=dub DSYMBOL_VERSION=max
branches:
only:
- master
- /^v\d+\.\d+\.\d+([+-]\S*)*$/
script: ./.travis.sh
jobs:
include:
- stage: GitHub Release
#if: tag IS present
d: ldc-1.23.0
os: linux
script: echo "Deploying to GitHub releases ..." && ./release.sh
deploy:
provider: releases
api_key: $GH_REPO_TOKEN
file_glob: true
file: bin/dcd-*.tar.gz
skip_cleanup: true
on:
repo: dlang-community/DCD
tags: true
- stage: GitHub Release
#if: tag IS present
d: ldc-1.23.0
os: osx
script: echo "Deploying to GitHub releases ..." && ./release.sh
deploy:
provider: releases
api_key: $GH_REPO_TOKEN
file_glob: true
file: bin/dcd-*.tar.gz
skip_cleanup: true
on:
repo: dlang-community/DCD
tags: true
- stage: GitHub Release
#if: tag IS present
d: ldc-1.23.0
os: linux
script: echo "Deploying to GitHub releases ..." && ./release-windows.sh
addons:
apt:
packages:
- p7zip-full
deploy:
provider: releases
api_key: $GH_REPO_TOKEN
file_glob: true
file: bin/dcd-*.zip
skip_cleanup: true
on:
repo: dlang-community/DCD
tags: true
- stage: GitHub Release
#if: tag IS present
d: ldc-1.23.0
os: linux
script: echo "Deploying to GitHub releases ..." && ARCH=64 ./release-windows.sh
addons:
apt:
packages:
- p7zip-full
deploy:
provider: releases
api_key: $GH_REPO_TOKEN
file_glob: true
file: bin/dcd-*.zip
skip_cleanup: true
on:
repo: dlang-community/DCD
tags: true
stages:
- name: test
if: type = pull_request or (type = push and branch = master)

View File

@ -1,112 +0,0 @@
platform: x64
environment:
matrix:
- DC: dmd
DVersion: stable
arch: x64
- DC: dmd
DVersion: stable
arch: x86
# - DC: ldc
# DVersion: beta
# arch: x86
# - DC: ldc
# DVersion: beta
# arch: x64
# - DC: ldc
# DVersion: stable
# arch: x86
# - DC: ldc
# DVersion: stable
# arch: x64
skip_tags: false
branches:
only:
- master
- /^v\d+\.\d+\.\d+([+-]\S*)*$/
install:
- ps: function ResolveLatestDMD
{
$version = $env:DVersion;
if($version -eq "stable") {
$latest = (Invoke-WebRequest "http://downloads.dlang.org/releases/LATEST").toString();
$url = "http://downloads.dlang.org/releases/2.x/$($latest)/dmd.$($latest).windows.7z";
}elseif($version -eq "beta") {
$latest = (Invoke-WebRequest "http://downloads.dlang.org/pre-releases/LATEST").toString();
$latestVersion = $latest.split("-")[0].split("~")[0];
$url = "http://downloads.dlang.org/pre-releases/2.x/$($latestVersion)/dmd.$($latest).windows.7z";
}elseif($version -eq "nightly") {
$url = "http://nightlies.dlang.org/dmd-master-2017-05-20/dmd.master.windows.7z"
}else {
$url = "http://downloads.dlang.org/releases/2.x/$($version)/dmd.$($version).windows.7z";
}
$env:PATH += ";C:\dmd2\windows\bin;";
return $url;
}
- ps: function ResolveLatestLDC
{
$version = $env:DVersion;
if($version -eq "stable") {
$latest = (Invoke-WebRequest "https://ldc-developers.github.io/LATEST").toString().replace("`n","").replace("`r","");
$url = "https://github.com/ldc-developers/ldc/releases/download/v$($latest)/ldc2-$($latest)-win64-msvc.zip";
}elseif($version -eq "beta") {
$latest = (Invoke-WebRequest "https://ldc-developers.github.io/LATEST_BETA").toString().replace("`n","").replace("`r","");
$url = "https://github.com/ldc-developers/ldc/releases/download/v$($latest)/ldc2-$($latest)-win64-msvc.zip";
} else {
$latest = $version;
$url = "https://github.com/ldc-developers/ldc/releases/download/v$($version)/ldc2-$($version)-win64-msvc.zip";
}
$env:PATH += ";C:\ldc2-$($latest)-win64-msvc\bin";
$env:DC = "ldc2";
return $url;
}
- ps: function SetUpDCompiler
{
$env:toolchain = "msvc";
if($env:DC -eq "dmd"){
echo "downloading ...";
$url = ResolveLatestDMD;
echo $url;
Invoke-WebRequest $url -OutFile "c:\dmd.7z";
echo "finished.";
pushd c:\\;
7z x dmd.7z > $null;
popd;
}
elseif($env:DC -eq "ldc"){
echo "downloading ...";
$url = ResolveLatestLDC;
echo $url;
Invoke-WebRequest $url -OutFile "c:\ldc.zip";
echo "finished.";
pushd c:\\;
7z x ldc.zip > $null;
popd;
}
}
- ps: SetUpDCompiler
build_script:
- ps: if($env:arch -eq "x86"){
$env:compilersetupargs = "x86";
$env:Darch = "x86";
$env:DConf = "m32";
}elseif($env:arch -eq "x64"){
$env:compilersetupargs = "amd64";
$env:Darch = "x86_64";
$env:DConf = "m64";
}
- ps: $env:compilersetup = "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall";
- '"%compilersetup%" %compilersetupargs%'
test_script:
- echo %PLATFORM%
- echo %Darch%
- echo %DC%
- echo %PATH%
- '%DC% --version'
- dub test --arch=%Darch% --compiler=%DC%
- git submodule update --init --recursive
- build.bat

View File

@ -1,22 +0,0 @@
#!/usr/bin/env bash
# Build the Windows binaries under Linux
set -eux -o pipefail
BIN_NAME=dcd
# Allow the script to be run from anywhere
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
source setup-ldc-windows.sh
# Run LDC with cross-compilation
archiveName="$BIN_NAME-$VERSION-$OS-$ARCH_SUFFIX.zip"
echo "Building $archiveName"
mkdir -p bin
DC=ldmd2 make ldcclient ldcserver
cd bin
mv dcd-client dcd-client.exe
mv dcd-server dcd-server.exe
zip "$archiveName" "dcd-client.exe" "dcd-server.exe"

View File

@ -1,23 +0,0 @@
#!/usr/bin/env bash
set -eux -o pipefail
VERSION=$(git describe --abbrev=0 --tags)
ARCH="${ARCH:-64}"
LDC_FLAGS=()
unameOut="$(uname -s)"
case "$unameOut" in
Linux*) OS=linux; LDC_FLAGS=("-flto=full" "-linker=gold" "-static") ;;
Darwin*) OS=osx; LDC_FLAGS+=("-L-macosx_version_min" "-L10.7" "-L-lcrt1.o"); ;;
*) echo "Unknown OS: $unameOut"; exit 1
esac
case "$ARCH" in
64) ARCH_SUFFIX="x86_64";;
32) ARCH_SUFFIX="x86";;
*) echo "Unknown ARCH: $ARCH"; exit 1
esac
archiveName="dcd-$VERSION-$OS-$ARCH_SUFFIX.tar.gz"
echo "Building $archiveName"
${MAKE:-make} ldcclient ldcserver LDC_FLAGS="${LDC_FLAGS[*]}"
tar cvfz "bin/$archiveName" -C bin dcd-server dcd-client

View File

@ -1,52 +0,0 @@
#!/usr/bin/env bash
# Sets up LDC for cross-compilation. Source this script, s.t. the new LDC is in PATH
# Make sure this version matches the version of LDC2 used in .travis.yml,
# otherwise the compiler and the lib used might mismatch.
LDC_VERSION="1.23.0"
ARCH=${ARCH:-32}
VERSION=$(git describe --abbrev=0 --tags)
OS=windows
# LDC should already be installed (see .travis.yml)
# However, we need the libraries, so download them
# We can't use the downloaded ldc2 itself, because obviously it's for Windows
if [ "${ARCH}" == 64 ]; then
ARCH_SUFFIX='x86_64'
ZIP_ARCH_SUFFIX='x64'
else
ARCH_SUFFIX='i686'
ZIP_ARCH_SUFFIX='x86'
fi
LDC_DIR_PATH="$(pwd)/ldc2-${LDC_VERSION}-windows-${ZIP_ARCH_SUFFIX}"
LDC_XDFLAGS="-conf=${LDC_DIR_PATH}/etc/ldc2.conf -mtriple=${ARCH_SUFFIX}-pc-windows-msvc"
# Step 1: download the LDC Windows release
# Check if the user already have it (e.g. building locally)
if [ ! -d ${LDC_DIR_PATH} ]; then
if [ ! -d "ldc2-${LDC_VERSION}-windows-${ZIP_ARCH_SUFFIX}.7z" ]; then
wget "https://github.com/ldc-developers/ldc/releases/download/v${LDC_VERSION}/ldc2-${LDC_VERSION}-windows-${ZIP_ARCH_SUFFIX}.7z"
fi
7z x "ldc2-${LDC_VERSION}-windows-${ZIP_ARCH_SUFFIX}.7z" > /dev/null
fi
# Step 2: Generate a config file with the proper path
cat > ${LDC_DIR_PATH}/etc/ldc2.conf <<EOF
default:
{
switches = [
"-defaultlib=phobos2-ldc,druntime-ldc",
"-link-defaultlib-shared=false",
];
post-switches = [
"-I${LDC_DIR_PATH}/import",
];
lib-dirs = [
"${LDC_DIR_PATH}/lib/",
"${LDC_DIR_PATH}/lib/mingw/",
];
};
EOF