Build and Release #141
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
name: Build and Release | |
on: | |
push: | |
branches: | |
- master | |
- 'feature/**' | |
- 'bugfix/**' | |
- 'github/**' | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build | |
outputs: | |
# accessible from other jobs as ${{needs.build.outputs.version_full}} | |
version_full: ${{steps.version.outputs.version_full}} | |
version_packed: ${{steps.version.outputs.version_packed}} | |
version_major: ${{steps.version.outputs.version_major}} | |
version_minor: ${{steps.version.outputs.version_minor}} | |
version_revision: ${{steps.version.outputs.version_revision}} | |
version_build: ${{steps.version.outputs.version_build}} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest] # nothing works on macos-latest (`cppunit` fails to build. `zlib` not found) | |
arch: [x86, amd64] | |
compiler: [gcc] | |
include: | |
- os: windows-latest | |
arch: x86 | |
compiler: msvc | |
- os: windows-latest | |
arch: amd64 | |
compiler: msvc | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Brew Dependencies | |
if: startsWith(matrix.os, 'macos') | |
run: | | |
brew install scons mingw-w64 libtool autoconf automake | |
- name: Apt Dependencies | |
if: startsWith(matrix.os, 'ubuntu') | |
run: sudo DEBIAN_FRONTEND=noninteractive apt-get install -y scons mingw-w64 | |
- name: Setup Python | |
if: startsWith(matrix.os, 'windows') | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Windows Dependencies | |
if: startsWith(matrix.os, 'windows') | |
run: | | |
# install scons excluding build 4.8.0 (https://github.com/SCons/scons/issues/4585) | |
pip install -U scons!=4.8.0 | |
#pip install -U scons | |
# microsoft removed the download of htmlhelp.exe -- https://chocolatey.org/packages/html-help-workshop#comment-5245282888 | |
#choco install html-help-workshop | |
echo "${Env:ProgramFiles(x86)}\HTML Help Workshop" >> $Env:GITHUB_PATH | |
echo ------------------------------------------------------------- | |
py -0p | |
pip list | |
- name: Upgrade msys2/mingw64 | |
if: startsWith(matrix.os, 'windows') && matrix.compiler == 'gcc' | |
uses: msys2/setup-msys2@v2 | |
with: | |
msystem: mingw64 | |
release: false | |
update: true | |
install: >- | |
libtool | |
autoconf-wrapper | |
automake-wrapper | |
# `fetch-depth: 0` pulls full branch history. Needed to extract the SVN revision number from git comments | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
path: nsis | |
submodules: 'true' | |
fetch-depth: 0 | |
- name: Version | |
id: version | |
shell: python | |
working-directory: nsis | |
run: | | |
import sys, os | |
sys.path.insert(0, os.path.join(r'${{github.workspace}}', r'nsis')) | |
from nsis_version import * | |
version_full = nsis_version(build_number=${{github.run_number}}) | |
version_packed = nsis_packed_version(build_number=${{github.run_number}}) | |
version_major = nsis_major_version() | |
version_minor = nsis_minor_version() | |
version_revision = nsis_revision_number() | |
version_build = nsis_build_number(${{github.run_number}}) | |
print(f"version_full={version_full}") | |
print(f"version_full=[{version_major}, {version_minor}, {version_revision}, {version_build}]") | |
print(f"version_packed={version_packed}") | |
with open(os.getenv('GITHUB_OUTPUT'), "a") as fout: | |
fout.write(f"version_full={version_full}\n") | |
fout.write(f"version_packed={version_packed}\n") | |
fout.write(f"version_major={version_major}\n") | |
fout.write(f"version_minor={version_minor}\n") | |
fout.write(f"version_revision={version_revision}\n") | |
fout.write(f"version_build={version_build}\n") | |
- name: Zlib Checkout & Build | |
shell: python | |
working-directory: nsis | |
run: | | |
import sys, os | |
sys.path.insert(0, os.path.join(r'${{github.workspace}}', r'nsis')) | |
from nsis_build import * | |
# ----- nsis_build.py ----- | |
zlibdir = os.path.join(r'${{github.workspace}}', 'zlib') | |
git_checkout('https://github.com/madler/zlib.git', zlibdir) | |
build_zlib(r'${{matrix.compiler}}', r'${{matrix.arch}}', zlibdir) | |
- name: Debug MacOS | |
if: startsWith(matrix.os, 'macos') | |
run: | | |
ls -la /usr/bin/i686* || echo "no /usr/bin/i686* files" | |
echo ------------------------------------------------------------ | |
ls -la /usr/bin/x86_64* || echo "no /usr/bin/x86_64* files" | |
echo ------------------------------------------------------------ | |
ls -la /usr/bin/*-13 || echo "no /usr/bin/*-13 files" | |
ls -la /usr/local/bin/*-13 || echo "no /usr/local/bin/*-13 files" | |
echo ------------------------------------------------------------ | |
ls -la /usr/local/Cellar/gcc@13/13.3.0/bin/* || echo "/usr/local/Cellar/gcc@13/13.3.0/bin/* files" | |
echo ------------------------------------------------------------ | |
ls -la /opt/homebrew/bin/i686* || echo "no /opt/homebrew/bin/i686* files" | |
echo ------------------------------------------------------------ | |
ls -la /opt/homebrew/bin/x86_64* || echo "no /opt/homebrew/bin/x86_64* files" | |
echo ------------------------------------------------------------ | |
for compiler in cc c++ gcc g++ gcc-13 g++-13 clang clang++ | |
do | |
echo -- $compiler -------------------------------------------------------- | |
which $compiler | |
$compiler --version | |
done | |
- name: CppUnit Checkout & Build | |
shell: python | |
working-directory: nsis | |
run: | | |
import sys, os | |
sys.path.insert(0, os.path.join(r'${{github.workspace}}', r'nsis')) | |
from nsis_build import * | |
# ----- nsis_build.py ----- | |
cppunitdir = os.path.join(r'${{github.workspace}}', 'cppunit') | |
#git_checkout('git://anongit.freedesktop.org/git/libreoffice/cppunit', cppunitdir) # git server is unreliable lately | |
download_cppunit(cppunitdir) | |
build_cppunit(r'${{matrix.compiler}}', r'${{matrix.arch}}', cppunitdir) | |
- name: Build NSIS | |
working-directory: nsis | |
shell: python | |
run: | | |
import sys, os | |
sys.path.insert(0, os.path.join(r'${{github.workspace}}', r'nsis')) | |
from nsis_build import * | |
# ----- nsis_build.py ----- | |
zlibdir = os.path.join(r'${{github.workspace}}', 'zlib') | |
cppunitdir = os.path.join(r'${{github.workspace}}', 'cppunit') | |
build_nsis_distro(r'${{matrix.compiler}}', r'${{matrix.arch}}', ${{github.run_number}}, zlibdir, cppunitdir, nsislog=True, nsismaxstrlen=4096, actions=['test', 'dist-zip']) | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts-${{matrix.os}}-${{matrix.arch}}-${{matrix.compiler}} | |
path: nsis/nsis-*.zip | |
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= | |
package: | |
name: Package | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
# `fetch-depth: 0` pulls full branch history. Needed to extract the SVN revision number from git comments | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
pattern: artifacts-* | |
- name: Merge Architectures | |
shell: python | |
run: | | |
import sys, os | |
sys.path.insert(0, r'${{github.workspace}}') | |
from nsis_package import * | |
# ----- nsis_package.py ----- | |
# blend x86 and amd64 artifacts together | |
build_nsis_package('artifacts', '.instdist-ubuntu-x86', '.instdist-ubuntu-amd64') | |
- name: Build NSIS Setup (x86) | |
shell: python | |
run: | | |
import sys, os | |
sys.path.insert(0, r'${{github.workspace}}') | |
from nsis_package import * | |
# ----- nsis_package.py ----- | |
build_nsis_installer('.instdist-ubuntu-x86', 'x86', ${{needs.build.outputs.version_major}}, ${{needs.build.outputs.version_minor}}, ${{needs.build.outputs.version_revision}}, ${{needs.build.outputs.version_build}}) | |
- name: Build NSIS Setup (amd64) | |
shell: python | |
run: | | |
import sys, os | |
sys.path.insert(0, r'${{github.workspace}}') | |
from nsis_package import * | |
# ----- nsis_package.py ----- | |
build_nsis_installer('.instdist-ubuntu-amd64', 'amd64', ${{needs.build.outputs.version_major}}, ${{needs.build.outputs.version_minor}}, ${{needs.build.outputs.version_revision}}, ${{needs.build.outputs.version_build}}) | |
- name: Upload NSIS Setup (x86) | |
uses: actions/upload-artifact@v4 | |
with: | |
name: nsis-x86-setup | |
path: .instdist-ubuntu-x86/nsis*-x86.exe | |
include-hidden-files: true # https://github.com/actions/upload-artifact/issues/618 | |
- name: Upload NSIS Setup (amd64) | |
uses: actions/upload-artifact@v4 | |
with: | |
name: nsis-amd64-setup | |
path: .instdist-ubuntu-amd64/nsis*-amd64.exe | |
include-hidden-files: true # https://github.com/actions/upload-artifact/issues/618 | |
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= | |
release: | |
name: Release Draft | |
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/github/') | |
needs: [build, package] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download NSIS | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
pattern: nsis-*-setup | |
merge-multiple: true | |
- name: Prepare release notes | |
shell: python | |
run: | | |
lines = [] | |
with open(".github/workflows/release-body.md") as fin: | |
line = fin.read() | |
line = line.replace('{version-gcc}', 'todo') | |
line = line.replace('{url-workflow}', 'https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}') | |
lines.append(line) | |
with open(".github/workflows/release-body.md", "w") as fout: | |
for line in lines: | |
fout.write(line) | |
- name: Create GitHub release draft | |
uses: ncipollo/release-action@v1 | |
with: | |
# note: `tag` is the release key | |
tag: release-candidate | |
name: v${{needs.build.outputs.version_full}} | |
artifacts: artifacts/*.exe | |
bodyFile: .github/workflows/release-body.md | |
draft: true | |
makeLatest: true | |
allowUpdates: true | |
updateOnlyUnreleased: true | |
artifactErrorsFailBuild: true | |
removeArtifacts: true |