Skip to content

Commit f916756

Browse files
committed
Automate release builds
1 parent b7ea8a5 commit f916756

6 files changed

Lines changed: 166 additions & 12 deletions

File tree

.circleci/config.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
version: 2.1
2+
#
3+
# Copyright (c) 2023 Robert Di Pardo <dipardo.r@gmail.com>
4+
#
5+
# This Source Code Form is subject to the terms of the Mozilla Public
6+
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
7+
# You can obtain one at https://mozilla.org/MPL/2.0/.
8+
#
9+
orbs:
10+
lazarus: rdipardo/lazarus@2
11+
win: circleci/windows@5
12+
13+
references:
14+
executor: &executor
15+
executor:
16+
name: win/default
17+
shell: bash.exe
18+
development: &development
19+
filters:
20+
tags:
21+
only: /v.*/
22+
production: &production
23+
filters:
24+
branches:
25+
ignore: /.*/
26+
tags:
27+
only: /v.*/
28+
29+
jobs:
30+
build:
31+
<<: *executor
32+
environment:
33+
UPX_VER: 4.0.2
34+
steps:
35+
- checkout
36+
- run:
37+
name: Clone submodules
38+
command: |
39+
git reset --hard
40+
git submodule sync --recursive
41+
git submodule update -f --init --remote --checkout --recursive
42+
- run:
43+
name: Install UPX
44+
command: |
45+
curl -sLO "https://github.com/upx/upx/releases/download/v$UPX_VER/upx-$UPX_VER-win64.zip"
46+
7z e upx-$UPX_VER-win64.zip -o"$WINDIR"
47+
upx.exe --version
48+
- lazarus/install:
49+
win32: true
50+
- run:
51+
name: Build and Pack
52+
command: make_release.cmd
53+
shell: cmd.exe
54+
- persist_to_workspace:
55+
root: .
56+
paths: out
57+
58+
push-release:
59+
<<: *executor
60+
parameters:
61+
plugin-name:
62+
type: string
63+
default: HTMLTag
64+
65+
steps:
66+
- checkout
67+
- attach_workspace:
68+
at: .
69+
- store_artifacts:
70+
name: Upload << parameters.plugin-name >>_<< pipeline.git.tag >>.zip
71+
path: out/<< parameters.plugin-name >>_<< pipeline.git.tag >>.zip
72+
destination: << parameters.plugin-name >>_<< pipeline.git.tag >>.zip
73+
- store_artifacts:
74+
name: Upload << parameters.plugin-name >>_<< pipeline.git.tag >>_x64.zip
75+
path: out/<< parameters.plugin-name >>_<< pipeline.git.tag >>_x64.zip
76+
destination: << parameters.plugin-name >>_<< pipeline.git.tag >>_x64.zip
77+
- run:
78+
name: Create GitHub Release
79+
command: bash.exe .circleci/scripts/gh_release.sh
80+
environment:
81+
SLUGX86: << parameters.plugin-name >>_<< pipeline.git.tag >>.zip
82+
SLUGX64: << parameters.plugin-name >>_<< pipeline.git.tag >>_x64.zip
83+
BIN_DIR: out
84+
85+
workflows:
86+
lazarus-build:
87+
jobs:
88+
- build:
89+
<<: *development
90+
- push-release:
91+
<<: *production
92+
requires: [build]

.circleci/scripts/gh_release.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/bash
2+
#
3+
# Copyright (c) 2022 Robert Di Pardo
4+
# License: https://github.com/rdipardo/nppFSIPlugin/blob/master/Copyright.txt
5+
#
6+
COMMIT=$(git rev-parse ${CIRCLE_TAG}) \
7+
&& TMP=$(git branch -a --contains $COMMIT) \
8+
&& BRANCH="${TMP##*/}"
9+
10+
cd "$BIN_DIR" || exit 0
11+
printf '#### SHA256 Checksums\\n\\n' > sha256sums.md
12+
printf '\\t%s\\n' "$(sha256sum ${SLUGX86})" >> sha256sums.md
13+
printf '\\t%s\\n' "$(sha256sum ${SLUGX64})" >> sha256sums.md
14+
curl -sL -X POST \
15+
-H "Accept: application/vnd.github+json" \
16+
-H "Authorization: Bearer ${GH_API_TOKEN}" \
17+
"https://api.github.com/repos/${CIRCLE_USERNAME}/${CIRCLE_PROJECT_REPONAME}/releases" \
18+
-d "{\"tag_name\":\"${CIRCLE_TAG}\",
19+
\"target_commitish\":\"${BRANCH}\",
20+
\"name\":\"${CIRCLE_TAG}\",
21+
\"body\":\"$(cat sha256sums.md)\",
22+
\"draft\":true,
23+
\"prerelease\":false,
24+
\"generate_release_notes\":false}"

