Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

159 fix spec builds local and gh action #160

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 0 additions & 64 deletions .github/workflows/build-doc.yml

This file was deleted.

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

# The workflow is triggered by pull request, push to main, and manual dispatch.
on:
workflow_dispatch:
inputs:
revision_mark:
description: 'Set revision mark as Draft, Release or Stable:'
required: true
type: choice
options:
- Development
- Stable
- Frozen
- Ratified
default: Development
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:
# Checkout the repository
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Get next version
uses: reecetech/[email protected]
id: version
with:
scheme: semver
increment: patch

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

# Override VERSION and REVMARK for manual workflow dispatch
- name: Update environment variables
run: |
echo "VERSION=v${{ steps.version.outputs.version }}" >> "$GITHUB_ENV"
echo "REVMARK=${{ github.event.inputs.revision_mark }}" >> "$GITHUB_ENV"
if: github.event_name == 'workflow_dispatch'

# Build Files
- name: Build Files
run: make

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

# Create Release
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: ${{ github.workspace }}/build/*.pdf
tag_name: v${{ steps.version.outputs.version }}
name: Release ${{ steps.version.outputs.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.
143 changes: 70 additions & 73 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,87 +2,84 @@
# Build usable documents
#

ASCIIDOCTOR = asciidoctor
ASCIIDOCTOR_PDF = $(ASCIIDOCTOR)-pdf
DOCS := \
riscv-sbi.adoc

DATE ?= $(shell date +%Y-%m-%d)
VERSION ?= v3.0.0-rc1
REVMARK ?= Draft
DOCKER_IMG := riscvintl/riscv-docs-base-container-image:latest
ifneq ($(SKIP_DOCKER),true)
DOCKER_CMD := docker run --rm -v ${PWD}:/build -w /build \
${DOCKER_IMG} \
/bin/sh -c
DOCKER_QUOTE := "
endif

SRC_DIR := src
BUILD_DIR := build

DOCS_PDF := $(DOCS:%.adoc=%.pdf)
DOCS_HTML := $(DOCS:%.adoc=%.html)

XTRA_ADOC_OPTS :=
ASCIIDOCTOR_PDF := asciidoctor-pdf
ASCIIDOCTOR_HTML := asciidoctor
OPTIONS := --trace \
-a toc \
-a compress \
-a mathematical-format=svg \
-a revnumber=${VERSION} \
-a revremark=${REVMARK} \
-a revdate=${DATE} \
-a pdf-fontsdir=docs-resources/fonts \
-a pdf-theme=docs-resources/themes/riscv-pdf.yml \
$(XTRA_ADOC_OPTS) \
-D build \
--failure-level=ERROR
REQUIRES := --require=asciidoctor-bibtex \
--require=asciidoctor-diagram \
--require=asciidoctor-lists \
--require=asciidoctor-mathematical
DITAA = ditaa
DEPS = src/contributors.adoc
DEPS += src/changelog.adoc
DEPS += src/intro.adoc
DEPS += src/terms.adoc
DEPS += src/binary-encoding.adoc
DEPS += src/ext-base.adoc
DEPS += src/ext-legacy.adoc
DEPS += src/ext-time.adoc
DEPS += src/ext-ipi.adoc
DEPS += src/ext-rfence.adoc
DEPS += src/ext-hsm.adoc
DEPS += src/ext-sys-reset.adoc
DEPS += src/ext-pmu.adoc
DEPS += src/ext-debug-console.adoc
DEPS += src/ext-sys-suspend.adoc
DEPS += src/ext-cppc.adoc
DEPS += src/ext-nested-acceleration.adoc
DEPS += src/ext-steal-time.adoc
DEPS += src/ext-sse.adoc
DEPS += src/ext-firmware-features.adoc
DEPS += src/ext-debug-triggers.adoc
DEPS += src/ext-experimental.adoc
DEPS += src/ext-vendor.adoc
DEPS += src/ext-firmware.adoc
DEPS += src/references.adoc
DEPS += src/references.bib
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)

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

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

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

$(SPEC)/autogenerated:
-mkdir $@

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

.PHONY: clean
clean:
rm -f $(TARGETS)
rm -rf $(SPEC)/autogenerated

.PHONY: install-debs
install-debs:
sudo apt-get install pandoc asciidoctor ditaa ruby-asciidoctor-pdf
.PHONY: all build clean build-container build-no-container build-docs

all: build

build-docs: $(DOCS_PDF) $(DOCS_HTML)

vpath %.adoc $(SRC_DIR)

.PHONY: install-rpms
install-rpms:
sudo dnf install ditaa pandoc rubygem-asciidoctor rubygem-asciidoctor-pdf
%.pdf: %.adoc
$(DOCKER_CMD) $(DOCKER_QUOTE) $(ASCIIDOCTOR_PDF) $(OPTIONS) $(REQUIRES) $< $(DOCKER_QUOTE)

%.html: %.adoc
$(DOCKER_CMD) $(DOCKER_QUOTE) $(ASCIIDOCTOR_HTML) $(OPTIONS) $(REQUIRES) $< $(DOCKER_QUOTE)

build:
@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; \
else \
echo "Docker is not available, building without Docker..."; \
$(MAKE) build-no-container; \
fi

build-container:
@echo "Starting build inside Docker container..."
$(MAKE) build-docs
@echo "Build completed successfully inside Docker container."

build-no-container:
@echo "Starting build..."
$(MAKE) SKIP_DOCKER=true build-docs
@echo "Build completed successfully."

# Update docker image to latest
docker-pull-latest:
docker pull ${DOCKER_IMG}

clean:
@echo "Cleaning up generated files..."
rm -rf $(BUILD_DIR)
@echo "Cleanup completed."
7 changes: 4 additions & 3 deletions riscv-sbi.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
:description: Supervisor Binary Interface
:company: RISC-V.org
// Pull in variable with revision info
include::autogenerated/revision.adoc-snippet[]
#include::autogenerated/revision.adoc-snippet[]
:revremark: This document is under development. Expect potential changes.
:url-riscv: http://riscv.org
:doctype: book
Expand All @@ -17,6 +17,7 @@ include::autogenerated/revision.adoc-snippet[]
:experimental:
:reproducible:
//:WaveDromEditorApp: app/wavedrom-editor.app
:imagesdir: .
:imagesoutdir: docs-resources/images
:bibtex-file: src/references.bib
:bibtex-order: alphabetical
Expand All @@ -37,8 +38,8 @@ endif::[]
:stem: latexmath
:footnote:
:xrefstyle: short
:table
font_size: 12
//#:table
// font_size: 12

// Preamble
[WARNING]
Expand Down