mirror of
https://github.com/kjanat/articulate-parser.git
synced 2026-01-16 16:22:09 +01:00
Change how BUILD_TIME is derived Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
157 lines
5.4 KiB
YAML
157 lines
5.4 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*.*.*'
|
|
workflow_call:
|
|
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
IMAGE_NAME: ${{ github.repository }}
|
|
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
|
|
jobs:
|
|
release:
|
|
name: Create Release
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
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 using git commit timestamp
|
|
BUILD_TIME=$(git log -1 --format=%cd --date=iso-strict)
|
|
|
|
# Add run permissions to the build script
|
|
chmod +x ./scripts/build.sh
|
|
|
|
# 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
|
|
run: |
|
|
cd build/
|
|
for binary in articulate-parser-*; do
|
|
echo "Compressing $binary..."
|
|
upx --best "$binary" || {
|
|
echo "Warning: UPX compression failed for $binary, keeping original"
|
|
}
|
|
done
|
|
|
|
- name: Create Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
files: |
|
|
build/articulate-parser-linux-amd64
|
|
build/articulate-parser-linux-arm64
|
|
build/articulate-parser-windows-amd64.exe
|
|
build/articulate-parser-windows-arm64.exe
|
|
build/articulate-parser-darwin-amd64
|
|
build/articulate-parser-darwin-arm64
|
|
generate_release_notes: true
|
|
draft: false
|
|
# Mark pre-1.0 versions (v0.x.x) as prerelease since they are considered unstable
|
|
# This helps users understand that these releases may have breaking changes
|
|
prerelease: ${{ startsWith(github.ref, 'refs/tags/v0.') }}
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
docker:
|
|
name: Docker Build & Push
|
|
runs-on: ubuntu-latest
|
|
needs: ['release']
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ vars.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Log in to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: |
|
|
${{ env.IMAGE_NAME }}
|
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
tags: |
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=semver,pattern={{major}}
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
labels: |
|
|
org.opencontainers.image.title=Articulate Parser
|
|
org.opencontainers.image.description=A powerful CLI tool to parse Articulate Rise courses and export them to multiple formats including Markdown HTML and DOCX. Supports media extraction content cleaning and batch processing for educational content conversion.
|
|
org.opencontainers.image.vendor=kjanat
|
|
org.opencontainers.image.licenses=MIT
|
|
org.opencontainers.image.url=https://github.com/${{ github.repository }}
|
|
org.opencontainers.image.source=https://github.com/${{ github.repository }}
|
|
org.opencontainers.image.documentation=https://github.com/${{ github.repository }}/blob/master/DOCKER.md
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
platforms: |
|
|
linux/amd64
|
|
linux/arm64
|
|
linux/arm/v7
|
|
linux/386
|
|
linux/ppc64le
|
|
linux/s390x
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
annotations: ${{ steps.meta.outputs.labels }}
|
|
build-args: |
|
|
VERSION=${{ github.ref_name }}
|
|
BUILD_TIME=${{ github.event.head_commit.timestamp || github.event.repository.pushed_at }}
|
|
GIT_COMMIT=${{ github.sha }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=A powerful CLI tool to parse Articulate Rise courses and export them to multiple formats including Markdown HTML and DOCX. Supports media extraction content cleaning and batch processing for educational content conversion.
|
|
sbom: true
|
|
provenance: true
|