Skip to content

Commit

Permalink
Merge pull request #2 from theavege/add/github-actions
Browse files Browse the repository at this point in the history
add github-actions
  • Loading branch information
mozturkgss authored Nov 18, 2024
2 parents 9a06e48 + 089e67c commit d98655f
Show file tree
Hide file tree
Showing 13 changed files with 389 additions and 153 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
39 changes: 39 additions & 0 deletions .github/workflows/make.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: Make

on:
push:
branches:
- "**"
pull_request:
branches:
- master

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ${{ matrix.os }}
timeout-minutes: 120
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

- name: Build on Linux
if: runner.os == 'Linux'
shell: bash
run: bash -x make.sh build

- name: Build on Windows
if: runner.os == 'Windows'
shell: powershell
run: pwsh -File make.ps1 build
94 changes: 0 additions & 94 deletions MultiPdfSmaller.lpi

This file was deleted.

90 changes: 90 additions & 0 deletions make.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/usr/bin/env pwsh
##############################################################################################################

Function Show-Usage {
Return "
Usage: pwsh -File $($PSCommandPath) [OPTIONS]
Options:
build Build program
"
}

Function Request-File {
ForEach ($REPLY in $args) {
$params = @{
Uri = $REPLY
OutFile = (Split-Path -Path $REPLY -Leaf).Split('?')[0]
}
Invoke-WebRequest @params | Out-Null
Return $params.OutFile
}
}

Function Install-Program {
While ($Input.MoveNext()) {
Switch ((Split-Path -Path $Input.Current -Leaf).Split('.')[-1]) {
'msi' {
& msiexec /passive /package $Input.Current | Out-Host
}
'exe' {
& ".\$($Input.Current)" /SP- /VERYSILENT /SUPPRESSMSGBOXES /NORESTART | Out-Host
}
}
Remove-Item $Input.Current
}
}

Function Build-Project {
$VAR = @{
Cmd = 'lazbuild'
Url = 'https://netix.dl.sourceforge.net/project/lazarus/Lazarus%20Windows%2064%20bits/Lazarus%203.6/lazarus-3.6-fpc-3.2.2-win64.exe?viasf=1'
Path = "C:\Lazarus"
}
Try {
Get-Command $VAR.Cmd
} Catch {
Request-File $VAR.Url | Install-Program
$env:PATH+=";$($VAR.Path)"
Get-Command $VAR.Cmd
}
If ( Test-Path -Path 'use\components.txt' ) {
& git submodule update --recursive --init | Out-Host
& git submodule update --recursive --remote | Out-Host
Get-Content -Path 'use\components.txt' | ForEach-Object {
If ((-not (& lazbuild --verbose-pkgsearch $_ | Out-Null)) -and
(-not (& lazbuild --add-package $_ | Out-Null)) -and
(-not (Test-Path -Path 'use\components.txt'))) {
$OutFile = Request-File "https://packages.lazarus-ide.org/$($_).zip"
Expand-Archive -Path $OutFile -DestinationPath "use\$($_)" -Force
Remove-Item $OutFile
}
}
Get-ChildItem -Filter '*.lpk' -Recurse -File –Path 'use' | ForEach-Object {
& lazbuild --add-package-link $_ | Out-Host
}
}
Get-ChildItem -Filter '*.lpi' -Recurse -File –Path 'src' | ForEach-Object {
& lazbuild --no-write-project --recursive --build-mode=release $_ | Out-Host
}
}

Function Switch-Action {
$ErrorActionPreference = 'stop'
Set-PSDebug -Strict -Trace 1
Invoke-ScriptAnalyzer -EnableExit -Path $PSCommandPath
If ($args.count -gt 0) {
Switch ($args[0]) {
'build' {
Build-Project
}
Default {
Show-Usage
}
}
} Else {
Show-Usage
}
}

##############################################################################################################
Switch-Action @args | Out-Null
59 changes: 59 additions & 0 deletions make.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env bash

function priv_clippit
(
cat <<EOF
Usage: bash ${0} [OPTIONS]
Options:
build Build program
EOF
)

function priv_lazbuild
(
if ! (which lazbuild); then
source '/etc/os-release'
case ${ID:?} in
debian | ubuntu)
sudo apt-get update
sudo apt-get install -y lazarus
;;
esac
fi
if [[ -f 'use/components.txt' ]]; then
git submodule update --init --recursive
git submodule update --recursive --remote
while read -r; do
if [[ -n "${REPLY}" ]] &&
! (lazbuild --verbose-pkgsearch "${REPLY}") &&
! (lazbuild --add-package "${REPLY}") &&
! [[ -f "use/${REPLY}" ]]; then
declare -A VAR=(
[url]="https://packages.lazarus-ide.org/${REPLY}.zip"
[out]=$(mktemp)
)
wget --output-document "${VAR[out]}" "${VAR[url]}" >/dev/null
unzip -o "${VAR[out]}" -d "use/${REPLY}"
rm --verbose "${VAR[out]}"
fi
done < 'use/components.txt'
find 'use' -type 'f' -name '*.lpk' -exec lazbuild --add-package-link {} +
fi
find 'src' -type 'f' -name '*.lpi' \
-exec lazbuild --no-write-project --recursive --no-write-project --build-mode=release {} + 1>&2
)

function priv_main
(
set -euo pipefail
if ((${#})); then
case ${1} in
build) priv_lazbuild ;;
*) priv_clippit ;;
esac
else
priv_clippit
fi
)

priv_main "${@}" >/dev/null
File renamed without changes.
Loading

0 comments on commit d98655f

Please sign in to comment.