Skip to content

Commit

Permalink
feat: extension
Browse files Browse the repository at this point in the history
  • Loading branch information
alandefreitas committed Aug 6, 2024
1 parent 23d2188 commit 6cf5bf2
Show file tree
Hide file tree
Showing 10 changed files with 826 additions and 0 deletions.
99 changes: 99 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Continuous Integration

on:
push:
branches:
- '*'
tags:
- "v*.*.*"
pull_request:
branches:
- develop

concurrency:
group: ${{format('{0}:{1}', github.repository, github.ref)}}
cancel-in-progress: true

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
run: npm ci

- name: Tests
run: npm test

publish-npm:
name: Publish NPM package
needs: [ build ]
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Check version tags
run: |
GITHUB_TAGNAME=${{ github.ref_name }}
if [[ ! $GITHUB_TAGNAME =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Tag name is not valid. It should match the pattern v*.*.*"
exit 1
fi
PACKAGE_JSON_VERSION=$(node -p "require('./package.json').version")
if [[ $GITHUB_TAGNAME != "v$PACKAGE_JSON_VERSION" ]]; then
echo "Tag name does not match package.json version"
exit 1
fi
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/

- name: Install dependencies
run: npm ci

- name: Generate README.md
run: |
sudo apt install -y pandoc asciidoc-base
asciidoc -b docbook README.adoc
pandoc -f docbook -t markdown README.xml -o README.md
rm README.xml
- name: Publish NPM package
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

publish-github:
name: Publish Github Release
needs: [ build, publish-npm ]
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
permissions:
contents: write

steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Changelog
uses: alandefreitas/cpp-actions/create-changelog@v1.8.3
with:
thank-non-regular: true

- name: Release
uses: softprops/action-gh-release@v2
with:
body_path: CHANGELOG.md
218 changes: 218 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
### jetbrains

# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser


### visualstudiocode

.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# Local History for Visual Studio Code
.history/


### node

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test
.env.production

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*


.idea/
*.iml

example/doc/build/
example/build/
23 changes: 23 additions & 0 deletions LICENSE_1_0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Boost Software License - Version 1.0 - August 17th, 2003

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
48 changes: 48 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,2 +1,50 @@
= Antora Playbook Macros Extension

This allows you to use macros in your Antora playbook.

== Configuration

=== npm

Install this extension

[source,bash]
----
npm i -D @alandefreitas/antora-playbook-macros-extension
----

=== Playbook

Append the following in your `playbook.yaml`:

[source,yaml]
----
antora:
extensions:
- require: '@alandefreitas/antora-playbook-macros-extension' # <1>
macros: # <2>
key1: value1
key2: value2
----

* <1> `npm` package name: `@alandefreitas/antora-playbook-macros-extension` (required)
* <2> List of default macros and values (optional)

== Using macros

Any value in the playbook can use a macro with the `${key}` syntax. The value will be replaced by the macro value as defined by one of the following sources:

1. Environment variable
2. Uppercase environment variable
3. Asciidoc attribute
4. Default value
5. Predefined macros

Asciidoc attributes comes from the `asciidoc.attributes` section of the playbook. They can also be set in the antora command line using the `--attribute` option.

Default values are defined in the `macros` section of extension configuration. The provide a way to define default values for macros that are not set in any other source.

The predefined macros are:

- `branch`: The current branch name as per `git rev-parse --abbrev-ref HEAD`
- `commit-id`: The current commit hash as per `git rev-parse HEAD`
Loading

0 comments on commit 6cf5bf2

Please sign in to comment.