Skip to content

Commit 7266891

Browse files
committed
Implement versioning and build enhancements with cross-platform support
1 parent 8ba48d2 commit 7266891

File tree

7 files changed

+980
-8
lines changed

7 files changed

+980
-8
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ jobs:
1212
test:
1313
name: Test
1414
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
1517
strategy:
1618
matrix:
1719
go: [1.21.x, 1.22.x, 1.23.x, 1.24.x]
@@ -105,18 +107,26 @@ jobs:
105107

106108
- name: Build binaries
107109
run: |
108-
# Build for different platforms
109-
OS = ["darwin", "freebsd", "linux", "windows"]
110-
ARCH = ["amd64", "arm64"]
111-
112-
for os in OS:
113-
for arch in ARCH:
114-
GOOS=$os GOARCH=$arch go build -o articulate-parser-$os-$arch main.go
110+
chmod +x ./scripts/build.sh
111+
112+
# OPTIONS:
113+
# -h, --help Show this help message and exit
114+
# -j <number> Number of parallel jobs (default: 4)
115+
# -o <directory> Output directory for binaries (default: build)
116+
# -e <file> Entry point Go file (default: main.go)
117+
# -v, --verbose Enable verbose output for debugging
118+
# --show-targets Show available Go build targets and exit
119+
./scripts/build.sh \
120+
--verbose \
121+
-j 8 \
122+
-o build \
123+
-e main.go \
124+
-ldflags '-s -w -X github.com/kjanat/articulate-parser/internal/version.Version=${{ github.ref_name }} -X github.com/kjanat/articulate-parser/internal/version.BuildTime=$(date -u +%Y-%m-%dT%H:%M:%SZ) -X github.com/kjanat/articulate-parser/internal/version.GitCommit=${{ github.sha }}'
115125
116126
- name: Create Release
117127
uses: softprops/action-gh-release@v2
118128
with:
119-
files: articulate-parser-*
129+
files: build/*
120130
generate_release_notes: true
121131
draft: false
122132
prerelease: ${{ startsWith(github.ref, 'refs/tags/v0.') }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,7 @@ go.work
3030
output/
3131
articulate-sample.json
3232
test-output.*
33+
go-os-arch-matrix.csv
34+
35+
# Build artifacts
36+
build/

internal/version/version.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Package version provides version information for the Articulate Parser.
2+
// It includes the current version, build time, and Git commit hash.
3+
package version
4+
5+
// Version information.
6+
var (
7+
// Version is the current version of the application.
8+
Version = "0.1.0"
9+
10+
// BuildTime is the time the binary was built.
11+
BuildTime = "unknown"
12+
13+
// GitCommit is the git commit hash.
14+
GitCommit = "unknown"
15+
)

main.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import (
1414
"time"
1515

1616
"github.com/unidoc/unioffice/document"
17+
18+
"github.com/kjanat/articulate-parser/internal/version"
19+
1720
)
1821

1922
// Core data structures based on the Articulate Rise JSON format
@@ -547,8 +550,17 @@ func (p *ArticulateParser) processItemToDocx(doc *document.Document, item Item)
547550
}
548551

549552
func main() {
553+
// Handle version flag
554+
if len(os.Args) > 1 && (os.Args[1] == "-v" || os.Args[1] == "--version") {
555+
fmt.Printf("articulate-parser %s\n", version.Version)
556+
fmt.Printf("Build time: %s\n", version.BuildTime)
557+
fmt.Printf("Commit: %s\n", version.GitCommit)
558+
os.Exit(0)
559+
}
560+
550561
if len(os.Args) < 3 {
551562
fmt.Println("Usage: articulate-parser <input_uri_or_file> <output_format> [output_path]")
563+
fmt.Println(" articulate-parser -v|--version")
552564
fmt.Println(" input_uri_or_file: Articulate Rise URI or local JSON file path")
553565
fmt.Println(" output_format: md (Markdown) or docx (Word Document)")
554566
fmt.Println(" output_path: Optional output file path")

scripts/_build_tools_available.ps1

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
param(
2+
[switch]$AsCheckmark
3+
)
4+
5+
# Get the list from 'go tool dist list'
6+
$dists = & go tool dist list
7+
8+
# Parse into OS/ARCH pairs
9+
$parsed = $dists | ForEach-Object {
10+
$split = $_ -split '/'
11+
[PSCustomObject]@{ OS = $split[0]; ARCH = $split[1] }
12+
}
13+
14+
# Find all unique OSes and arches, sorted
15+
$oses = $parsed | Select-Object -ExpandProperty OS -Unique | Sort-Object
16+
$arches = $parsed | Select-Object -ExpandProperty ARCH -Unique | Sort-Object
17+
18+
# Group by OS, and build custom objects
19+
$results = foreach ($os in $oses) {
20+
$props = @{}
21+
$props.OS = $os
22+
foreach ($arch in $arches) {
23+
$hasArch = $parsed | Where-Object { $_.OS -eq $os -and $_.ARCH -eq $arch }
24+
if ($hasArch) {
25+
if ($AsCheckmark) {
26+
$props[$arch] = ''
27+
} else {
28+
$props[$arch] = $true
29+
}
30+
} else {
31+
$props[$arch] = $false
32+
}
33+
}
34+
[PSCustomObject]$props
35+
}
36+
37+
# Output
38+
$results | Format-Table -AutoSize

0 commit comments

Comments
 (0)