build.cmd

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
@echo off
2+
::
3+
:: Copyright (c) 2023 Robert Di Pardo <dipardo.r@gmail.com>
4+
::
5+
:: This Source Code Form is subject to the terms of the Mozilla Public
6+
:: License, v. 2.0. If a copy of the MPL was not distributed with this file,
7+
:: You can obtain one at https://mozilla.org/MPL/2.0/.
8+
::
9+
SETLOCAL
10+
11+
set "FPC_BUILD_TYPE=Debug"
12+
set "FPC_CPU=x86_64"
13+
14+
if "%1" NEQ "" ( set "FPC_BUILD_TYPE=%1" )
15+
if "%2" NEQ "" ( set "FPC_CPU=%2" )
16+
call :%FPC_BUILD_TYPE% 2>NUL:
17+
if %errorlevel%==1 ( goto :USAGE )
18+
19+
:Release
20+
del /S /Q /F out\*.zip 2>NUL:
21+
:Debug
22+
23+
call %~dp0src\Forms\suppress_ole_init.cmd
24+
if %errorlevel%==2 (
25+
echo Patch failed
26+
goto :END
27+
)
28+
29+
set "BUILD_ALL="
30+
if "%3"=="clean" (
31+
rmdir /S /Q out 2>NUL:
32+
set "BUILD_ALL=-B"
33+
)
34+
35+
lazbuild %BUILD_ALL% --bm=%FPC_BUILD_TYPE% --cpu=%FPC_CPU% src\prj\HTMLTag.lpi
36+
goto :END
37+
38+
:USAGE
39+
echo Usage: ".\%~n0 [Debug,Release] [i386,x86_64] [clean]"
40+
41+
:END
42+
exit /B %errorlevel%
43+
44+
ENDLOCAL

make_release.cmd

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,17 @@ set "SLUGX64_SRC=out\%PLUGIN%_v%VERSION%_x64"
1818
set "SLUG=%SLUG_SRC%.zip"
1919
set "SLUGX64=%SLUGX64_SRC%.zip"
2020

21-
del /S /Q /F out\*.zip 2>NUL
22-
rmdir /S /Q out\obj out\i386-win32\Release out\x86_64-win64\Release 2>NUL
23-
call %~dp0src\Forms\suppress_ole_init.cmd
21+
call %~dp0build.cmd Release i386 clean
2422
if %errorlevel% NEQ 0 (
25-
echo Patch failed
2623
exit /B %errorlevel%
2724
)
28-
lazbuild -B --bm=Release --cpu=i386 src\prj\HTMLTag.lpi
29-
lazbuild -B --bm=Release --cpu=x86_64 src\prj\HTMLTag.lpi
25+
call %~dp0build.cmd Release x86_64
3026
xcopy /DIY *.textile "out\Doc"
3127

3228
:: https://fossil.2of4.net/npp_htmltag/doc/trunk/doc/HTMLTag-readme.txt
3329
echo F | xcopy /DV ".\%PLUGIN_DLL%" ".\%PLUGIN_LEGACY_DLL%"
30+
upx.exe --best -q ".\%PLUGIN_LEGACY_DLL%"
31+
upx.exe --best -q ".\%PLUGINX64_DLL%"
3432
7z a -tzip "%SLUG%" ".\%PLUGIN_LEGACY_DLL%" ".\dat\*entities*" ".\out\Doc" -y
3533
7z a -tzip "%SLUGX64%" ".\%PLUGINX64_DLL%" ".\dat\*entities*" ".\out\Doc" -y
3634

src/Forms/suppress_ole_init.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ SETLOCAL
33
set EXIT_CODE=0
44
pushd %~dp0fpg
55
git apply -v "%~dp0patches\no_drag_and_drop.diff" 2>NUL
6-
git grep -niE "Ole(Un|)Initialize" -- src/corelib/gdi 2>NUL
6+
git grep -niE "Ole(Un|)Initialize" -- src/corelib/gdi 2,1>NUL
77
popd
88
if %ERRORLEVEL%==0 (SET EXIT_CODE=2)
99
exit /B %EXIT_CODE%

src/prj/HTMLTag.lpi

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,9 @@
7272
-dSCI_DISABLE_PROVISIONAL
7373
-FcUTF8
7474
-vm2026,4104,5024"/>
75-
<OtherDefines Count="2">
75+
<OtherDefines Count="1">
7676
<Define0 Value="UNICODE"/>
7777
</OtherDefines>
78-
<ExecuteAfter>
79-
<Command Value="&quot;C:\Users\Rob\scoop\apps\upx\current\upx.exe&quot; --best -q &quot;$TargetFile()&quot;"/>
80-
<CompileReasons Compile="False" Run="False"/>
81-
</ExecuteAfter>
8278
</Other>
8379
</CompilerOptions>
8480
</Item2>

0 commit comments

Comments
 (0)