Files
articulate-parser/.github/workflows/ci.yml
Kaj Kowalski 9de7222ec3 Adds DOCX and Markdown export functionality
Introduces a modular exporter pattern supporting DOCX and Markdown formats
by implementing Exporter interfaces and restructuring application logic.

Enhances CI to install UPX for binary compression, excluding recent macOS
binaries due to compatibility issues.

Enables CGO when building binaries for all platforms, addressing potential
cross-platform compatibility concerns.

Bumps version to 0.1.1.
2025-05-25 13:03:21 +02:00

177 lines
4.9 KiB
YAML

name: CI
on:
push:
branches: [ "master", "develop" ]
tags:
- "v*.*.*"
pull_request:
branches: [ "master", "develop" ]
jobs:
test:
name: Test
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
matrix:
go: [1.21.x, 1.22.x, 1.23.x, 1.24.x]
steps:
- uses: actions/checkout@v4
- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
check-latest: true
cache-dependency-path: "**/*.sum"
- name: Download dependencies
run: go mod download && echo "Download successful" || go mod tidy && echo "Tidy successful" || return 1
- name: Verify dependencies
run: go mod verify
- name: Build
run: go build -v ./...
- name: Run tests
run: go test -v -race -coverprofile=coverage.out ./...
- name: Run go vet
run: go vet ./...
- name: Run go fmt
run: |
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
echo "The following files are not formatted:"
gofmt -s -l .
exit 1
fi
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
flags: Go ${{ matrix.go }}
slug: kjanat/articulate-parser
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
flags: Go ${{ matrix.go }}
token: ${{ secrets.CODECOV_TOKEN }}
dependency-review:
name: Dependency Review
runs-on: ubuntu-latest
permissions:
contents: read
if: github.event_name == 'pull_request'
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v4
- name: 'Dependency Review'
uses: actions/dependency-review-action@v4
with:
fail-on-severity: moderate
comment-summary-in-pr: always
# # Use comma-separated names to pass list arguments:
# deny-licenses: LGPL-2.0, BSD-2-Clause
release:
name: Release
runs-on: ubuntu-latest
if: github.ref_type == 'tag'
permissions:
contents: write
needs: [ "test" ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
check-latest: true
- name: Run tests
run: go test -v ./...
- name: Install UPX
run: |
sudo apt-get update
sudo apt-get install -y upx
- name: Build binaries
run: |
# Set the build time environment variable
BUILD_TIME=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
# Add run permissions to the build script
chmod +x ./scripts/build.sh
# Display help information for the build script
./scripts/build.sh --help
# Build for all platforms
./scripts/build.sh \
--verbose \
-ldflags "-s -w -X github.com/kjanat/articulate-parser/internal/version.Version=${{ github.ref_name }} -X github.com/kjanat/articulate-parser/internal/version.BuildTime=$BUILD_TIME -X github.com/kjanat/articulate-parser/internal/version.GitCommit=${{ github.sha }}"
- name: Compress binaries with UPX
run: |
echo "Compressing binaries with UPX..."
cd build/
# Get original sizes
echo "Original sizes:"
ls -lah
echo ""
# Compress all binaries except Darwin (macOS) binaries as UPX doesn't work well with recent macOS versions
for binary in articulate-parser-*; do
if [[ "$binary" == *"darwin"* ]]; then
echo "Skipping UPX compression for $binary (macOS compatibility)"
else
echo "Compressing $binary..."
upx --best --lzma "$binary" || {
echo "Warning: UPX compression failed for $binary, keeping original"
}
fi
done
echo ""
echo "Final sizes:"
ls -lah
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4.6.2
with:
# Artifact name
name: build-artifacts # optional, default is artifact
# A file, directory or wildcard pattern that describes what to upload
path: build/
if-no-files-found: ignore
retention-days: 1
compression-level: 9
overwrite: true
include-hidden-files: true
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: build/*
generate_release_notes: true
draft: false
prerelease: ${{ startsWith(github.ref, 'refs/tags/v0.') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}