Skip to content

Commit ed3be61

Browse files
committed
Add GitHub CI for deployment and corresponding scripts
Set up GitHub Action CI to deploy page. Currently using the new GitHub feature to directly publish an artifact as a deployment instead of needing to go through a separate gh-pages branch. This makes sense for this repository because everything is generated by the vimhelp tool anyway and we never need to directly commit anything to a branch. By using an artifact based approach we won't have to worry about the Git repository getting too big (e.g. Neovim actually has a manual history pruning step to prune their gh-pages branch for this reason). Added some scripts to manually parse MacVim's version info from the source files so we can display that in the main page. Currently, the CI is going to run every night, which is not ideal. We should find a way to cache the last version we generated, and do not re-regenerate it unless this repo itself has changed, or MacVim has been updated.
1 parent 6beaaad commit ed3be61

File tree

5 files changed

+116
-0
lines changed

5 files changed

+116
-0
lines changed

.github/FUNDING.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github: macvim-dev
2+
open_collective: macvim

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"

.github/workflows/ci.yaml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: MacVim Documentation Build
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
schedule:
8+
- cron: "50 3 * * *" # 3:50 am UTC every day. Just a random time intentionally picked to be not during busy hours.
9+
workflow_dispatch:
10+
11+
# Allow one concurrent deployment
12+
concurrency:
13+
group: "pages"
14+
cancel-in-progress: true
15+
16+
env:
17+
MACVIM_REPO: 'macvim-dev/macvim'
18+
MACVIM_DIR: ${{ format('{0}/macvim', github.workspace) }}
19+
20+
jobs:
21+
# Build the page and upload it as an artifact
22+
build:
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: read
26+
steps:
27+
- uses: actions/checkout@v3
28+
29+
- name: Checkout MacVim
30+
uses: actions/checkout@v3
31+
with:
32+
repository: ${{ env.MACVIM_REPO }}
33+
path: 'macvim'
34+
35+
- uses: actions/setup-python@v4
36+
with:
37+
python-version: '3.x'
38+
cache: 'pip'
39+
cache-dependency-path: 'vimhelp/requirements.txt'
40+
41+
- name: Set up vimhelp
42+
run: |
43+
pip install -r vimhelp/requirements.txt
44+
45+
- name: Set up commit / version environmental vars
46+
run: |
47+
cd "$MACVIM_DIR"
48+
printf 'MACVIM_COMMIT=%s\n' $(git rev-parse HEAD) >> $GITHUB_ENV
49+
printf 'MACVIM_VERSION=%s\n' $(${GITHUB_WORKSPACE}/scripts/extract_macvim_version ./src) >> $GITHUB_ENV
50+
printf 'VIM_VERSION=%s\n' $(${GITHUB_WORKSPACE}/scripts/extract_vim_version ./src) >> $GITHUB_ENV
51+
52+
- name: Build the documentation
53+
run: |
54+
echo "MacVim commit: ${MACVIM_COMMIT}"
55+
echo "MacVim release: ${MACVIM_VERSION}"
56+
echo "Vim version: ${VIM_VERSION}"
57+
58+
version_string="r${MACVIM_VERSION} (Vim ${VIM_VERSION})"
59+
echo "Version string: $version_string"
60+
61+
cd vimhelp
62+
python3 scripts/h2h.py -i "$MACVIM_DIR/runtime/doc" -o ../build --project macvim --web-version --version "$version_string" --commit "$MACVIM_COMMIT"
63+
64+
- name: Upload page artifact
65+
uses: actions/upload-pages-artifact@v1
66+
with:
67+
path: build
68+
69+
# Deploy the artifact to the page
70+
deploy:
71+
needs: build
72+
73+
permissions:
74+
pages: write # to deploy to Pages
75+
id-token: write # to verify the deployment originates from an appropriate source
76+
77+
environment:
78+
name: github-pages
79+
url: ${{ steps.deployment.outputs.page_url }}
80+
81+
runs-on: ubuntu-latest
82+
steps:
83+
- name: Deploy to GitHub Pages
84+
id: deployment
85+
uses: actions/deploy-pages@v1

scripts/extract_macvim_version

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
set -e -o pipefail
4+
5+
srcdir=$1
6+
7+
macvim_release_number=`grep -A1 CFBundleVersion $srcdir/MacVim/Info.plist|tail -1|sed -E -e 's/^.*<string>([[:digit:]]+).*/\1/'`
8+
9+
echo "$macvim_release_number"

scripts/extract_vim_version

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
set -e -o pipefail
4+
5+
srcdir=$1
6+
7+
# Logic was extracted from MacVim's configure.ac
8+
vim_major_version_string=`grep -m 1 'define.*VIM_VERSION_MAJOR' $srcdir/version.h|sed -E -e 's/^.*([[:digit:]]+).*/\1/'`
9+
vim_minor_version_string=`/usr/bin/grep -m 1 'define.*VIM_VERSION_MINOR' $srcdir/version.h|sed -E -e 's/^.*([[:digit:]]+).*/\1/'`
10+
snapshot=`/usr/bin/grep -C2 "Add new patch number below this line" $srcdir/version.c|tail -1|sed -E -e 's/^ *([[:digit:]]+),.*/\1/'`
11+
12+
vim_short_version_string="$vim_major_version_string.$vim_minor_version_string.$snapshot"
13+
14+
echo "$vim_short_version_string"

0 commit comments

Comments
 (0)