Skip to content

Commit

Permalink
Build Windows portable and installer packages on CI (crystal-lang#13578)
Browse files Browse the repository at this point in the history
  • Loading branch information
HertzDevil authored Jul 2, 2023
1 parent 0f2c637 commit 9b76eb3
Show file tree
Hide file tree
Showing 7 changed files with 526 additions and 122 deletions.
167 changes: 45 additions & 122 deletions .github/workflows/win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
key: win-dlls-${{ hashFiles('.github/workflows/win.yml', 'etc/win-ci/*.ps1') }}-msvc
- name: Build libgc
if: steps.cache-dlls.outputs.cache-hit != 'true'
run: .\etc\win-ci\build-gc.ps1 -BuildTree deps\gc -Version 8.2.2 -AtomicOpsVersion 7.8.0 -Dynamic
run: .\etc\win-ci\build-gc.ps1 -BuildTree deps\gc -Version 8.2.4 -AtomicOpsVersion 7.8.0 -Dynamic
- name: Build libpcre
if: steps.cache-dlls.outputs.cache-hit != 'true'
run: .\etc\win-ci\build-pcre.ps1 -BuildTree deps\pcre -Version 8.45 -Dynamic
Expand Down Expand Up @@ -201,8 +201,14 @@ jobs:
cmake -DCMAKE_INSTALL_PREFIX=$(pwd)\llvm -P cmake_install.cmake
x86_64-windows:
runs-on: windows-2022
needs: [x86_64-windows-libs, x86_64-windows-dlls, x86_64-windows-llvm]
uses: ./.github/workflows/win_build_portable.yml
with:
release: false

x86_64-windows-test:
runs-on: windows-2022
needs: [x86_64-windows]
steps:
- name: Disable CRLF line ending substitution
run: |
Expand All @@ -211,72 +217,15 @@ jobs:
- name: Enable Developer Command Prompt
uses: ilammy/msvc-dev-cmd@cec98b9d092141f74527d0afa6feb2af698cfe89 # v1.12.1

- name: Install Crystal
uses: crystal-lang/install-crystal@v1
with:
crystal: "1.8.2"

- name: Download Crystal source
uses: actions/checkout@v3

- name: Restore libraries
uses: actions/cache/restore@v3
with:
path: |
libs/pcre.lib
libs/pcre2-8.lib
libs/iconv.lib
libs/gc.lib
libs/ffi.lib
libs/z.lib
libs/mpir.lib
libs/yaml.lib
libs/xml2.lib
key: win-libs-${{ hashFiles('.github/workflows/win.yml', 'etc/win-ci/*.ps1') }}-msvc
fail-on-cache-miss: true
- name: Restore OpenSSL
uses: actions/cache/restore@v3
with:
path: |
libs/crypto.lib
libs/ssl.lib
libs/openssl_VERSION
key: win-openssl-libs-3.1.0-${{ hashFiles('etc/win-ci/build-openssl.ps1') }}-msvc
fail-on-cache-miss: true
- name: Restore DLLs
uses: actions/cache/restore@v3
with:
path: |
libs/pcre-dynamic.lib
libs/pcre2-8-dynamic.lib
libs/iconv-dynamic.lib
libs/gc-dynamic.lib
libs/ffi-dynamic.lib
libs/z-dynamic.lib
libs/mpir-dynamic.lib
libs/yaml-dynamic.lib
libs/xml2-dynamic.lib
dlls/pcre.dll
dlls/pcre2-8.dll
dlls/libiconv.dll
dlls/gc.dll
dlls/libffi.dll
dlls/zlib1.dll
dlls/mpir.dll
dlls/yaml.dll
dlls/libxml2.dll
key: win-dlls-${{ hashFiles('.github/workflows/win.yml', 'etc/win-ci/*.ps1') }}-msvc
fail-on-cache-miss: true
- name: Restore OpenSSL DLLs
uses: actions/cache/restore@v3
- name: Download Crystal executable
uses: actions/download-artifact@v3
with:
path: |
libs/crypto-dynamic.lib
libs/ssl-dynamic.lib
dlls/libcrypto-3-x64.dll
dlls/libssl-3-x64.dll
key: win-openssl-dlls-3.1.0-${{ hashFiles('etc/win-ci/build-openssl.ps1') }}-msvc
fail-on-cache-miss: true
name: crystal
path: build

- name: Restore LLVM
uses: actions/cache/restore@v3
with:
Expand All @@ -286,71 +235,44 @@ jobs:

- name: Set up environment
run: |
echo "CRYSTAL_LIBRARY_PATH=$(pwd)\libs" >> ${env:GITHUB_ENV}
echo "LLVM_CONFIG=$(pwd)\llvm\bin\llvm-config.exe" >> ${env:GITHUB_ENV}
- name: Build LLVM extensions
run: make -f Makefile.win deps
Add-Content $env:GITHUB_PATH "$(pwd)\build"
Add-Content $env:GITHUB_ENV "CRYSTAL_SPEC_COMPILER_BIN=$(pwd)\build\crystal.exe"
Add-Content $env:GITHUB_ENV "LLVM_CONFIG=$(pwd)\llvm\bin\llvm-config.exe"
- name: Build Crystal
run: |
bin/crystal.bat env
make -f Makefile.win -B
- name: Run stdlib specs
run: make -f Makefile.win std_spec

- name: Download shards release
uses: actions/checkout@v3
with:
repository: crystal-lang/shards
ref: v0.17.3
path: shards
- name: Run compiler specs
run: make -f Makefile.win compiler_spec

- name: Download molinillo release
uses: actions/checkout@v3
with:
repository: crystal-lang/crystal-molinillo
ref: v0.2.0
path: shards/lib/molinillo
- name: Run primitives specs
run: make -f Makefile.win -o .build\crystal.exe primitives_spec # we know the compiler is fresh; do not rebuild it here

- name: Build shards release
working-directory: ./shards
run: ../bin/crystal.bat build src/shards.cr
- name: Build samples
run: make -f Makefile.win samples

- name: Gather Crystal binaries
run: |
mkdir crystal/src
mkdir crystal/lib
cp .build/crystal.exe crystal/
cp shards/shards.exe crystal/
cp libs/* crystal/lib/
cp dlls/* crystal/
cp src/* crystal/src -Recurse
rm crystal/src/llvm/ext/llvm_ext.obj
- name: Upload Crystal binaries
uses: actions/upload-artifact@v3
with:
name: crystal
path: crystal
x86_64-windows-release:
needs: [x86_64-windows-libs, x86_64-windows-dlls, x86_64-windows-llvm]
uses: ./.github/workflows/win_build_portable.yml
with:
release: true

x86_64-windows-test:
x86_64-windows-installer:
runs-on: windows-2022
needs: [x86_64-windows]
needs: [x86_64-windows-release]
steps:
- name: Disable CRLF line ending substitution
run: |
git config --global core.autocrlf false
- name: Enable Developer Command Prompt
uses: ilammy/msvc-dev-cmd@cec98b9d092141f74527d0afa6feb2af698cfe89 # v1.12.1

- name: Download Crystal source
uses: actions/checkout@v3

- name: Download Crystal executable
uses: actions/download-artifact@v3
with:
name: crystal
path: build
name: crystal-release
path: etc/win-ci/portable

- name: Restore LLVM
uses: actions/cache/restore@v3
Expand All @@ -361,18 +283,19 @@ jobs:

- name: Set up environment
run: |
Add-Content $env:GITHUB_PATH "$(pwd)\build"
Add-Content $env:GITHUB_ENV "CRYSTAL_SPEC_COMPILER_BIN=$(pwd)\build\crystal.exe"
Add-Content $env:GITHUB_PATH "$(pwd)\etc\win-ci\portable"
Add-Content $env:GITHUB_ENV "LLVM_CONFIG=$(pwd)\llvm\bin\llvm-config.exe"
- name: Run stdlib specs
run: make -f Makefile.win std_spec
- name: Build docs
run: make -f Makefile.win install_docs prefix=etc\win-ci\portable

- name: Run compiler specs
run: make -f Makefile.win compiler_spec

- name: Run primitives specs
run: make -f Makefile.win -o .build\crystal.exe primitives_spec # we know the compiler is fresh; do not rebuild it here
- name: Build installer
working-directory: ./etc/win-ci
run: |
iscc.exe crystal.iss
- name: Build samples
run: make -f Makefile.win samples
- name: Upload Crystal installer
uses: actions/upload-artifact@v3
with:
name: crystal-installer
path: etc/win-ci/Output/crystal-setup.exe
138 changes: 138 additions & 0 deletions .github/workflows/win_build_portable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: Windows CI / Build Portable Package

on:
workflow_call:
inputs:
release:
required: true
type: boolean

jobs:
build:
runs-on: windows-2022
steps:
- name: Disable CRLF line ending substitution
run: |
git config --global core.autocrlf false
- name: Enable Developer Command Prompt
uses: ilammy/msvc-dev-cmd@cec98b9d092141f74527d0afa6feb2af698cfe89 # v1.12.1

- name: Install Crystal
uses: crystal-lang/install-crystal@v1
with:
crystal: "1.8.2"

- name: Download Crystal source
uses: actions/checkout@v3

- name: Restore libraries
uses: actions/cache/restore@v3
with:
path: |
libs/pcre.lib
libs/pcre2-8.lib
libs/iconv.lib
libs/gc.lib
libs/ffi.lib
libs/z.lib
libs/mpir.lib
libs/yaml.lib
libs/xml2.lib
key: win-libs-${{ hashFiles('.github/workflows/win.yml', 'etc/win-ci/*.ps1') }}-msvc
fail-on-cache-miss: true
- name: Restore OpenSSL
uses: actions/cache/restore@v3
with:
path: |
libs/crypto.lib
libs/ssl.lib
libs/openssl_VERSION
key: win-openssl-libs-3.1.0-${{ hashFiles('etc/win-ci/build-openssl.ps1') }}-msvc
fail-on-cache-miss: true
- name: Restore DLLs
uses: actions/cache/restore@v3
with:
path: |
libs/pcre-dynamic.lib
libs/pcre2-8-dynamic.lib
libs/iconv-dynamic.lib
libs/gc-dynamic.lib
libs/ffi-dynamic.lib
libs/z-dynamic.lib
libs/mpir-dynamic.lib
libs/yaml-dynamic.lib
libs/xml2-dynamic.lib
dlls/pcre.dll
dlls/pcre2-8.dll
dlls/libiconv.dll
dlls/gc.dll
dlls/libffi.dll
dlls/zlib1.dll
dlls/mpir.dll
dlls/yaml.dll
dlls/libxml2.dll
key: win-dlls-${{ hashFiles('.github/workflows/win.yml', 'etc/win-ci/*.ps1') }}-msvc
fail-on-cache-miss: true
- name: Restore OpenSSL DLLs
uses: actions/cache/restore@v3
with:
path: |
libs/crypto-dynamic.lib
libs/ssl-dynamic.lib
dlls/libcrypto-3-x64.dll
dlls/libssl-3-x64.dll
key: win-openssl-dlls-3.1.0-${{ hashFiles('etc/win-ci/build-openssl.ps1') }}-msvc
fail-on-cache-miss: true
- name: Restore LLVM
uses: actions/cache/restore@v3
with:
path: llvm
key: llvm-libs-16.0.3-msvc
fail-on-cache-miss: true

- name: Set up environment
run: |
echo "CRYSTAL_LIBRARY_PATH=$(pwd)\libs" >> ${env:GITHUB_ENV}
echo "LLVM_CONFIG=$(pwd)\llvm\bin\llvm-config.exe" >> ${env:GITHUB_ENV}
- name: Build LLVM extensions
run: make -f Makefile.win deps

- name: Build Crystal
run: |
bin/crystal.bat env
make -f Makefile.win -B ${{ inputs.release && 'release=1' || '' }}
- name: Download shards release
uses: actions/checkout@v3
with:
repository: crystal-lang/shards
ref: v0.17.3
path: shards

- name: Download molinillo release
uses: actions/checkout@v3
with:
repository: crystal-lang/crystal-molinillo
ref: v0.2.0
path: shards/lib/molinillo

- name: Build shards release
working-directory: ./shards
run: ../bin/crystal.bat build ${{ inputs.release && '--release' || '' }} src/shards.cr

- name: Gather Crystal binaries
run: |
make -f Makefile.win install prefix=crystal
mkdir crystal/lib
cp shards/shards.exe crystal/
cp libs/* crystal/lib/
cp dlls/* crystal/
cp README.md crystal/
- name: Upload Crystal binaries
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.release && 'crystal-release' || 'crystal' }}
path: crystal
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ install_docs: docs ## Install docs at DESTDIR

cp -av docs "$(DATADIR)/docs"
cp -av samples "$(DATADIR)/examples"
rm -rf "$(DATADIR)/examples/.gitignore"

.PHONY: uninstall_docs
uninstall_docs: ## Uninstall docs from DESTDIR
Expand Down
1 change: 1 addition & 0 deletions Makefile.win
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ install_docs: docs ## Install docs at prefix
$(call MKDIR,"$(DATADIR)")
$(call INSTALLDIR,docs,"$(DATADIR)\docs")
$(call INSTALLDIR,samples,"$(DATADIR)\examples")
$(call RM,"$(DATADIR)\examples\.gitignore")

.PHONY: uninstall_docs
uninstall_docs: ## Uninstall docs from prefix
Expand Down
Binary file added etc/win-ci/crystal.bmp
Binary file not shown.
Loading

0 comments on commit 9b76eb3

Please sign in to comment.