Skip to content

Commit

Permalink
Merge branch 'master' into romanschejbal/reasonmlgh-2422
Browse files Browse the repository at this point in the history
  • Loading branch information
romanschejbal authored Oct 29, 2019
2 parents 1eccf87 + 611cde3 commit 6a27973
Show file tree
Hide file tree
Showing 145 changed files with 6,670 additions and 44,850 deletions.
82 changes: 82 additions & 0 deletions .ci/build-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
parameters:
platform: "macOS"
vmImage: "macOS-10.13"

jobs:
- job: ${{ parameters.platform }}
pool:
vmImage: ${{ parameters.vmImage }}
demands: node.js
timeoutInMinutes: 120 # This is mostly for Windows
steps:
- powershell: $Env:Path
continueOnError: true
condition: and(eq(variables['AGENT.OS'], 'Windows_NT'), and(eq(variables['Build.Reason'], 'PullRequest'), and(succeeded(), ne(variables['Build.SourceBranch'], variables['System.PullRequest.TargetBranch']))))
displayName: "Print env in powershell"
# Needed so that the mingw tar doesn't shadow the system tar. See
# pipelines.yaml. We need windows bsdtar from system32, not the mingw
# one. Note powershell doesn't need escaping of backslashes.
- powershell: Write-Host "##vso[task.setvariable variable=PATH;]C:\Windows\system32;${env:PATH}"
continueOnError: true
condition: eq(variables['AGENT.OS'], 'Windows_NT')
displayName: "Make sure windows/system32 is at front of path if windows"
- powershell: $Env:Path
continueOnError: true
condition: and(eq(variables['AGENT.OS'], 'Windows_NT'), and(eq(variables['Build.Reason'], 'PullRequest'), and(succeeded(), ne(variables['Build.SourceBranch'], variables['System.PullRequest.TargetBranch']))))
displayName: "Print env in powershell"
- powershell: get-command tar
continueOnError: true
condition: and(eq(variables['AGENT.OS'], 'Windows_NT'), and(eq(variables['Build.Reason'], 'PullRequest'), and(succeeded(), ne(variables['Build.SourceBranch'], variables['System.PullRequest.TargetBranch']))))
displayName: "Print where tar is located"
- powershell: tar --help
continueOnError: true
condition: and(eq(variables['AGENT.OS'], 'Windows_NT'), and(eq(variables['Build.Reason'], 'PullRequest'), and(succeeded(), ne(variables['Build.SourceBranch'], variables['System.PullRequest.TargetBranch']))))
displayName: "Print tar help"
- bash: |
# COMPUTE THE ESY INSTALL CACHE LOCATION AHEAD OF TIME
DESIRED_LEN="86"
# Note: This will need to change when upgrading esy version
# that reenables long paths on windows.
if [ "$AGENT_OS" == "Windows_NT" ]; then
DESIRED_LEN="33"
fi
HOME_ESY3="$HOME/.esy/3"
HOME_ESY3_LEN=${#HOME_ESY3}
NUM_UNDERS=$(echo "$(($DESIRED_LEN-$HOME_ESY3_LEN))")
UNDERS=$(printf "%-${NUM_UNDERS}s" "_")
UNDERS="${UNDERS// /_}"
THE_ESY__CACHE_INSTALL_PATH=${HOME_ESY3}${UNDERS}/i
if [ "$AGENT_OS" == "Windows_NT" ]; then
THE_ESY__CACHE_INSTALL_PATH=$( cygpath --mixed --absolute "$THE_ESY__CACHE_INSTALL_PATH")
fi
echo "THE_ESY__CACHE_INSTALL_PATH: $THE_ESY__CACHE_INSTALL_PATH"
# This will be exposed as an env var ESY__CACHE_INSTALL_PATH, or an
# Azure var esy__cache_install_path
echo "##vso[task.setvariable variable=esy__cache_install_path]$THE_ESY__CACHE_INSTALL_PATH"
# - bash: |
# which esy
# echo "$( which esy )"
# echo "##vso[task.setvariable variable=esy_bin_location]$(which esy)"
# displayName: "Find esy binary"
# - bash: echo ${ESY_BIN_LOCATION}
# displayName: "Print esy bin location"
- bash: env
displayName: "Print environment"
- template: utils/use-node.yml
- template: utils/use-esy.yml
- script: "esy install"
displayName: "esy install"
- template: utils/restore-build-cache.yml
- script: "esy build"
displayName: "esy build"
- template: utils/create-docs.yml
- script: "esy test"
displayName: "Test command"
- script: "esy release"
displayName: "esy release"
- template: utils/publish-build-cache.yml
- task: PublishBuildArtifacts@1
displayName: "Publish Artifact: ${{ parameters.platform }}"
inputs:
PathtoPublish: "_release"
ArtifactName: ${{ parameters.platform }}
34 changes: 34 additions & 0 deletions .ci/cross-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
steps:
- template: utils/use-node.yml

- script: "mkdir _release"
displayName: "Create _release dir"

- template: release-platform-setup.yml
parameters:
platform: "Linux"
folder: "platform-linux"

- template: release-platform-setup.yml
parameters:
platform: "macOS"
folder: "platform-darwin"

- template: release-platform-setup.yml
parameters:
platform: "Windows"
folder: "platform-windows-x64"

- script: "node .ci/pipelines-release.js"
displayName: "node .ci/pipelines-release.js"
continueOnError: true

- script: "npm pack ."
displayName: "npm pack"
workingDirectory: "_release"

- task: PublishBuildArtifacts@1
displayName: "Publish Artifact: Release"
inputs:
PathtoPublish: "_release"
ArtifactName: Release
106 changes: 106 additions & 0 deletions .ci/pipelines-release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
const fs = require("fs");
const path = require("path");

console.log("Creating package.json");

// From the project root pwd
const mainPackageJsonPath =
fs.existsSync('esy.json') ?
'esy.json' : 'package.json';

const exists = fs.existsSync(mainPackageJsonPath);
if (!exists) {
console.error("No package.json or esy.json at " + mainPackageJsonPath);
process.exit(1);
}
// Now require from this script's location.
const mainPackageJson = require(path.join('..', mainPackageJsonPath));
const bins =
Array.isArray(mainPackageJson.esy.release.bin) ?
mainPackageJson.esy.release.bin.reduce(
(acc, curr) => Object.assign({ [curr]: "bin/" + curr }, acc),
{}
) :
Object.keys(mainPackageJson.esy.release.bin).reduce(
(acc, currKey) => Object.assign({ [currKey]: "bin/" + mainPackageJson.esy.release.bin[currKey] }, acc),
{}
);

const packageJson = JSON.stringify(
{
name: mainPackageJson.name,
version: mainPackageJson.version,
license: mainPackageJson.license,
description: mainPackageJson.description,
repository: mainPackageJson.repository,
scripts: {
postinstall: "node ./postinstall.js"
},
bin: bins,
files: [
"_export/",
"bin/",
"postinstall.js",
"esyInstallRelease.js",
"platform-linux/",
"platform-darwin/",
"platform-windows-x64/"
]
},
null,
2
);

fs.writeFileSync(
path.join(__dirname, "..", "_release", "package.json"),
packageJson,
{
encoding: "utf8"
}
);

try {
console.log("Copying LICENSE");
fs.copyFileSync(
path.join(__dirname, "..", "LICENSE"),
path.join(__dirname, "..", "_release", "LICENSE")
);
} catch (e) {
console.warn("No LICENSE found");
}

console.log("Copying README.md");
fs.copyFileSync(
path.join(__dirname, "..", "README.md"),
path.join(__dirname, "..", "_release", "README.md")
);

console.log("Copying postinstall.js");
fs.copyFileSync(
path.join(__dirname, "release-postinstall.js"),
path.join(__dirname, "..", "_release", "postinstall.js")
);

console.log("Creating placeholder files");
const placeholderFile = `:; echo "You need to have postinstall enabled"; exit $?
@ECHO OFF
ECHO You need to have postinstall enabled`;
fs.mkdirSync(path.join(__dirname, "..", "_release", "bin"));

Object.keys(bins).forEach(
name => {
if(bins[name]) {
const binPath = path.join(
__dirname,
"..",
"_release",
bins[name]
);
fs.writeFileSync(binPath, placeholderFile);
fs.chmodSync(binPath, 0777);
} else {
console.log("bins[name] name=" + name + " was empty. Weird.");
console.log(bins);
}
}
);
16 changes: 16 additions & 0 deletions .ci/release-platform-setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
parameters:
platform: "macOS"
folder: "platform-darwin"

steps:
- task: DownloadBuildArtifacts@0
displayName: "Download ${{ parameters.platform }} Artifacts"
inputs:
artifactName: ${{ parameters.platform }}
downloadPath: $(Build.StagingDirectory)

- script: "mkdir _release/${{ parameters.folder }}"
displayName: "Create _release/${{ parameters.folder }}"

- script: "cp -r $(Build.StagingDirectory)/${{ parameters.platform }}/ _release/${{ parameters.folder }}"
displayName: "cp ${{ parameters.platform }}"
Loading

0 comments on commit 6a27973

Please sign in to comment.