Skip to content

Commit

Permalink
Fix GitHub CI build issue
Browse files Browse the repository at this point in the history
Signed-off-by: Anup Patel <[email protected]>
  • Loading branch information
avpatel committed Aug 15, 2024
1 parent 14d490c commit 85f0054
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 94 deletions.
64 changes: 0 additions & 64 deletions .github/workflows/build-doc.yml

This file was deleted.

73 changes: 73 additions & 0 deletions .github/workflows/build-pdf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Create Specification Document

# The workflow is triggered by pull request, push to main, and manual dispatch.
on:
workflow_dispatch:
inputs:
version:
description: 'Release version, e.g. X.Y.Z:'
required: true
type: string
revision_mark:
description: 'Set revision mark as Draft, Release or Stable:'
required: true
type: string
default: 'Draft'
prerelease:
description: 'Tag as a pre-release?'
required: false
type: boolean
default: true
draft:
description: 'Create release as a draft?'
required: false
type: boolean
default: false
pull_request:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
# Step 1: Checkout the repository
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: 'recursive'

# Step 2: Pull the latest RISC-V Docs container image
- name: Pull Container
run: docker pull riscvintl/riscv-docs-base-container-image:latest

# Step 3: Build Files
- name: Build Files
run: make
env:
VERSION: v${{ github.event.inputs.version }}
REVMARK: ${{ github.event.inputs.revision_mark }}

