Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Windows build and deploy script (#4547)
- Loading branch information
Showing
3 changed files
with
148 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: CE Windows Build | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
buildnumber: | ||
description: 'Build number' | ||
default: '' | ||
required: true | ||
|
||
jobs: | ||
build_dist: | ||
runs-on: windows-2019 | ||
outputs: | ||
release_name: ${{ steps.build_dist.outputs.release_name }} | ||
branch: ${{ steps.build_dist.outputs.branch }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{ github.event.inputs.buildnumber }} | ||
- name: Use Node.js 16.x | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16.x | ||
cache: npm | ||
- name: Build distribution | ||
id: build_dist | ||
run: powershell -File etc/scripts/build-dist-win.ps1 | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: dist | ||
path: out/dist-bin | ||
|
||
deploy: | ||
needs: [build_dist] | ||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Use Node.js 16.x | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16.x | ||
cache: npm | ||
- name: Download the built distribution | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: dist | ||
path: out/dist-bin | ||
- name: Deploy | ||
uses: jakejarvis/s3-sync-action@master | ||
with: | ||
args: --acl public-read --follow-symlinks | ||
env: | ||
AWS_S3_BUCKET: compiler-explorer | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
SOURCE_DIR: out/dist-bin | ||
DEST_DIR: dist/gh/${{ needs.build_dist.outputs.branch }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
Set-Location -Path $PSScriptRoot/../.. | ||
$ROOT=Get-Location | ||
|
||
# Assumption here is that the current commit that's checked out is already tagged | ||
$RELEASE_FILE_NAME = (git describe --tags) -join [Environment]::NewLine -replace "gh-" | ||
$RELEASE_NAME = (git describe --tags) -join [Environment]::NewLine | ||
$HASH=(git rev-parse HEAD) -join [Environment]::NewLine | ||
|
||
Write-Host "RELEASE_FILE_NAME: $RELEASE_FILE_NAME" | ||
Write-Host "RELEASE_NAME: $RELEASE_NAME" | ||
Write-Host "HASH: $HASH" | ||
|
||
Write-Host "GITHUB_OUTPUT: $env:GITHUB_OUTPUT" | ||
|
||
return | ||
|
||
# Clear the output | ||
Remove-Item -Path "out" -Recurse -Force -ErrorAction Ignore | ||
New-Item -Path . -Name "out/dist" -Force -ItemType "directory" | ||
|
||
Set-Location -Path "./out/dist" | ||
|
||
New-Item -Name "git_hash" | ||
Set-Content -Path "git_hash" -Value "$HASH" | ||
|
||
New-Item -Name "release_build" | ||
Set-Content -Path "release_build" -Value "$RELEASE_NAME" | ||
|
||
Copy-Item -Path "$ROOT/etc" -Destination . -Recurse | ||
Copy-Item -Path "$ROOT/examples" -Destination . -Recurse | ||
Copy-Item -Path "$ROOT/views" -Destination . -Recurse | ||
Copy-Item -Path "$ROOT/types" -Destination . -Recurse | ||
Copy-Item -Path "$ROOT/package*.json" -Destination . -Recurse | ||
|
||
Remove-Item -Path "$ROOT/lib/storage/data" -Force -Recurse -ErrorAction Ignore | ||
|
||
# Set up and build and webpack everything | ||
Set-Location -Path $ROOT | ||
|
||
npm install --no-audit | ||
npm run webpack | ||
npm run ts-compile | ||
|
||
# Now install only the production dependencies in our output directory | ||
Set-Location -Path "./out/dist" | ||
npm install --no-audit --ignore-scripts --production | ||
|
||
Remove-Item -Path "node_modules/.cache" -Force -Recurse -ErrorAction Ignore | ||
Remove-Item -Path "node_modules/monaco-editor" -Force -Recurse -ErrorAction Ignore | ||
Remove-Item -Path "node_modules" -Include "*.ts" -Force -Recurse -ErrorAction Ignore | ||
|
||
# Output some magic for GH to set the branch name and release name | ||
|
||
$BRANCH = $GITHUB_REF -replace "refs/heads/" | ||
Add-Content -Path $env:GITHUB_OUTPUT -Value "branch=$BRANCH" | ||
Add-Content -Path $env:GITHUB_OUTPUT -Value "release_name=$RELEASE_NAME" | ||
|
||
# Run to make sure we haven't just made something that won't work | ||
node -r esm ./app.js --version --dist | ||
|
||
Remove-Item -Path "$ROOT/out/dist-bin" -Force -Recurse -ErrorAction Ignore | ||
New-Item -Path $ROOT -Name "out/dist-bin" -Force -ItemType "directory" | ||
|
||
# This part is different from build-dist.sh (zip instead of tarxz) | ||
if ($IsWindows -or $ENV:OS) { | ||
Compress-Archive -Path "./*" -DestinationPath "$ROOT/out/dist-bin/$RELEASE_FILE_NAME.zip" | ||
} else { | ||
$env:XZ_OPT="-1 -T 0" | ||
tar -Jcf "$ROOT/out/dist-bin/$RELEASE_FILE_NAME.tar.xz" . | ||
} | ||
|
||
New-Item -Path $ROOT -Name "out/webpack" -Force -ItemType "directory" | ||
Push-Location -Path "$ROOT/out/webpack" | ||
if ($IsWindows -or $ENV:OS) { | ||
Compress-Archive -Path "static/*" -DestinationPath "$ROOT/out/dist-bin/$RELEASE_FILE_NAME.static.zip" | ||
} else { | ||
tar -Jcf "$ROOT/out/dist-bin/$RELEASE_FILE_NAME.static.tar.xz" --transform="s,^static/,," static/* | ||
} | ||
Pop-Location | ||
|
||
Set-Content -Path "$ROOT/out/dist-bin/$RELEASE_FILE_NAME.txt" -Value "$HASH" | ||
|
||
Set-Location -Path $ROOT |