Skip to content

Commit da1835f

Browse files
committed
build: Add automated packaging workflow for distribution releases
Add 'package' target to Makefile for creating versioned zip archives with HTML documentation (pandoc) and update Inno Setup installer for Windows. Reads version from environment and prepares for GitHub Actions automation.
1 parent 9fd2021 commit da1835f

5 files changed

Lines changed: 106 additions & 17 deletions

File tree

Makefile

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# sqlcw: SQL Code Wrapper - Build Configuration
22

33
# Directory structure
4-
BUILD_DIR := build
5-
SRC_DIR := src
6-
OBJ_DIR = $(BUILD_DIR)/obj
4+
BUILD_DIR := $(CURDIR)/build
5+
SRC_DIR := $(CURDIR)/src
6+
OBJ_DIR := $(BUILD_DIR)/obj
77
BUILD_INFO_FILE := $(BUILD_DIR)/build_info.h
8+
PACKAGE_DIR := $(BUILD_DIR)/package
89

910
# Discover all C++ source files in the source directory
1011
SOURCE_FILES := $(wildcard $(SRC_DIR)/*.cpp)
@@ -36,11 +37,13 @@ BUILD_VERSION_STR := $(if $(and $(ENV_BUILD_VERSION_MAJOR),$(ENV_BUILD_VERSION_M
3637
# Platform-specific configuration
3738
ifdef MSYSTEM
3839
# Building on Windows (MSYS2/MinGW)
40+
PLATFORM := win64
3941
TARGET := $(BUILD_DIR)/sqlcw.exe
4042
# Boost libraries on Windows use -mt suffix (multi-threaded)
4143
LIBS := $(addsuffix -mt, $(addprefix -l,$(BOOST_LIBS)))
4244
else
4345
# Building on Linux/Unix
46+
PLATFORM := linux_$(shell uname -m)
4447
TARGET := $(BUILD_DIR)/sqlcw
4548
LIBS := $(addprefix -l,$(BOOST_LIBS))
4649
endif
@@ -94,9 +97,22 @@ else
9497
WINDRES_OBJECT_FILE :=
9598
endif
9699

97-
# Placeholder for packaging step (e.g., creating zip/tarball)
100+
# Package application executable and documentation for distribution
98101
package: $(TARGET)
99-
@echo "Generating package..."
102+
@echo "Generating documentation and creating distribution packages..."
103+
BUILD_VERSION=$(BUILD_VERSION_STR) pandoc README.md -o $(BUILD_DIR)/README.html --embed-resources --standalone --lua-filter=scripts/pandoc-link-rewriter.lua
104+
BUILD_VERSION=$(BUILD_VERSION_STR) pandoc LICENSE.md -o $(BUILD_DIR)/LICENSE.html --embed-resources --standalone --lua-filter=scripts/pandoc-link-rewriter.lua
105+
106+
mkdir -p $(PACKAGE_DIR)/bin
107+
cp $(TARGET) $(PACKAGE_DIR)/bin
108+
cp $(BUILD_DIR)/README.html $(BUILD_DIR)/LICENSE.html -t $(PACKAGE_DIR)
109+
cp -r doc/library-licenses doc/examples -t $(PACKAGE_DIR)
110+
cd $(PACKAGE_DIR) && zip -r $(BUILD_DIR)/sqlcw-$(BUILD_VERSION_STR)-$(PLATFORM).zip .
111+
rm -rf $(PACKAGE_DIR)
112+
113+
ifeq ($(OS),Windows_NT)
114+
iscc -Obuild -Q installer/sqlcw_installer.iss
115+
endif
100116

101117
# Remove all generated files
102118
clean:

doc/LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019-2025 peter277 - https://github.com/peter277
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

installer/sqlcw_installer.iss

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
#define MyAppName "sqlcw"
2-
#define MyAppVersion "1.1"
3-
#define MyAppURL "https://sourceforge.net/projects/sqlcw/"
2+
#define MyAppURL "https://github.com/peter277/sqlcw"
43
#define MyAppExeName "sqlcw.exe"
5-
#define ProjectDir "X:\Projects\sqlcw"
4+
#define ProjectDir ExtractFileDir(ExtractFileDir(SourcePath))
5+
6+
#define VerMajor GetEnv("ENV_BUILD_VERSION_MAJOR")
7+
#define VerMinor GetEnv("ENV_BUILD_VERSION_MINOR")
8+
#define VerPatch GetEnv("ENV_BUILD_VERSION_PATCH") != "" ? GetEnv("ENV_BUILD_VERSION_PATCH") : "0"
9+
10+
#if VerMajor != "" && VerMinor != ""
11+
#define MyAppVersion VerMajor + "." + VerMinor + "." + VerPatch
12+
#else
13+
#define MyAppVersion "dev"
14+
#endif
615

716
[Setup]
817
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
@@ -11,13 +20,14 @@ AppId={{0D0F4C50-15D5-4CDF-A7C7-316375B5359A}
1120
AppName={#MyAppName}
1221
AppVersion={#MyAppVersion}
1322
AppVerName={#MyAppName} {#MyAppVersion}
23+
;AppPublisher={#MyAppPublisher}
1424
AppPublisherURL={#MyAppURL}
1525
AppSupportURL={#MyAppURL}
1626
AppUpdatesURL={#MyAppURL}
1727
DefaultDirName={autopf}\{#MyAppName}
1828
DefaultGroupName={#MyAppName}
1929
AllowNoIcons=yes
20-
LicenseFile={#ProjectDir}\doc\LICENSE_GPL-3.0.txt
30+
LicenseFile={#ProjectDir}\doc\LICENSE.txt
2131
; Remove the following line to run in administrative install mode (install for all users.)
2232
PrivilegesRequired=lowest
2333
PrivilegesRequiredOverridesAllowed=dialog commandline
@@ -27,13 +37,13 @@ SolidCompression=yes
2737
WizardStyle=modern
2838
ChangesEnvironment=true
2939

30-
; "ArchitecturesAllowed=x64" specifies that Setup cannot run on
40+
; "ArchitecturesAllowed=x64compatible" specifies that Setup cannot run on
3141
; anything but x64.
32-
ArchitecturesAllowed=x64
33-
; "ArchitecturesInstallIn64BitMode=x64" requests that the install be
42+
ArchitecturesAllowed=x64compatible
43+
; "ArchitecturesInstallIn64BitMode=x64compatible" requests that the install be
3444
; done in "64-bit mode" on x64, meaning it should use the native
3545
; 64-bit Program Files directory and the 64-bit view of the registry.
36-
ArchitecturesInstallIn64BitMode=x64
46+
ArchitecturesInstallIn64BitMode=x64compatible
3747

3848
; Specify a particular icon file to display for the Uninstall entry in the Add/Remove Programs Control Panel applet
3949
UninstallDisplayIcon={app}\bin\{#MyAppExeName}
@@ -42,17 +52,20 @@ UninstallDisplayIcon={app}\bin\{#MyAppExeName}
4252
Name: "english"; MessagesFile: "compiler:Default.isl"
4353

4454
[Files]
45-
Source: "{#ProjectDir}\bin\Release\sqlcw.exe"; DestDir: "{app}\bin"; Flags: ignoreversion
46-
Source: "{#ProjectDir}\doc\README.txt"; DestDir: "{app}"; Flags: ignoreversion
55+
Source: "{#ProjectDir}\build\sqlcw.exe"; DestDir: "{app}\bin"; Flags: ignoreversion
56+
Source: "{#ProjectDir}\build\README.html"; DestDir: "{app}"; Flags: ignoreversion
57+
Source: "{#ProjectDir}\build\LICENSE.html"; DestDir: "{app}"; Flags: ignoreversion
4758
Source: "{#ProjectDir}\doc\examples\*"; DestDir: "{app}\examples"; Flags: ignoreversion recursesubdirs createallsubdirs
59+
Source: "{#ProjectDir}\doc\library-licenses\*"; DestDir: "{app}\library-licenses"; Flags: ignoreversion recursesubdirs createallsubdirs
4860
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
4961

5062
[Icons]
5163
;Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
5264
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
5365
Name: "{group}\Examples"; Filename: "{app}\examples"
5466
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
55-
Name: "{group}\{#MyAppName} Readme"; Filename: "{app}\README.txt"
67+
Name: "{group}\{#MyAppName} Readme"; Filename: "{app}\README.html"
68+
Name: "{group}\{#MyAppName} License"; Filename: "{app}\LICENSE.html"
5669

5770
[Tasks]
5871
Name: modifypath; Description: &Add application executable to environmental path

scripts/pandoc-link-rewriter.lua

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
--[[
2+
Pandoc filter to rewrite relative links to versioned GitHub URLs.
3+
4+
Reads BUILD_VERSION from environment:
5+
- Set to version number: links to /blob/v{version}/
6+
- Set to "dev" or unset: links to /blob/main/
7+
8+
Usage example: pandoc input.md -o out.html --lua-filter=scripts/pandoc-link-rewriter.lua
9+
--]]
10+
11+
-- Read version from environment, fallback to 'main'
12+
local version = os.getenv("BUILD_VERSION") or os.getenv("BUILD_VERSION_STR")
13+
local base_url
14+
15+
-- Use main branch if no version, or if version is 'dev'
16+
if version and version ~= "dev" then
17+
-- Use tag URL: /blob/v1.1.1/
18+
io.stderr:write("Using version tag: v" .. version .. "\n")
19+
base_url = "https://github.com/peter277/sqlcw/blob/v" .. version .. "/"
20+
else
21+
-- Fallback to main branch (no version or dev build)
22+
if version == "dev" then
23+
io.stderr:write("Development build detected, using main branch\n")
24+
else
25+
io.stderr:write("No version found, using main branch\n")
26+
end
27+
base_url = "https://github.com/peter277/sqlcw/blob/main/"
28+
end
29+
30+
function Link(el)
31+
-- Only rewrite relative links (not absolute URLs or anchors)
32+
if not el.target:match("^https?://") and
33+
not el.target:match("^#") and
34+
not el.target:match("^mailto:")
35+
then
36+
el.target = base_url .. el.target
37+
end
38+
return el
39+
end

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ int main(int argc, char **argv)
8080
cout << "SQLCW - SQL CODE WRAPPER, VERSION " << BUILD_VERSION_STR << endl
8181
<< "Build Date : " << BUILD_DATE << endl
8282
<< "Build Compiler : " << BUILD_COMPILER << endl
83-
<< "Website : http://sqlcw.sourceforge.net/" << endl
83+
<< "Website : https://github.com/peter277/sqlcw" << endl
8484
<< "License : MIT" << endl
8585
;
8686
return 0;

0 commit comments

Comments
 (0)