# Step 4: Upload the built PDF files as a single artifact
- name: Upload Build Artifacts
uses: actions/upload-artifact@v3
with:
name: Build Artifacts
path: ${{ github.workspace }}/*.pdf
retention-days: 30

# Create Release
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: ${{ github.workspace }}/*.pdf
tag_name: v${{ github.event.inputs.version }}
name: Release ${{ github.event.inputs.version }}
draft: ${{ github.event.inputs.draft }}
prerelease: ${{ github.event.inputs.prerelease }}
env:
GITHUB_TOKEN: ${{ secrets.GHTOKEN }}
if: github.event_name == 'workflow_dispatch'
# This condition ensures this step only runs for workflow_dispatch events.
84 changes: 55 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,9 @@
# Build usable documents
#

ASCIIDOCTOR = asciidoctor
ASCIIDOCTOR_PDF = $(ASCIIDOCTOR)-pdf
OPTIONS := --trace \
-a toc \
-a compress \
-a mathematical-format=svg \
-a pdf-fontsdir=docs-resources/fonts \
-a pdf-theme=docs-resources/themes/riscv-pdf.yml \
--failure-level=ERROR
REQUIRES := --require=asciidoctor-bibtex \
--require=asciidoctor-diagram \
--require=asciidoctor-mathematical
DITAA = ditaa
DOCKER_RUN := docker run --rm -v ${PWD}:/build -w /build \
riscvintl/riscv-docs-base-container-image:latest

DEPS = src/contributors.adoc
DEPS += src/changelog.adoc
DEPS += src/intro.adoc
Expand All @@ -41,43 +31,79 @@ DEPS += src/ext-vendor.adoc
DEPS += src/ext-firmware.adoc
DEPS += src/references.adoc
DEPS += src/references.bib

DEPS += $(SPEC)/autogenerated/revision.adoc-snippet

IMAGES = images/riscv-sbi-intro1.png
IMAGES += images/riscv-sbi-intro2.png
IMAGES += images/riscv-sbi-hsm.png
IMAGES += images/riscv-sbi-sse-sm.png
REVSNIP = $(SPEC)/autogenerated/revision.adoc-snippet

TARGETS = riscv-sbi.pdf
TARGETS += riscv-sbi.html
TARGETS += $(REVSNIP)

COMMITDATE=$(shell git show -s --format=%ci | cut -d ' ' -f 1)
GITVERSION=$(shell git describe --tag)
SPEC=$(shell pwd)

.PHONY: all
all: $(IMAGES) $(TARGETS)
ASCIIDOCTOR_PDF := asciidoctor-pdf
OPTIONS := --trace \
-a compress \
-a mathematical-format=svg \
-a pdf-fontsdir=docs-resources/fonts \
-a pdf-theme=docs-resources/themes/riscv-pdf.yml \
--failure-level=ERROR
REQUIRES := --require=asciidoctor-bibtex \
--require=asciidoctor-diagram \
--require=asciidoctor-mathematical

images/%.png: src/%.ditaa
rm -f $@
$(DITAA) $< $@
.PHONY: all images clean

%.html: %.adoc $(IMAGES) $(REVSNIP) $(DEPS)
$(ASCIIDOCTOR) -d book -b html $<
all: $(TARGETS)
images: $(IMAGES)

%.pdf: %.adoc $(IMAGES) docs-resources/themes/riscv-pdf.yml $(REVSNIP) $(DEPS)
$(ASCIIDOCTOR_PDF) $(OPTIONS) $(REQUIRES) --out-file=$@ $<
# Preserve all intermediate files
.SECONDARY:

$(SPEC)/autogenerated:
-mkdir $@
images/%.png: src/%.ditaa
mkdir -p `dirname $@`
ditaa $< $@

$(SPEC)/autogenerated/revision.adoc-snippet: Makefile $(SPEC)/autogenerated
$(SPEC)/autogenerated/revision.adoc-snippet: Makefile
mkdir -p $(SPEC)/autogenerated
echo ":revdate: ${COMMITDATE}" > $@-tmp
echo ":revnumber: ${GITVERSION}" >> $@-tmp
(test -f $@ && diff $@ $@-tmp) || mv $@-tmp $@

%.pdf: %.adoc $(DEPS)
@echo "Checking if Docker is available..."
@if command -v docker >/dev/null 2>&1 ; then \
echo "Docker is available, building inside Docker container..."; \
$(MAKE) build-container/$@; \
cp -f build-container/$@ $@; \
else \
echo "Docker is not available, building without Docker..."; \
$(MAKE) build-no-container/$@; \
cp -f build-no-container/$@ $@; \
fi

build-container/%.pdf: %.adoc $(DEPS)
@echo "Starting build inside Docker container..."
@mkdir -p `dirname $@`
$(DOCKER_RUN) /bin/sh -c "$(ASCIIDOCTOR_PDF) $(OPTIONS) $(REQUIRES) --out-file=$@ $<"
@echo "Build completed successfully inside Docker container."

build-no-container/%.pdf: %.adoc $(DEPS)
@echo "Starting build..."
@mkdir -p `dirname $@`
$(ASCIIDOCTOR_PDF) $(OPTIONS) $(REQUIRES) --out-file=$@ $<
@echo "Build completed successfully."

.PHONY: clean
clean:
rm -f $(TARGETS)
@echo "Cleaning up generated files..."
rm -rf build-container build-no-container $(TARGETS)
rm -rf $(SPEC)/autogenerated
@echo "Cleanup completed."

.PHONY: install-debs
install-debs:
Expand Down
14 changes: 14 additions & 0 deletions dependencies/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
source 'https://rubygems.org'
gem 'asciidoctor'
gem 'asciidoctor-bibtex'
gem 'asciidoctor-diagram'
gem 'asciidoctor-mathematical'
gem 'asciidoctor-pdf'
gem 'citeproc-ruby'
gem 'coderay'
gem 'csl-styles'
gem 'json'
gem 'pygments.rb'
gem 'rghost'
gem 'rouge'
gem 'ruby_dev'
2 changes: 2 additions & 0 deletions dependencies/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Dependencies for the build environment for various package managers. Used in
`.github/workflows/`.
32 changes: 32 additions & 0 deletions dependencies/apt_packages.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
bison
build-essential
python3-pip
cmake
curl
flex
fonts-lyx
git
graphviz
default-jre
libcairo2-dev
libffi-dev
libgdk-pixbuf2.0-dev
libpango1.0-dev
libxml2-dev
libglib2.0-dev
make
pkg-config
ruby
ruby-dev
libgif-dev
libwebp-dev
libzstd-dev
ruby-full
gem
npm
texlive-latex-base
texlive-fonts-recommended
texlive-fonts-extra
texlive-latex-extra
texlive-science
ditaa
8 changes: 8 additions & 0 deletions dependencies/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"dependencies": {
"bytefield-svg": "^1.8.0",
"wavedrom-cli": "^2.6.8"
},
"name": "local",
"version": "0.0.1"
}
2 changes: 1 addition & 1 deletion docs-resources

0 comments on commit 85f0054

Please sign in to comment.