Skip to content

Implement versioning and build enhancements with cross-platform support #28

Implement versioning and build enhancements with cross-platform support

Implement versioning and build enhancements with cross-platform support #28

Workflow file for this run

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: Build binaries
run: |
chmod +x ./scripts/build.sh
# OPTIONS:
# -h, --help Show this help message and exit
# -j <number> Number of parallel jobs (default: 4)
# -o <directory> Output directory for binaries (default: build)
# -e <file> Entry point Go file (default: main.go)
# -v, --verbose Enable verbose output for debugging
# --show-targets Show available Go build targets and exit
./scripts/build.sh \
--verbose \
-j 8 \
-o build \
-e main.go \
-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 }}'
- 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 }}