Skip to content

Commit 122f8f0

Browse files
authored
Merge pull request #63 from afh/web-docs
Build documentation using nix for CI
2 parents 2e6d3b4 + 51e10f8 commit 122f8f0

File tree

10 files changed

+745
-44
lines changed

10 files changed

+745
-44
lines changed
Lines changed: 48 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,56 @@
1-
name: Build and Deploy
2-
1+
name: Build and Deploy static content to GitHub Pages
32
on:
4-
workflow_dispatch:
53
push:
6-
branches: [ "master" ]
4+
branches: master
75
pull_request:
8-
branches: [ "master" ]
6+
branches: master
7+
# Allows you to run this workflow manually from the Actions tab
8+
workflow_dispatch:
99

10-
permissions:
11-
contents: read
10+
# Allow one concurrent deployment
11+
concurrency:
12+
group: "pages"
13+
cancel-in-progress: true
1214

1315
jobs:
14-
build_and_deploy:
16+
build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v3
20+
- uses: cachix/install-nix-action@v20
21+
with:
22+
nix_path: nixpkgs=channel:nixos-unstable
23+
- name: Build website
24+
run: |
25+
mkdir -p build
26+
nix build .
27+
cp -R result/* build
28+
- name: Build documentation
29+
run: |
30+
mkdir -p build/doc
31+
nix build .#doc-ledger
32+
cp result/share/doc/ledger/ledger* build/doc
33+
nix build .#doc-ledger-mode
34+
cp result/ledger-mode.* build/doc
35+
- name: Upload artifact
36+
uses: actions/upload-pages-artifact@v1
37+
with:
38+
path: 'build'
39+
40+
deploy:
41+
if: ${{ github.ref == 'refs/heads/master' }}
42+
needs: build
43+
permissions:
44+
contents: read
45+
pages: write
46+
id-token: write
47+
environment:
48+
name: github-pages
49+
url: ${{ steps.deployment.outputs.page_url }}
1550
runs-on: ubuntu-latest
1651
steps:
17-
- uses: actions/checkout@v3
18-
- name: Install dependencies
19-
run: |
20-
sudo apt-get update;
21-
sudo apt-get install --yes \
22-
texinfo groff \
23-
texlive-base texlive-fonts-recommended texlive-plain-generic
24-
- name: Set up Ruby
25-
uses: ruby/setup-ruby@v1
26-
with:
27-
ruby-version: 2.7
28-
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
29-
- name: Build website
30-
run: bundle exec middleman build
31-
- name: Build documentation
32-
run: make docs
33-
- name: Deploy
34-
if: ${{ github.ref == 'refs/heads/master' }}
35-
env:
36-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
37-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
38-
uses: reggionick/s3-deploy@v3
39-
with:
40-
folder: build
41-
bucket: ${{ vars.AWS_S3_BUCKET }}
42-
bucket-region: ${{ vars.AWS_S3_BUCKET_REGION }}
43-
delete-removed: true
44-
no-cache: true
45-
private: true
46-
filesToInclude: ".*/*,*/*,**"
52+
- name: Setup Pages
53+
uses: actions/configure-pages@v3
54+
- name: Deploy to GitHub Pages
55+
id: deployment
56+
uses: actions/deploy-pages@v2

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ _*
77
snapshot.tar.gz
88
*.log
99
*.aes
10+
.DS_Store
11+
result*
1012
vendor/
1113
.bundle/

CNAME

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
www.ledger-cli.org

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ GEM
1010
public_suffix (>= 2.0.2, < 6.0)
1111
autoprefixer-rails (10.4.13.0)
1212
execjs (~> 2)
13-
backports (3.23.0)
13+
backports (3.24.0)
1414
coffee-script (2.4.1)
1515
coffee-script-source
1616
execjs

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ CURL := curl --silent --location
99

1010
OWNER := ledger
1111
REPO := ledger
12-
LATEST := $(shell curl -sqI -w '%{redirect_url}\n' -o /dev/null https://github.com/$(OWNER)/$(REPO)/releases/latest | rev | cut -d/ -f1 | rev)
12+
LATEST := $(shell curl -sqI -w '%{redirect_url}\n' -o /dev/null https://github.com/$(OWNER)/$(REPO)/releases/latest | awk -F/ '{print $$NF}' )
1313

1414
HOST := https://raw.githubusercontent.com
1515
ledger3.texi_repopath := $(OWNER)/$(REPO)/$(LATEST)/doc

flake.lock

Lines changed: 94 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
{
2+
description = "Website for ledger-cli.org";
3+
4+
nixConfig.bash-prompt = "ledger-cli.org$ ";
5+
6+
inputs = {
7+
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
8+
flake-utils.url = "github:numtide/flake-utils";
9+
# NOTA BENE: When a new release of ledger or ledger-mode is available, update
10+
# the tag in the url below and run `nix flake update`, so that GitHub Actions
11+
# will build the documentation from the latest ledger and ledger-mode release.
12+
# TODO: Replace `master` with the tag of the ledger release following 3.3.1, once available.
13+
ledger.url = "github:ledger/ledger/master";
14+
ledger-mode.url = "github:ledger/ledger-mode/v4.0.0";
15+
ledger-mode.flake = false;
16+
};
17+
18+
outputs = { self, nixpkgs, flake-utils, ledger, ledger-mode }:
19+
flake-utils.lib.eachDefaultSystem( system:
20+
let
21+
pkgs = import nixpkgs { inherit system; };
22+
gems = with pkgs; bundlerEnv {
23+
name = "ledger.github.io-gems";
24+
inherit ruby;
25+
gemdir = ./.;
26+
};
27+
tex = with pkgs; texlive.combine {
28+
inherit (texlive) collection-plaingeneric collection-fontsrecommended;
29+
};
30+
in
31+
{
32+
packages = rec {
33+
default = website;
34+
website = pkgs.stdenvNoCC.mkDerivation rec {
35+
name = "ledger.github.io";
36+
src = self;
37+
38+
dontConfigure = true;
39+
40+
nativeBuildInputs = with pkgs; [ gems ruby nodejs ];
41+
42+
buildPhase = ''
43+
runHook preBuild
44+
bundle exec middleman build
45+
runHook postBuild
46+
'';
47+
48+
installPhase = ''
49+
runHook preInstall
50+
mv build $out
51+
runHook postInstall
52+
'';
53+
};
54+
55+
doc-ledger = pkgs.stdenvNoCC.mkDerivation rec {
56+
name = "ledger";
57+
58+
src = ledger;
59+
60+
nativeBuildInputs = with pkgs; [
61+
cmake groff texinfo tex
62+
];
63+
64+
enableParallelBuilding = false;
65+
66+
preConfigure = "cd doc";
67+
68+
cmakeFlags = [ "-DBUILD_WEB_DOCS:BOOL=ON" "-Wno-dev" ];
69+
70+
buildFlags = "doc";
71+
};
72+
73+
doc-ledger-mode = pkgs.stdenvNoCC.mkDerivation rec {
74+
name = "ledger-mode";
75+
76+
src = ledger-mode;
77+
nativeBuildInputs = with pkgs; [
78+
texinfo tex
79+
];
80+
81+
enableParallelBuilding = false;
82+
83+
dontConfigure = true;
84+
85+
preBuild = "cd doc";
86+
buildPhase = ''
87+
runHook preBuild
88+
texi2pdf --batch ledger-mode.texi
89+
makeinfo --force --html --no-split ledger-mode.texi
90+
runHook postBuild
91+
'';
92+
93+
installPhase = ''
94+
runHook preInstall
95+
mkdir -p $out
96+
cp ledger-mode.html ledger-mode.pdf $out/
97+
runHook postInstall
98+
'';
99+
};
100+
};
101+
});
102+
}

0 commit comments

Comments
 (0)